Putting it together - production
- Docker & Kubernetes course
- Advanced
- Lesson 65/70
- 5 min
Apply all resources to deploy the production app.
Putting it together: the production rollout
In the last step the chart is deployed to production with a single command and the deployment is verified end to end. A safe CI step does the following: lints the chart, shows the difference, upgrades with --atomic (rolls back on failure) and tests the external address:
helm lint ./magaza -f values-prod.yaml
helm upgrade --install magaza ./magaza -n magaza -f values-prod.yaml \
--set image.tag=$GIT_SHA --atomic --timeout 10m
kubectl get all,ing,hpa,pvc -n magaza
curl -fsS https://magaza.example.com/api/saglikThe rollback plan
Every production deployment must have a rollback path. Helm revisions bring the application version back; but database migrations may not be reversible; that's why migrations are written backward-compatibly (first add the column, then use it, finally remove the old one):
helm history magaza -n magaza
REVISION STATUS APP VERSION DESCRIPTION
11 superseded 1.4.2 Upgrade complete
12 deployed 1.5.0 Upgrade complete
helm rollback magaza 11 -n magaza --waitPractice Deploy to production
Write four commands: lint ./magaza with values-prod.yaml; upgrade the magaza release in the magaza namespace, installing it if missing, with values-prod.yaml, --set image.tag=$GIT_SHA, --atomic and --timeout 10m; list the all,ing,hpa,pvc objects in magaza; test with curl -fsS https://magaza.example.com/api/saglik.
Starter code
# buraya yazSample solution
helm lint ./magaza -f values-prod.yaml
helm upgrade --install magaza ./magaza -n magaza -f values-prod.yaml --set image.tag=$GIT_SHA --atomic --timeout 10m
kubectl get all,ing,hpa,pvc -n magaza
curl -fsS https://magaza.example.com/api/saglikExpected output
1 chart(s) linted, 0 chart(s) failed
Release "magaza" has been upgraded. Happy Helming!
NAME READY STATUS RESTARTS AGE
pod/api-6b5c4d3e2-abcde 1/1 Running 0 1m
pod/db-0 1/1 Running 0 3d
{"durum":"ok","surum":"9f3c2a1"}
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Why is the Git commit hash (GIT_SHA) used for image.tag?
- Because it equals latest
- Because Helm requires it
- Each deployment shows exactly which code version runs, and it can be rolled back Correct answer
- Because it's shorter
Explanation: Immutable tags are the basis of reproducible deployments.
2 Automatically roll back a failed upgrade.
helm upgrade --install magaza ./magaza -n magaza -f values-prod.yaml ____ --timeout 10m
helm upgrade --install magaza ./magaza -n magaza -f values-prod.yaml --atomic --timeout 10m
Explanation: --atomic returns to the previous revision on failure.
3 Match.
| Term | Meaning |
|---|---|
helm lint |
Check first |
--atomic |
Roll back on failure |
GIT_SHA etiketi |
Exact version |
curl -fsS |
External test |