Please answer the quiz and click the "Test" button at the bottom right.

Kubernetes - Core Objects - multichoice questions

Given the below Pod YAML manifest:

apiVersion: v1
kind: Pod
metadata:
  name: nginx-with-sidecar
  labels:
    app: nginx-with-sidecar
spec:
  containers:
    - name: nginx
      image: nginx:1.14
      ports:
        - containerPort: 80
    - name: sidecar-container
      image: busybox:latest
      command: ["/bin/sh", "-c", "while true; do echo 'Sidecar Container Running'; sleep 10; done"]
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
spec:
  selector:
    app: nginx-with-sidecar
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80

Answer the below 4 questions

Question 1

Choose the correct sentence:

Question 2

Performing curl http://nginx-service:80 from another pod in the cluster located in the default namespace:

Question 3

Let's say, in addition to the above nginx-with-sidecar Pod, you apply the following Deployment manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-with-sidecar
  template:
    metadata:
      labels:
        app: nginx-with-sidecar
    spec:
      containers:
        - name: nginx-container
          image: nginx:latest
          ports:
            - containerPort: 80
        - name: sidecar-container
          image: busybox:latest
          command: ["/bin/sh", "-c", "while true; do echo 'Sidecar Container Running'; sleep 10; done"]

How many replicas are currently running in the underlying ReplicaSet created by the Deployment?

Question 4

Choose the correct sentence:

Question 5

Given a Deployment called worker with 4 replicas. Assume the Deployment state is as described below:

$ kubectl get pods
NAME                                  READY   STATUS    RESTARTS      AGE     IP            NODE  
worker-846c94dc48-v6gd5               1/1     Running      0          2d12h   10.244.0.31   node1
worker-846c94dc48-k42tv               1/1     Running      0          1m      10.244.0.19   node2
worker-846c94dc48-tnl2t               1/1     Pending      0          1m      10.244.0.24   node3
worker-846c94dc48-cjkvn               1/1     Running      0          1m      10.244.0.25   node1

If the Deployment would scaled down to 2 replicas. Which Pods would be scaled down?

Hint: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/#scaling-a-replicaset

Question 6

Consider the following Service:

apiVersion: v1
kind: Service
metadata:
  namespace: stage
  name: my-service
spec:
  selector:
    app: myapp
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080

Given the below Pod:

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - name: nginx
    image: nginx:latest

How does the nginx Pod access the my-service service?

Given the following Secret and Pod:

apiVersion: v1
kind: Secret
metadata:
  name: my-secret
type: Opaque
data:
  password: cGFzc3dvcmQxMjM=
  username: dXNlcgo=
---
apiVersion: v1
kind: Pod
metadata:
  name: mypod
spec:
  containers:
  - name: mycontainer
    image: busybox:latest
    command: ["sleep", "3600"]
    volumeMounts:
    - name: secret-volume
      mountPath: "/etc/my-secret"
  volumes:
  - name: secret-volume
    secret:
      secretName: my-secret

Getting a Shell access to mypod, answer the below 3 questions:

Question 7

What would the following command print?

cat /etc/my-secret/password

Question 8

What is the file type of /etc/my-secret/password?

Question 9

How many files are in /etc/my-secret?

Question 10

Given the below Service:

apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  ports:
    - protocol: TCP
      port: 8080
      targetPort: 80
      nodePort: 30302
  selector:
    app: myapp

Let's say this Kubernetes cluster is provisioned in AWS with 50 EC2 instances.

Below is an example YAML manifest for a Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  replicas: 5
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 2
      maxUnavailable: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: nginx:1.25.2

The current version of the application is nginx:1.25.2. You want to perform a rolling update to deploy a new version of the application, nginx:1.25.3.

Question 11

What is the maximum number of Pod might be observed during version update?

Question 12

What is the minimum number of Pod might be observed during version update?

Question 13

Below is an example YAML manifest for a Deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-deployment
spec:
  replicas: 5
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp-container
        image: nginx:1.25.2

The current version of the application is nginx:1.25.2. You want to perform an update to deploy a new version of the application, nginx:1.25.3.

What is the minimum number of Pod might be observed during version update?

license