Merge lp:~ricardokirkner/isitdeployable/generic-deployment-infra into lp:isitdeployable

Proposed by Ricardo Kirkner
Status: Merged
Approved by: Ricardo Kirkner
Approved revision: 270
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~ricardokirkner/isitdeployable/generic-deployment-infra
Merge into: lp:isitdeployable
Diff against target: 244 lines (+12/-196)
3 files modified
.bzrignore (+1/-0)
deployment/Makefile (+5/-152)
deployment/README (+6/-44)
To merge this branch: bzr merge lp:~ricardokirkner/isitdeployable/generic-deployment-infra
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Review via email: mp+333804@code.launchpad.net

Commit message

rely on generic Makefile from ols-k8s project

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

I like red!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2017-11-10 16:19:27 +0000
3+++ .bzrignore 2017-11-16 11:28:00 +0000
4@@ -1,4 +1,5 @@
5 branches/*
6+deployment/ols-k8s
7 deployment/secrets.yaml
8 deployment/tmp/*
9 test.db
10
11=== modified file 'deployment/Makefile'
12--- deployment/Makefile 2017-11-15 15:42:19 +0000
13+++ deployment/Makefile 2017-11-16 11:28:00 +0000
14@@ -1,122 +1,17 @@
15 IMAGE_NAME ?= isitdeployable
16
17+# include generic Makefile
18+include ols-k8s/Makefile
19+
20 # pre-process arguments
21-# if the first argument is "special" (logs, describe, shell, bzr-check-lock, bzr-break-lock)...
22-ifneq (,$(filter $(firstword $(MAKECMDGOALS)),logs describe shell bzr-check-lock bzr-break-lock))
23+# if the first argument is "special" (bzr-check-lock, bzr-break-lock)...
24+ifneq (,$(filter $(firstword $(MAKECMDGOALS)),bzr-check-lock bzr-break-lock))
25 # use the rest as sub-arguments
26 ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
27 # ...and turn them into do-nothing targets
28 $(eval $(ARGS):;@:)
29 endif
30
31-.DEFAULT_GOAL := status
32-
33-.PHONY: help
34-help:
35- @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
36- | cut -d ':' -f 2,3 \
37- | sort \
38- | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
39-
40-.PHONY: status
41-status: ## Show cluster status info
42- @$(check-env-vars)
43- @kubectl cluster-info | grep 'Kubernetes master'
44- kubectl -n $(NAMESPACE) get -L revision po,rs,deploy,svc,cm,secrets,ingress
45-
46-.PHONY: namespace
47-namespace: tmp/namespace.yaml ## Create namespace
48- @$(check-env-vars)
49- kubectl apply -f tmp/namespace.yaml --record
50- kubectl get secret registry-access -o yaml | sed 's/default/$(NAMESPACE)/g' | kubectl -n $(NAMESPACE) apply -f - --record
51-
52-.PHONY: deploy
53-deploy: render-config ## Deploy stack (from scratch)
54- @$(check-env-vars)
55- @$(check-image-vars)
56- kubectl apply --record \
57- -f tmp/configmaps.yaml \
58- -f secrets.yaml \
59- -f tmp/services.yaml \
60- -f tmp/ingress.yaml
61- $(MAKE) migrate-db
62- kubectl apply --record -f tmp/deployments.yaml
63- kubectl -n $(NAMESPACE) rollout status deployment/app
64- $(MAKE) clean-migrate-db
65-
66-.PHONY: update-deploy
67-update-deploy: FILENAME ?= tmp/deployments.yaml
68-update-deploy: render-config ## Update deployment
69- @$(check-env-vars)
70- @$(check-image-vars)
71- kubectl replace -f $(FILENAME) --record
72- kubectl -n $(NAMESPACE) rollout status deployment/app
73-
74-.PHONY: update-config
75-update-config: tmp/configmaps.yaml ## Update config options
76- @$(check-env-vars)
77- kubectl replace -f tmp/configmaps.yaml --record
78-
79-.PHONY: update-secrets
80-update-secrets: ## Update secrets
81- @$(check-env-vars)
82- kubectl replace -f secrets.yaml --record
83-
84-.PHONY: update-code
85-update-code: ## Update image only
86- @$(check-env-vars)
87- @$(check-image-vars)
88- kubectl -n $(NAMESPACE) set image deployment/app app=$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) worker=$(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG) --record
89- kubectl -n $(NAMESPACE) rollout status deployment/app
90-
91-.PHONY: migrate-db
92-migrate-db: tmp/migrate-db-job.yaml ## Run schema migrations
93- @$(check-env-vars)
94- kubectl apply -f tmp/migrate-db-job.yaml --record
95- until kubectl -n $(NAMESPACE) get jobs migrate-db -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep True ; do sleep 1 ; done
96-
97-.PHONY: clean-migrate-db
98-clean-migrate-db: tmp/migrate-db-job.yaml ## Remove job for schema migrations
99- @$(check-env-vars)
100- kubectl delete -f tmp/migrate-db-job.yaml
101-
102-.PHONY: release
103-release: ## Cut a new release
104- @$(check-env-vars)
105- @$(check-image-vars)
106- $(MAKE) clean-config
107- $(MAKE) render-config
108- $(MAKE) migrate-db
109- $(MAKE) update-deploy
110- $(MAKE) clean-migrate-db
111-
112-.PHONY: rollback
113-rollback: ## Undo latest release
114- @$(check-env-vars)
115- kubectl -n $(NAMESPACE) rollout undo deploy/app
116-
117-.PHONY: logs
118-logs: ## Show logs
119- @$(check-env-vars)
120- kubectl -n $(NAMESPACE) logs $(ARGS)
121-
122-.PHONY: describe
123-describe: ## Describe pod
124- @$(check-env-vars)
125- kubectl -n $(NAMESPACE) describe $(ARGS)
126-
127-.PHONY: shell
128-shell: ## Open a shell
129- @$(check-env-vars)
130- kubectl -n $(NAMESPACE) exec -it $(ARGS) bash
131-
132-.PHONY: render-config
133-render-config: $(shell find config -name '*.yaml.tpl' -printf 'tmp/%f\n' | sed -e 's/.tpl//g') ## Render config from templates
134-
135-.PHONY: clean-config
136-clean-config: ## Delete rendered config files
137- rm -f tmp/*.yaml
138-
139 .PHONY: bzr-check-lock
140 bzr-check-lock: ## Check for bzr locks held in place
141 @$(check-env-vars)
142@@ -130,47 +25,5 @@
143 @$(check-env-vars)
144 kubectl -n $(NAMESPACE) exec -it $(ARGS) -c worker bash -- -c 'for branch in `find tmp/branches -name .bzr -type d | xargs dirname`; do (cd $${branch}; bzr break-lock); done'
145
146-
147-# helper targets
148-
149-tmp/%.yaml: config/%.yaml.tpl
150- $(MAKE) render-template SRC=$< DST=$@
151-
152-.PHONY: render-template
153-render-template:
154- @$(eval REVISION=$(shell docker inspect -f '{{.Config.Labels.revision}}' $(DOCKER_REGISTRY)/$(IMAGE_NAME):$(IMAGE_TAG)))
155- @REVISION=$(REVISION) IMAGE_NAME=$(IMAGE_NAME) IMAGE_TAG=$(IMAGE_TAG) envsubst < $(SRC) > $(DST)
156-
157-# defines
158-
159-define check-env-vars
160- if test -z "$(NAMESPACE)"; then \
161- echo "NAMESPACE variable not defined; aborting."; \
162- exit 1; \
163- elif test -z "$(DOMAIN)"; then \
164- echo "DOMAIN variable not defined; aborting."; \
165- exit 1; \
166- elif test -z "$(DB_EXTERNAL_NAME)"; then \
167- echo "DB_EXTERNAL_NAME variable not defined; aborting."; \
168- exit 1; \
169- elif test -z "$(AMQP_EXTERNAL_NAME)"; then \
170- echo "AMQP_EXTERNAL_NAME variable not defined; aborting."; \
171- exit 1; \
172- fi
173-endef
174-
175-define check-image-vars
176- if test -z "$(DOCKER_REGISTRY)"; then \
177- echo "DOCKER_REGISTRY variable not defined; aborting."; \
178- exit 1; \
179- elif test -z "$(IMAGE_NAME)"; then \
180- echo "IMAGE_NAME variable not defined; aborting."; \
181- exit 1; \
182- elif test -z "$(IMAGE_TAG)"; then \
183- echo "IMAGE_TAG variable not defined; aborting."; \
184- exit 1; \
185- fi
186-endef
187-
188 # other makefiles
189 include dev.mk
190
191=== modified file 'deployment/README'
192--- deployment/README 2017-11-10 18:54:25 +0000
193+++ deployment/README 2017-11-16 11:28:00 +0000
194@@ -1,44 +1,6 @@
195-= Bootstrap Kubernetes cluster
196-
197-make cluster
198-make registry-proxy
199-
200-= Build image
201-
202-cd .. && make k8s-build k8s-upload
203-
204-Take note of the tag applied to the build image. See last line of output, should be
205-something along the lines of:
206-
207-Successfully tagged isitdeployable:trunk-<revno>
208-
209-Then, from now on use IMAGE_TAG=trunk-<revno>
210-
211-= Initial deploy
212-
213-source envrc
214-make namespace
215-make external-services (for development only)
216-make secrets.yaml (for development only)
217-
218-Wait until the cluster is ready (check using `make status` until all pods are ready).
219-Then deploy the app:
220-
221-make deploy IMAGE_TAG=trunk-<revno>
222-
223-= Code update
224-
225-Assuming a new revision is available and an image was built and uploaded for it:
226-
227-make release IMAGE_TAG=trunk-<revno>
228-
229-= Config / Secret update
230-
231-make update-config
232-make update-secret
233-
234-= Redeploy
235-
236-You can easily redeploy any revision by just releasing it again:
237-
238-make release IMAGE_TAG=trunk-<revno>
239+= Get started
240+
241+git clone lp:ols-k8s
242+
243+The follow README from ols-k8s/README
244+

Subscribers

People subscribed via source and target branches