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:
-
nginxandsidecar-containercontainers will run on different nodes. -
nginxandsidecar-containercontainers will not run on different nodes. -
nginxandsidecar-containercontainers may run on different nodes, depending on the scheduler. - The YAML is not a valid Pod manifest
Question 2
Performing curl http://nginx-service:80 from another pod in the cluster located in the default namespace:
- The
nginxcontainer will receive the HTTP request. - The
sidecar-containercontainer will receive the HTTP request. - The HTTP request fails due to Connection Error.
- None of the above
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?
- 2
- 3
- 0
- 4
Question 4
Choose the correct sentence:
- Requests to
nginx-serviceService can be routed tonginx-deployments Pods. - Requests to
nginx-serviceService cannot be routed tonginx-deployments Pods. - Requests to
nginx-serviceService can be routed tonginx-deployments Pods only if the two Pod's spec is identical. - This behavior is not defined well in Kubernetes.
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?
-
v6gd5andk42tv -
v6gd5andtnl2t -
v6gd5andcjkvn -
k42tvandtnl2t -
k42tvandcjkvn -
tnl2tandcjkvn
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?
-
http://my-service.stage:80 -
http://my-service:80 -
http://my-service:8080 -
http://my-service.stage.svc.cluster.local:80
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
- k8s_is_great!
- No such file or directory error
- password123
- None of the above
Question 8
What is the file type of /etc/my-secret/password?
- Regular file (
-). - Directory (
d). - Link (
l). - None of the above
Question 9
How many files are in /etc/my-secret?
- 1
- 2
- 3
- Unknown
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.
- The service is accessible from any IP of the cluster's EC2s, on port 30302
- The service is accessible from any IP of the cluster's EC2s IP, on port 8080
- The service is accessible from only one IP of the cluster's EC2s, on port 30302
- The service is accessible from only one IP of the cluster's EC2s, on port 8080
- None of the above
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?
- 5
- 2
- 8
- 7
Question 12
What is the minimum number of Pod might be observed during version update?
- 5
- 4
- 3
- 0
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?
- 5
- 4
- 3
- 0