Repository Reading Site
22-web-deployment-v2.yaml
manifests/10-reliability/22-web-deployment-v2.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: web
namespace: reliability-lab
labels:
lesson: reliability
app: web
spec:
replicas: 3
minReadySeconds: 5
revisionHistoryLimit: 10
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
lesson: reliability
app: web
template:
metadata:
labels:
lesson: reliability
app: web
spec:
terminationGracePeriodSeconds: 30
containers:
- name: web
image: busybox:1.36
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
mkdir -p /www
httpd -f -p 8080 -h /www &
while true; do
printf 'version=%s\npod=%s\nnode=%s\ntime=%s\n' \
"${APP_VERSION}" \
"$(hostname)" \
"${NODE_NAME}" \
"$(date '+%Y-%m-%dT%H:%M:%S%z')" > /www/index.html
if [ -f /tmp/fail-readiness ]; then
rm -f /www/ready
else
printf 'ok\n' > /www/ready
fi
if [ -f /tmp/fail-liveness ]; then
rm -f /www/live
else
printf 'ok\n' > /www/live
fi
sleep 2
done
env:
- name: APP_VERSION
value: v2
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
lifecycle:
preStop:
exec:
command:
- sh
- -c
- |
rm -f /www/ready
sleep 20
ports:
- name: http
containerPort: 8080
readinessProbe:
httpGet:
path: /ready
port: http
periodSeconds: 3
failureThreshold: 1
livenessProbe:
httpGet:
path: /live
port: http
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 2
resources:
requests:
cpu: 10m
memory: 32Mi