GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. .DEFAULT: all
  2. .PHONY: all release-bins clean realclean test integration-test generate-deploy check-generated
  3. SUDO := $(shell docker info > /dev/null 2> /dev/null || echo "sudo")
  4. TEST_FLAGS?=
  5. include docker/kubectl.version
  6. include docker/kustomize.version
  7. include docker/helm.version
  8. # NB default target architecture is amd64. If you would like to try the
  9. # other one -- pass an ARCH variable, e.g.,
  10. # `make ARCH=arm64`
  11. ifeq ($(ARCH),)
  12. ARCH=amd64
  13. endif
  14. CURRENT_OS_ARCH=$(shell echo `go env GOOS`-`go env GOARCH`)
  15. GOBIN?=$(shell echo `go env GOPATH`/bin)
  16. godeps=$(shell go list -deps -f '{{if not .Standard}}{{ $$dep := . }}{{range .GoFiles}}{{$$dep.Dir}}/{{.}} {{end}}{{end}}' $(1) | sed "s%${PWD}/%%g")
  17. FLUXD_DEPS:=$(call godeps,./cmd/fluxd/...)
  18. FLUXCTL_DEPS:=$(call godeps,./cmd/fluxctl/...)
  19. IMAGE_TAG:=$(shell ./docker/image-tag)
  20. VCS_REF:=$(shell git rev-parse HEAD)
  21. BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
  22. DOCS_PORT:=8000
  23. all: $(GOBIN)/fluxctl $(GOBIN)/fluxd build/.flux.done
  24. release-bins:
  25. for arch in amd64; do \
  26. for os in linux darwin windows; do \
  27. CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
  28. done; \
  29. done;
  30. for arch in arm arm64; do \
  31. for os in linux; do \
  32. CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
  33. done; \
  34. done;
  35. clean:
  36. go clean
  37. rm -rf ./build
  38. rm -f test/bin/kubectl test/bin/helm test/bin/kind test/bin/kustomize
  39. realclean: clean
  40. rm -rf ./cache
  41. test: test/bin/helm test/bin/kubectl test/bin/kustomize
  42. PATH="${PWD}/bin:${PWD}/test/bin:${PATH}" go test ${TEST_FLAGS} $(shell go list ./... | grep -v "^github.com/weaveworks/flux/vendor" | sort -u)
  43. e2e: test/bin/helm test/bin/kubectl build/.flux.done
  44. PATH="${PWD}/test/bin:${PATH}" CURRENT_OS_ARCH=$(CURRENT_OS_ARCH) test/e2e/run.sh
  45. build/.%.done: docker/Dockerfile.%
  46. mkdir -p ./build/docker/$*
  47. cp $^ ./build/docker/$*/
  48. $(SUDO) docker build -t docker.io/fluxcd/$* -t docker.io/fluxcd/$*:$(IMAGE_TAG) \
  49. --build-arg VCS_REF="$(VCS_REF)" \
  50. --build-arg BUILD_DATE="$(BUILD_DATE)" \
  51. -f build/docker/$*/Dockerfile.$* ./build/docker/$*
  52. touch $@
  53. build/.flux.done: build/fluxd build/kubectl build/kustomize docker/ssh_config docker/kubeconfig docker/known_hosts.sh
  54. build/fluxd: $(FLUXD_DEPS)
  55. build/fluxd: cmd/fluxd/*.go
  56. CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd
  57. build/kubectl: cache/linux-$(ARCH)/kubectl-$(KUBECTL_VERSION)
  58. test/bin/kubectl: cache/$(CURRENT_OS_ARCH)/kubectl-$(KUBECTL_VERSION)
  59. build/helm: cache/linux-$(ARCH)/helm-$(HELM_VERSION)
  60. test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION)
  61. build/kustomize: cache/linux-amd64/kustomize-$(KUSTOMIZE_VERSION)
  62. test/bin/kustomize: cache/$(CURRENT_OS_ARCH)/kustomize-$(KUSTOMIZE_VERSION)
  63. build/kubectl test/bin/kubectl build/kustomize test/bin/kustomize build/helm test/bin/helm:
  64. mkdir -p build
  65. cp $< $@
  66. if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-$(ARCH)" ]; then strip $@; fi
  67. chmod a+x $@
  68. cache/%/kubectl-$(KUBECTL_VERSION): docker/kubectl.version
  69. mkdir -p cache/$*
  70. curl --fail -L -o cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz "https://dl.k8s.io/$(KUBECTL_VERSION)/kubernetes-client-$*.tar.gz"
  71. [ $* != "linux-$(ARCH)" ] || echo "$(KUBECTL_CHECKSUM_$(ARCH)) cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz" | shasum -a 512 -c
  72. tar -m --strip-components 3 -C ./cache/$* -xzf cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz kubernetes/client/bin/kubectl
  73. mv ./cache/$*/kubectl $@
  74. cache/%/kustomize-$(KUSTOMIZE_VERSION): docker/kustomize.version
  75. mkdir -p cache/$*
  76. curl --fail -L -o $@ "https://github.com/kubernetes-sigs/kustomize/releases/download/v$(KUSTOMIZE_VERSION)/kustomize_$(KUSTOMIZE_VERSION)_`echo $* | tr - _`"
  77. [ $* != "linux-amd64" ] || echo "$(KUSTOMIZE_CHECKSUM) $@" | shasum -a 256 -c
  78. cache/%/helm-$(HELM_VERSION): docker/helm.version
  79. mkdir -p cache/$*
  80. curl --fail -L -o cache/$*/helm-$(HELM_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM_VERSION)-$*.tar.gz"
  81. [ $* != "linux-$(ARCH)" ] || echo "$(HELM_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
  82. tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm
  83. mv cache/$*/helm $@
  84. $(GOBIN)/fluxctl: $(FLUXCTL_DEPS)
  85. go install ./cmd/fluxctl
  86. $(GOBIN)/fluxd: $(FLUXD_DEPS)
  87. go install ./cmd/fluxd
  88. integration-test: all
  89. test/bin/test-flux
  90. generate-deploy: install/generated_templates.gogen.go
  91. cd deploy && go run ../install/generate.go deploy
  92. install/generated_templates.gogen.go: install/templates/*
  93. cd install && go run generate.go embedded-templates
  94. check-generated: generate-deploy install/generated_templates.gogen.go
  95. git diff --exit-code -- integrations/apis integrations/client install/generated_templates.gogen.go
  96. build-docs:
  97. @cd docs && docker build -t flux-docs .
  98. test-docs: build-docs
  99. @docker run -it flux-docs /usr/bin/linkchecker _build/html/index.html
  100. serve-docs: build-docs
  101. @echo Stating docs website on http://localhost:${DOCS_PORT}/_build/html/index.html
  102. @docker run -i -p ${DOCS_PORT}:8000 -e USER_ID=$$UID flux-docs