An orchestrator for managing a collection of Kubernetes Helm charts.
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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. # Copyright 2018 AT&T Intellectual Property. All other rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # APP INFO
  15. BUILD_DIR := $(shell mktemp -d)
  16. DOCKER_REGISTRY ?= quay.io
  17. IMAGE_PREFIX ?= airshipit
  18. IMAGE_NAME ?= armada
  19. IMAGE_TAG ?= latest
  20. HELM ?= $(BUILD_DIR)/helm
  21. PROXY ?= http://proxy.foo.com:8000
  22. NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
  23. USE_PROXY ?= false
  24. PUSH_IMAGE ?= false
  25. # use this variable for image labels added in internal build process
  26. LABEL ?= org.airshipit.build=community
  27. COMMIT ?= $(shell git rev-parse HEAD)
  28. PYTHON = python3
  29. CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
  30. DISTRO ?= ubuntu_bionic
  31. IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}-${DISTRO}
  32. UBUNTU_BASE_IMAGE ?=
  33. # VERSION INFO
  34. GIT_COMMIT = $(shell git rev-parse HEAD)
  35. GIT_SHA = $(shell git rev-parse --short HEAD)
  36. GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
  37. GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
  38. HELM_PIDFILE ?= $(abspath ./.helm-pid)
  39. ifdef VERSION
  40. DOCKER_VERSION = $(VERSION)
  41. endif
  42. SHELL = /bin/bash
  43. info:
  44. @echo "Version: ${VERSION}"
  45. @echo "Git Tag: ${GIT_TAG}"
  46. @echo "Git Commit: ${GIT_COMMIT}"
  47. @echo "Git Tree State: ${GIT_DIRTY}"
  48. @echo "Docker Version: ${DOCKER_VERSION}"
  49. @echo "Registry: ${DOCKER_REGISTRY}"
  50. .PHONY: all
  51. all: lint charts images
  52. .PHONY: build
  53. build: bootstrap
  54. $(PYTHON) setup.py install
  55. .PHONY: bootstrap
  56. bootstrap:
  57. pip install -r requirements.txt
  58. .PHONY: bootstrap-all
  59. bootstrap-all: bootstrap
  60. pip install -r test-requirements.txt
  61. .PHONY: check-docker
  62. check-docker:
  63. @if [ -z $$(which docker) ]; then \
  64. echo "Missing \`docker\` client which is required for development"; \
  65. exit 2; \
  66. fi
  67. .PHONY: check-tox
  68. check-tox:
  69. @if [ -z $$(which tox) ]; then \
  70. echo "Missing \`tox\` client which is required for development"; \
  71. exit 2; \
  72. fi
  73. .PHONY: images
  74. images: check-docker build_armada
  75. .PHONY: docs
  76. docs: clean build_docs
  77. .PHONY: build_docs
  78. build_docs:
  79. tox -e docs
  80. .PHONY: run_images
  81. run_images: run_armada
  82. .PHONY: run_armada
  83. run_armada: build_armada
  84. ./tools/armada_image_run.sh $(IMAGE)
  85. _BASE_IMAGE_ARG := $(if $(UBUNTU_BASE_IMAGE),--build-arg FROM="${UBUNTU_BASE_IMAGE}" ,)
  86. .PHONY: build_armada
  87. build_armada:
  88. ifeq ($(USE_PROXY), true)
  89. docker build --network host -t $(IMAGE) --label $(LABEL) \
  90. --label "org.opencontainers.image.revision=$(COMMIT)" \
  91. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  92. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  93. -f images/armada/Dockerfile.$(DISTRO) \
  94. $(_BASE_IMAGE_ARG) \
  95. --build-arg http_proxy=$(PROXY) \
  96. --build-arg https_proxy=$(PROXY) \
  97. --build-arg HTTP_PROXY=$(PROXY) \
  98. --build-arg HTTPS_PROXY=$(PROXY) \
  99. --build-arg no_proxy=$(NO_PROXY) \
  100. --build-arg NO_PROXY=$(NO_PROXY) .
  101. else
  102. docker build --network host -t $(IMAGE) --label $(LABEL) \
  103. --label "org.opencontainers.image.revision=$(COMMIT)" \
  104. --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
  105. --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
  106. -f images/armada/Dockerfile.$(DISTRO) \
  107. $(_BASE_IMAGE_ARG) .
  108. endif
  109. ifeq ($(PUSH_IMAGE), true)
  110. docker push $(IMAGE)
  111. endif
  112. # make tools
  113. .PHONY: protoc
  114. protoc:
  115. @tools/helm-hapi.sh
  116. .PHONY: clean
  117. clean:
  118. rm -rf build
  119. rm -rf doc/build
  120. rm -f charts/*.tgz
  121. rm -f charts/*/requirements.lock
  122. rm -rf charts/*/charts
  123. # testing checks
  124. .PHONY: tests
  125. tests: check-tox
  126. tox
  127. .PHONY: test-all
  128. test-all: check-tox helm_lint
  129. tox
  130. .PHONY: test-unit
  131. test-unit: check-tox
  132. tox -e py35
  133. .PHONY: test-coverage
  134. test-coverage: check-tox
  135. tox -e cover
  136. .PHONY: test-bandit
  137. test-bandit: check-tox
  138. tox -e bandit
  139. # style checks
  140. .PHONY: lint
  141. lint: test-pep8 helm_lint
  142. .PHONY: test-pep8
  143. test-pep8: check-tox
  144. tox -e pep8
  145. chartbanner:
  146. @echo Building charts: $(CHARTS)
  147. .PHONY: charts
  148. charts: $(CHARTS)
  149. @echo Done building charts.
  150. .PHONY: helm-init
  151. helm-init: $(addprefix helm-init-,$(CHARTS))
  152. .PHONY: helm-init-%
  153. helm-init-%: helm-serve
  154. @echo Initializing chart $*
  155. cd charts;if [ -s $*/requirements.yaml ]; then echo "Initializing $*";$(HELM) dep up $*; fi
  156. .PHONY: helm-serve
  157. helm-serve: helm-install
  158. ./tools/helm_tk.sh $(HELM) $(HELM_PIDFILE)
  159. .PHONY: helm-lint
  160. helm-lint: $(addprefix helm-lint-,$(CHARTS))
  161. .PHONY: helm-lint-%
  162. helm-lint-%: helm-init-%
  163. @echo Linting chart $*
  164. cd charts;$(HELM) lint $*
  165. .PHONY: dry-run
  166. dry-run: clean $(addprefix dry-run-,$(CHARTS))
  167. .PHONY: dry-run-%
  168. dry-run-%: helm-lint-%
  169. echo Running Dry-Run on chart $*
  170. cd charts;$(HELM) template --set pod.resources.enabled=true $*
  171. .PHONY: $(CHARTS)
  172. $(CHARTS): $(addprefix dry-run-,$(CHARTS)) chartbanner
  173. $(HELM) package -d charts charts/$@
  174. # Install helm binary
  175. .PHONY: helm-install
  176. helm-install:
  177. ./tools/helm_install.sh $(HELM)