apiVersion: apps/v1
kind: Deployment
metadata:
name: osydor-app
labels:
app: osydor-app
student: osydor
spec:
replicas: 1
selector:
matchLabels:
app: osydor-app
template:
metadata:
labels:
app: osydor-app
deploy: osydor-app
kind: redis
role: master
tier: db
spec:
containers:
- name: redis-master
image: redis:5-alpine
ports:
- containerPort: 6379
initContainers:
- command:
- sleep
- "10"
image: busybox:1.34
imagePullPolicy: IfNotPresent
name: busybox
Create a deployment manifest file /root/osydor-app.yaml
based on requirements below. And deploy it.
Requirements:
Deployment Name:
osydor-app
Deployment Labels:
- app:
osydor-app
- student:
osydor
- app:
Pod(s) Labels:
- deploy:
osydor-app
- kind:
redis
- role:
master
- tier:
db
- deploy:
Container:
- Image:
redis:5-alpine
- Port:
6379
- Name:
redis-master
- Image:
Init Container:
- Image:
busybox:1.34
- Command:
sleep 10
- Image:
Please Note!
Try to avoid using constructions like:
command: [ "sh", "-c"] args: ["sleep 10"]
or:
command: [ "sh", "-c", "sleep 10"]
Why?
Becausesleep
is a regular binary executable file which doesn’t require anyshell
wrappers
$ which sleep /usr/bin/sleep
Verify:
$ kubectl get deploy osydor-app
NAME READY UP-TO-DATE AVAILABLE AGE
osydor-app 1/1 1 1 17s
$ kubectl get pod -l deploy=osydor-app
NAME READY STATUS RESTARTS AGE
osydor-app-57479f67bc-nkdk7 1/1 Running 0 23s
$ cat << EOF | tr '\n' ',' | sed 's/,$//;s/ *//g' | \
xargs -IF kubectl get pod -l deploy=osydor-app -o custom-columns="F"
STATUS:.status.phase
CONT_IMAGE:.spec.containers[*].image
CONT_NAME:.spec.containers[*].name
CONT_PORT:.spec.containers[*].ports[*].containerPort
INITC_IMAGE:.spec.initContainers[*].image
INITC_CMD:.spec.initContainers[*].command
INITC_ARGS:.spec.initContainers[*].args
NAME:.metadata.name
EOF
STATUS CONT_IMAGE CONT_NAME CONT_PORT INITC_IMAGE INITC_CMD INITC_ARGS NAME
Running redis:5-alpine redis-master 6379 busybox:1.34 [sleep 10] <none> osydor-app-57479f67bc-nkdk7
Documentation:
- https://kubernetes.io/docs/concepts/workloads/pods/pod/
- https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
- https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
Check Report
✓ deployment created
✓ deployment labels are ok
✓ pod labels are ok
✓ image is ok
✓ port is ok
✓ container name is ok
✓ image is ok
✓ command is ok
Немає коментарів:
Дописати коментар