apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: {% if profile == 'prod' %}production{% elif profile == 'staging' %}staging{% else %}development{% endif %}
labels:
app: myapp
environment: {{ profile }}
spec:
replicas: {% if profile == 'prod' %}3{% elif profile == 'staging' %}2{% else %}1{% endif %}
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
environment: {{ profile }}
spec:
containers:
- name: myapp
image: myorg/myapp:{{ values.image_tag }}
ports:
- containerPort: 8080
name: http
env:
- name: ENVIRONMENT
value: "{{ profile }}"
- name: DEBUG
value: "{% if profile == 'dev' %}true{% else %}false{% endif %}"
- name: APP_CONFIG
valueFrom:
configMapKeyRef:
name: myapp-config
key: config.yaml
resources:
requests:
cpu: {% if profile == 'prod' %}500m{% elif profile == 'staging' %}200m{% else %}100m{% endif %}
memory: {% if profile == 'prod' %}512Mi{% elif profile == 'staging' %}256Mi{% else %}128Mi{% endif %}
limits:
cpu: {% if profile == 'prod' %}2000m{% elif profile == 'staging' %}1000m{% else %}500m{% endif %}
memory: {% if profile == 'prod' %}1Gi{% elif profile == 'staging' %}512Mi{% else %}256Mi{% endif %}
livenessProbe:
httpGet:
path: /healthz
port: http
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: http
initialDelaySeconds: 5
periodSeconds: 5