Complete the code to specify the kind of Kubernetes object for a DaemonSet.
apiVersion: apps/v1 kind: [1] metadata: name: node-logger spec: selector: matchLabels: name: node-logger template: metadata: labels: name: node-logger spec: containers: - name: logger image: busybox command: ['sh', '-c', 'echo Logging from node; sleep 3600']
The kind field specifies the type of Kubernetes object. For running a pod on every node, use DaemonSet.
Complete the code to select pods with the correct label for the DaemonSet.
spec:
selector:
matchLabels:
name: [1]
template:
metadata:
labels:
name: node-loggerThe selector.matchLabels must match the labels in the pod template to manage the pods correctly.
Fix the error in the container command to keep the pod running.
containers: - name: logger image: busybox command: ['sh', '-c', [1]]
The command must keep the container running. Using sleep 3600 after echo keeps it alive for an hour.
Fill both blanks to specify the container image and the restart policy for the DaemonSet pods.
spec:
template:
spec:
containers:
- name: logger
image: [1]
restartPolicy: [2]The container image is busybox for a lightweight shell. The restart policy for DaemonSet pods is usually Always to keep pods running.
Fill all three blanks to create a DaemonSet that runs a pod with label 'app: monitor', image 'alpine', and command to sleep indefinitely.
apiVersion: apps/v1 kind: [1] metadata: name: monitor spec: selector: matchLabels: app: [2] template: metadata: labels: app: monitor spec: containers: - name: monitor image: [3] command: ['sh', '-c', 'sleep infinity']
The kind is DaemonSet to run pods on all nodes. The label app: monitor matches the pod template. The image alpine is a small Linux image suitable for this task.