CKA practice #75 Practise Static pod - Task 8

Course: Certified Kubernetes Administrator (CKA) with Practice Tests | Udemy Business

CKA practice #75 Practise Static pod - Task 8
Requirements:
Create a static pod named static-busybox that uses the busybox image and the command sleep 1000

Can I know why there is a need to put the command sleep 1000? I do notice it’s cycling in restart if I turn off sleep deliberately

controlplane ~ ➜ cat /etc/kubernetes/manifests/static-web.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: static-busybox3
name: static-busybox3
spec:
containers:

  • command:

    - sleep

    #- “1000”
    image: busybox
    name: static-busybox3
    resources: {}
    dnsPolicy: ClusterFirst
    restartPolicy: Always
    status: {}

controlplane ~ ➜ k get pod --watch
NAME READY STATUS RESTARTS AGE
static-busybox3-controlplane 0/1 CrashLoopBackOff 6 (4m30s ago) 10m
static-busybox3-controlplane 1/1 Running 7 (5m18s ago) 10m
static-busybox3-controlplane 0/1 Completed 7 (5m19s ago) 10m
static-busybox3-controlplane 0/1 CrashLoopBackOff 7 (12s ago) 11m

You’re getting the restart because if you don’t, the default command of busybox is “sh”, and you will exit immediately. sleep 1000 gives the container something to do to prevent it from exiting as “Completed”.

Make sense, thank you, Rob