github.com/AliyunContainerService/heapster@v1.6.0-beta.1.0.20190403101729-c280e398e293/Makefile (about) 1 all: build 2 3 PREFIX?=staging-k8s.gcr.io 4 FLAGS= 5 ARCH?=amd64 6 ALL_ARCHITECTURES=amd64 arm arm64 ppc64le s390x 7 ML_PLATFORMS=linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x 8 GOLANG_VERSION?=1.8 9 10 ifndef TEMP_DIR 11 TEMP_DIR:=$(shell mktemp -d /tmp/heapster.XXXXXX) 12 endif 13 14 VERSION?=v1.6.0-beta.1 15 GIT_COMMIT:=$(shell git rev-parse --short HEAD) 16 17 TESTUSER= 18 ifdef REPO_DIR 19 DOCKER_IN_DOCKER=1 20 TESTUSER=jenkins 21 else 22 REPO_DIR:=$(shell pwd) 23 endif 24 25 # You can set this variable for testing and the built image will also be tagged with this name 26 OVERRIDE_IMAGE_NAME?= 27 28 # If this session isn't interactive, then we don't want to allocate a 29 # TTY, which would fail, but if it is interactive, we do want to attach 30 # so that the user can send e.g. ^C through. 31 INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) 32 TTY= 33 ifeq ($(INTERACTIVE), 1) 34 TTY=-t 35 endif 36 37 SUPPORTED_KUBE_VERSIONS=1.9.3 38 TEST_NAMESPACE=heapster-e2e-tests 39 40 HEAPSTER_LDFLAGS=-w -X k8s.io/heapster/version.HeapsterVersion=$(VERSION) -X k8s.io/heapster/version.GitCommit=$(GIT_COMMIT) 41 42 fmt: 43 find . -type f -name "*.go" | grep -v "./vendor*" | xargs gofmt -s -w 44 45 build: clean fmt 46 GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "$(HEAPSTER_LDFLAGS)" -o heapster k8s.io/heapster/metrics 47 GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "$(HEAPSTER_LDFLAGS)" -o eventer k8s.io/heapster/events 48 49 sanitize: 50 hooks/check_boilerplate.sh 51 hooks/check_gofmt.sh 52 hooks/run_vet.sh 53 54 test-unit: clean sanitize build 55 ifeq ($(ARCH),amd64) 56 GOARCH=$(ARCH) go test --test.short -race ./... $(FLAGS) 57 else 58 GOARCH=$(ARCH) go test --test.short ./... $(FLAGS) 59 endif 60 61 test-unit-cov: clean sanitize build 62 hooks/coverage.sh 63 64 test-integration: clean build 65 go test -v --timeout=60m ./integration/... --vmodule=*=2 $(FLAGS) --namespace=$(TEST_NAMESPACE) --kube_versions=$(SUPPORTED_KUBE_VERSIONS) --test_user=$(TESTUSER) --logtostderr 66 67 container: 68 # Run the build in a container in order to have reproducible builds 69 # Also, fetch the latest ca certificates 70 docker run --rm -i $(TTY) -v $(TEMP_DIR):/build -v $(REPO_DIR):/go/src/k8s.io/heapster -w /go/src/k8s.io/heapster golang:$(GOLANG_VERSION) /bin/bash -c "\ 71 cp /etc/ssl/certs/ca-certificates.crt /build \ 72 && GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags \"$(HEAPSTER_LDFLAGS)\" -o /build/heapster k8s.io/heapster/metrics \ 73 && GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags \"$(HEAPSTER_LDFLAGS)\" -o /build/eventer k8s.io/heapster/events" 74 75 cp deploy/docker/Dockerfile $(TEMP_DIR) 76 docker build --pull -t $(PREFIX)/heapster-$(ARCH):$(VERSION) $(TEMP_DIR) 77 ifneq ($(OVERRIDE_IMAGE_NAME),) 78 docker tag $(PREFIX)/heapster-$(ARCH):$(VERSION) $(OVERRIDE_IMAGE_NAME) 79 endif 80 81 ifndef DOCKER_IN_DOCKER 82 rm -rf $(TEMP_DIR) 83 endif 84 85 do-push: 86 docker push $(PREFIX)/heapster-$(ARCH):$(VERSION) 87 ifeq ($(ARCH),amd64) 88 # TODO: Remove this and push the manifest list as soon as it's working 89 docker tag $(PREFIX)/heapster-$(ARCH):$(VERSION) $(PREFIX)/heapster:$(VERSION) 90 docker push $(PREFIX)/heapster:$(VERSION) 91 endif 92 93 # Should depend on target: ./manifest-tool 94 push: gcr-login $(addprefix sub-push-,$(ALL_ARCHITECTURES)) 95 # ./manifest-tool push from-args --platforms $(ML_PLATFORMS) --template $(PREFIX)/heapster-ARCH:$(VERSION) --target $(PREFIX)/heapster:$(VERSION) 96 97 sub-push-%: 98 $(MAKE) ARCH=$* PREFIX=$(PREFIX) VERSION=$(VERSION) container 99 $(MAKE) ARCH=$* PREFIX=$(PREFIX) VERSION=$(VERSION) do-push 100 101 influxdb: 102 ARCH=$(ARCH) PREFIX=$(PREFIX) make -C influxdb build 103 104 grafana: 105 ARCH=$(ARCH) PREFIX=$(PREFIX) make -C grafana build 106 107 push-influxdb: 108 PREFIX=$(PREFIX) make -C influxdb push 109 110 push-grafana: 111 PREFIX=$(PREFIX) make -C grafana push 112 113 gcr-login: 114 ifeq ($(findstring gcr.io,$(PREFIX)),gcr.io) 115 @echo "If you are pushing to a gcr.io registry, you have to be logged in via 'docker login'; 'gcloud docker push' can't push manifest lists yet." 116 @echo "This script is automatically logging you in now with 'gcloud docker -a'" 117 gcloud docker -a 118 endif 119 120 # TODO(luxas): As soon as it's working to push fat manifests to gcr.io, reenable this code 121 #./manifest-tool: 122 # curl -sSL https://github.com/luxas/manifest-tool/releases/download/v0.3.0/manifest-tool > manifest-tool 123 # chmod +x manifest-tool 124 125 clean: 126 rm -f heapster 127 rm -f eventer 128 129 .PHONY: all build sanitize test-unit test-unit-cov test-integration container grafana influxdb clean