Files
the-order/infra/k8s/base/identity/deployment.yaml
T

114 lines
2.4 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: identity-service
namespace: the-order
labels:
app: identity-service
version: v1
spec:
replicas: 2
selector:
matchLabels:
app: identity-service
template:
metadata:
labels:
app: identity-service
version: v1
spec:
containers:
- name: identity
image: theorder/identity-service:latest
ports:
- containerPort: 4002
name: http
env:
- name: PORT
value: "4002"
- name: NODE_ENV
valueFrom:
configMapKeyRef:
name: the-order-config
key: ENVIRONMENT
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: the-order-secrets
key: database-url
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 4002
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /health
port: 4002
initialDelaySeconds: 10
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3
startupProbe:
httpGet:
path: /health
port: 4002
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 3
failureThreshold: 30
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 15"]
---
apiVersion: v1
kind: Service
metadata:
name: identity-service
namespace: the-order
spec:
selector:
app: identity-service
ports:
- port: 80
targetPort: 4002
protocol: TCP
type: ClusterIP
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: identity-service-hpa
namespace: the-order
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: identity-service
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80