Weight: 6
Deploy a pod named nginx-pod using the nginx:alpine image.
Once done, click on the Next Question button in the top right corner of this panel. You may navigate back and forth freely between all questions. Once done with all questions, click on End Exam. Your work will be validated at the end and score shown. Good Luck!
Name: nginx-pod
Image: nginx:alpine
kubectl run nginx-pod --image=nginx:alpine
Weight: 8
Deploy a messaging pod using the redis:alpine image with the labels set to tier=msg.
Pod Name: messaging
Image: redis:alpine
Labels: tier=msg
controlplane ~ ✖ cat > 2.yaml
apiVersion: v1
kind: Pod
metadata:
name: messaging
labels:
tier: msg
spec:
containers:
- name: messaging
image: redis:alpine
controlplane ~ ➜ kubectl apply -f 2.yaml
pod/messaging created
Weight: 4
Create a namespace named apx-x9984574.
Namespace: apx-x9984574
kubectl create namespace apx-x9984574
Weight: 7
Get the list of nodes in JSON format and store it in a file at /opt/outputs/nodes-z3444kd9.json.
Task completed
controlplane ~ ➜ kubectl get nodes -o json > /opt/outputs/nodes-z3444kd9.json
Weight: 12
Create a service messaging-service to expose the messaging application within the cluster on port 6379.
Use imperative commands.
Service: messaging-service
Port: 6379
Type: ClusterIp
Use the right labels
kubectl expose pod messaging --port=6379 --name=messaging-service --type=ClusterIP
Create a deployment named hr-web-app using the image kodekloud/webapp-color with 2 replicas.
Name: hr-web-app
Image: kodekloud/webapp-color
Replicas: 2
kubectl create deployment hr-web-app --image=kodekloud/webapp-color --replicas=2
Weight: 8
Create a static pod named static-busybox on the controlplane node that uses the busybox image and the command sleep 1000.
Name: static-busybox
Image: busybox
/etc/kubernetes/manifests/아래가 됨controlplane ~ ✖ kubectl run --image=busybox static-busybox --dry-run=client -oyaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml
Weight: 12
Create a POD in the finance namespace named temp-bus with the image redis:alpine.
Name: temp-bus
Image Name: redis:alpine
controlplane ~ ✖ kubectl run temp-bus --image=redis:alpine -n=finance
pod/temp-bus created
Weight: 8
A new application orange is deployed. There is something wrong with it. Identify and fix the issue.
Issue fixed
ontrolplane ~ ✖ kubectl logs orange
Defaulted container "orange-container" out of: orange-container, init-myservice (init)
Error from server (BadRequest): container "orange-container" in pod "orange" is waiting to start: PodInitializing
controlplane ~ ✖ kubectl logs orange init-myservice
sh: sleeeep: not found
controlplane ~ ➜ vi orange_md.yaml
controlplane ~ ✖ cat orange_or.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-06-02T15:30:29Z"
name: orange
namespace: default
resourceVersion: "7845"
uid: 3cb2871c-dbff-439f-8b85-6c37b3612251
spec:
containers:
- command:
- sh
- -c
- echo The app is running! && sleep 3600
image: busybox:1.28
imagePullPolicy: IfNotPresent
name: orange-container
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-8fsw6
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
initContainers:
- command:
- sh
- -c
- sleeeep 2;
image: busybox
imagePullPolicy: Always
name: init-myservice
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-8fsw6
readOnly: true
nodeName: controlplane
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-8fsw6
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:31Z"
status: "True"
type: PodReadyToStartContainers
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with incomplete status: [init-myservice]'
reason: ContainersNotInitialized
status: "False"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with unready status: [orange-container]'
reason: ContainersNotReady
status: "False"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with unready status: [orange-container]'
reason: ContainersNotReady
status: "False"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
status: "True"
type: PodScheduled
containerStatuses:
- image: busybox:1.28
imageID: ""
lastState: {}
name: orange-container
ready: false
restartCount: 0
started: false
state:
waiting:
reason: PodInitializing
hostIP: 192.21.108.6
hostIPs:
- ip: 192.21.108.6
initContainerStatuses:
- containerID: containerd://a794eeb02db49b52095d7502a127d93b1b56b41b9c92ccfe3276868783593793
image: docker.io/library/busybox:latest
imageID: docker.io/library/busybox@sha256:5eef5ed34e1e1ff0a4ae850395cbf665c4de6b4b83a32a0bc7bcb998e24e7bbb
lastState:
terminated:
containerID: containerd://a794eeb02db49b52095d7502a127d93b1b56b41b9c92ccfe3276868783593793
exitCode: 127
finishedAt: "2024-06-02T15:31:56Z"
reason: Error
startedAt: "2024-06-02T15:31:56Z"
name: init-myservice
ready: false
restartCount: 4
started: false
state:
waiting:
message: back-off 1m20s restarting failed container=init-myservice pod=orange_default(3cb2871c-dbff-439f-8b85-6c37b3612251)
reason: CrashLoopBackOff
phase: Pending
podIP: 10.244.0.10
podIPs:
- ip: 10.244.0.10
qosClass: BestEffort
startTime: "2024-06-02T15:30:29Z"
controlplane ~ ➜ cat orange_md.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-06-02T15:30:29Z"
name: orange
namespace: default
resourceVersion: "7845"
uid: 3cb2871c-dbff-439f-8b85-6c37b3612251
spec:
containers:
- command:
- sh
- -c
- echo The app is running! && sleep 3600
image: busybox:1.28
imagePullPolicy: IfNotPresent
name: orange-container
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-8fsw6
readOnly: true
dnsPolicy: ClusterFirst
enableServiceLinks: true
initContainers:
- command:
- sh
- -c
- sleep 2
image: busybox
imagePullPolicy: Always
name: init-myservice
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/run/secrets/kubernetes.io/serviceaccount
name: kube-api-access-8fsw6
readOnly: true
nodeName: controlplane
preemptionPolicy: PreemptLowerPriority
priority: 0
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
serviceAccount: default
serviceAccountName: default
terminationGracePeriodSeconds: 30
tolerations:
- effect: NoExecute
key: node.kubernetes.io/not-ready
operator: Exists
tolerationSeconds: 300
- effect: NoExecute
key: node.kubernetes.io/unreachable
operator: Exists
tolerationSeconds: 300
volumes:
- name: kube-api-access-8fsw6
projected:
defaultMode: 420
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
items:
- key: ca.crt
path: ca.crt
name: kube-root-ca.crt
- downwardAPI:
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
path: namespace
status:
conditions:
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:31Z"
status: "True"
type: PodReadyToStartContainers
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with incomplete status: [init-myservice]'
reason: ContainersNotInitialized
status: "False"
type: Initialized
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with unready status: [orange-container]'
reason: ContainersNotReady
status: "False"
type: Ready
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
message: 'containers with unready status: [orange-container]'
reason: ContainersNotReady
status: "False"
type: ContainersReady
- lastProbeTime: null
lastTransitionTime: "2024-06-02T15:30:29Z"
status: "True"
type: PodScheduled
containerStatuses:
- image: busybox:1.28
imageID: ""
lastState: {}
name: orange-container
ready: false
restartCount: 0
started: false
state:
waiting:
reason: PodInitializing
hostIP: 192.21.108.6
hostIPs:
- ip: 192.21.108.6
initContainerStatuses:
- containerID: containerd://a794eeb02db49b52095d7502a127d93b1b56b41b9c92ccfe3276868783593793
image: docker.io/library/busybox:latest
imageID: docker.io/library/busybox@sha256:5eef5ed34e1e1ff0a4ae850395cbf665c4de6b4b83a32a0bc7bcb998e24e7bbb
lastState:
terminated:
containerID: containerd://a794eeb02db49b52095d7502a127d93b1b56b41b9c92ccfe3276868783593793
exitCode: 127
finishedAt: "2024-06-02T15:31:56Z"
reason: Error
startedAt: "2024-06-02T15:31:56Z"
name: init-myservice
ready: false
restartCount: 4
started: false
state:
waiting:
message: back-off 1m20s restarting failed container=init-myservice pod=orange_default(3cb2871c-dbff-439f-8b85-6c37b3612251)
reason: CrashLoopBackOff
phase: Pending
podIP: 10.244.0.10
podIPs:
- ip: 10.244.0.10
qosClass: BestEffort
startTime: "2024-06-02T15:30:29Z"
controlplane ~ ➜ kubectl replace -f orange_md.yaml --force
pod "orange" deleted
pod/orange replaced
Weight: 10
Expose the hr-web-app as service hr-web-app-service application on port 30082 on the nodes on the cluster.
The web application listens on port 8080.
Name: hr-web-app-service
Type: NodePort
Endpoints: 2
Port: 8080
NodePort: 30082
k expose deployment hr-web-app --name=hr-web-app-service --port=8080 --type=NodePort --dry-run=client -o yaml > 10.yaml
k expose deployment hr-web-app --name=hr-web-app-service --port=8080 --type=NodePort --dry-run=client -o yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: hr-web-app
name: hr-web-app-service
spec:
ports:
- port: 8080
protocol: TCP
targetPort: 8080
selector:
app: hr-web-app
type: NodePort
status:
loadBalancer: {}
controlplane ~ ✖ vi 10.yaml
controlplane ~ ➜ cat 10.yaml
apiVersion: v1
kind: Service
metadata:
creationTimestamp: null
labels:
app: hr-web-app
name: hr-web-app-service
spec:
ports:
- port: 8080
protocol: TCP
nodePort: 30082
selector:
app: hr-web-app
type: NodePort
status:
loadBalancer: {}
controlplane ~ ➜ kubectl apply -f 10.yaml
service/hr-wep-app-service created
Weight: 6
Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os_x43kj56.txt.
The osImages are under the nodeInfo section under status of each node.
Task Completed
controlplane ~ ➜ kubectl get nodes -o jsonpath="{.items[*]['status.nodeInfo.osImages']}" > /opt/outputs/nodes_os_x43kj56.txt
controlplane ~ ➜ cat /opt/outputs/nodes_os_x43kj56.txt
Ubuntu 22.04.4 LTS
Weight: 8
Create a Persistent Volume with the given specification: -
Volume name: pv-analytics
Storage: 100Mi
Access mode: ReadWriteMany
Host path: /pv/data-analytics
Is the volume name set?
Is the storage capacity set?
Is the accessMode set?
Is the hostPath set?
controlplane ~ ➜ cat > 12.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-analytics
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 100Mi
accessModes:
- ReadWriteMany
hostPath:
path: "/pv/data-analytics"
controlplane ~ ➜ kubectl apply -f 12.yaml
persistentvolume/pv-analytics created