пʼятниця, 17 листопада 2023 р.

Kubernetes. 3 Deployment. 6. Deployments.

 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
  • Pod(s) Labels:

    • deploy: osydor-app
    • kind: redis
    • role: master
    • tier: db
  • Container:

    • Image: redis:5-alpine
    • Port: 6379
    • Name: redis-master
  • Init Container:

    • Image: busybox:1.34
    • Command: sleep 10

Please Note!

Try to avoid using constructions like:

  command: [ "sh", "-c"]
  args: ["sleep 10"]

or:

  command: [ "sh", "-c", "sleep 10"]

Why?
Because sleep is a regular binary executable file which doesn’t require any shell 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:

Check Report

osydor-app deployment:

deployment created

deployment labels are ok

Pod template:

pod labels are ok

Pod Container:

image is ok

port is ok

container name is ok

Pod InitContainer:

image is ok

command is ok

Score: 100


 

Немає коментарів:

Дописати коментар