Production design
- Docker & Kubernetes course
- Advanced
- Lesson 61/70
- 4 min
Design the architecture of a production app.
Project: a production-ready deployment
You'll make the shop application from the intermediate project production-ready. To be added:
- Database: a StatefulSet with a persistent disk and a headless service
- External access: an Ingress with a domain name and HTTPS
- Load: an HPA for the API
- Security: an application-specific ServiceAccount and least privilege
- Packaging: all the parts in a single Helm chart
magaza/
Chart.yaml
values.yaml
values-prod.yaml
templates/
db-statefulset.yaml db-service.yaml
api-deployment.yaml api-service.yaml api-hpa.yaml
web-deployment.yaml web-service.yaml
ingress.yaml serviceaccount.yamlDesigning the values
A good values.yaml exposes everything likely to change and gives safe defaults for development; the production file only contains the differences:
# values.yaml
image:
api: ghcr.io/ali/magaza-api
tag: "" # if empty, Chart.appVersion
api:
replicas: 1
autoscaling: {enabled: false, min: 2, max: 10, cpu: 70}
ingress:
enabled: false
host: magaza.local
# values-prod.yaml
api:
autoscaling: {enabled: true}
ingress:
enabled: true
host: magaza.example.comPractice Production values
Write the contents of values-prod.yaml: api.autoscaling.enabled: true; under ingress, enabled: true and host: magaza.example.com; db.storage: 20Gi.
Starter code
# values-prod.yaml
# buraya yazSample solution
# values-prod.yaml
api:
autoscaling:
enabled: true
ingress:
enabled: true
host: magaza.example.com
db:
storage: 20GiExpected output
$ helm template magaza ./magaza -f values-prod.yaml | grep -c "^kind:" 10
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 Where is it best to keep environment-specific differences (replica count, domain name)?
- In separate chart copies
- By entering the pods by hand
- In environment-specific values files (values-prod.yaml) Correct answer
- Hard-coded inside the templates
Explanation: The templates stay the same; only the values change.
2 Create the chart skeleton.
helm ____ magaza
helm create magaza
Explanation: helm create produces a sample chart.
3 Match.
| Term | Meaning |
|---|---|
StatefulSet |
Database |
Ingress |
HTTPS and domain |
HPA |
API scaling |
values-prod.yaml |
Production differences |