kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch07/sleep/sleep-with-html-server.yaml

39 lines
1.0 KiB
YAML

apiVersion: apps/v1
kind: Deployment
metadata:
name: sleep
labels:
kiamol: ch07
spec:
selector:
matchLabels:
app: sleep
template:
metadata:
labels:
app: sleep
spec:
initContainers:
- name: init-html
image: kiamol/ch03-sleep
command: ['sh', '-c', "echo '<!DOCTYPE html><html><body><h1>KIAMOL Ch07</h1></body></html>' > /data/index.html"]
volumeMounts:
- name: data
mountPath: /data
containers:
- name: sleep
image: kiamol/ch03-sleep
- name: server
image: kiamol/ch03-sleep
command: ['sh', '-c', 'while true; do echo -e "HTTP/1.1 200 OK\nContent-Type: text/html\nContent-Length: 62\n\n$(cat /data-ro/index.html)" | nc -l -p 8080; done']
ports:
- containerPort: 8080
name: http
volumeMounts:
- name: data
mountPath: /data-ro
readOnly: true
volumes:
- name: data
emptyDir: {}