Docker Kubernetes Quiz
Docker Kubernetes Quiz
md at main · mamun001/kubernetes_interview_questions · …
kubernetes_interview_questions / kubernetes_interview_questions.md
By Mamun Rashid ::
https://www.linkedin.com/in/mamunrashid/
1. So, what have you done with Kubernetes? This question comes up all the time!
Answer:
While this seems easy, a prepared and practiced answer is significantly better than an impromptu
one.
You answer would be uniqe to your experience, but, here are some possibilities.
a. created clusters
e. added weave
g. deployed spinnaker
h. configured HPA
k. stateful sets
........
2. You have 2 different contexts (A and B). Context A has a secret named foo. Context
B does not. What would be a quick way to create the same exact secret in Context B?
Answer:
1. Switch to Context A
2. kubetcl get secret foo -o yaml > foo.yaml
3. Switch to Context B
4. kubectl apply -f foo.yaml
......
3. There are more than one way to implement Ingress? What did you use to
implement Ingress?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 2/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
.....
.....
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 3/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.....
.....
a. HA Proxy
b. Istio Ingress
c. Traefik kubernetes Ingress Provider
d. Skipper
e. Voyager
f. Tyk Operator
g. Gloo (open source)
h. AKS Application Gateway Ingress Controller (Azure)
i. Ambassador (envoy-based)
j. Enroute (another envoy-based Ingress Controller)
(and more)
.,...
Answer:
a. via GCP GUI OR
b. via GCP cloud shell window OR
c. gcloud CLI
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 4/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
d. Terraform
e. Google Deployment Manager
......
Answer: You can use --previous option with logs command to see the logs
of a crashed container.
(kubectl logs --previous)
......
11. What happens to containers if they use too much cpu or memory?
......
Answer:
This artcile answers it very well:
https://www.replex.io/blog/kubernetes-in-production-best-practices-
for-cluster-autoscaler-hpa-and-vpa
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 5/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: Answer will depend on your use case. One possible answer is to
have Service accounts that do certain things within the cluster.
By the way, RBAC in Kubernetes is just AWS IAM Policies and
Bindings. In RBAC, you have subjects (who gets the permission), verbs
(what can the subject actually do), and rolebinding (subject linking to
roles) and roles.
......
14. If you have 200 micro-services in your clusters, how do you manage security of
each one? How do you avoid toil?
Answer: RBAC is the answer. You define roles. And you place subjects in
those roles. Each role then will have access to X Y Z etc. This is
really no different than AWS or AD.
......
15. Tell me about the hardest production Kubernetes issue you solved or faced?
Answer:
There are N micro-services. One of them gets a new version. But, the
HPA for those pods are set wrong. Container keep crashing. This causes
cascading failures for many other micro-services.
Solution: Fix the HPA settings and add circuit-breakers in the
consuming micro-services.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 6/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
16. You want to know how to make yaml files for making PODs and you have no
access to internet. What do you do?
It will show you all fields in a mapped kind of fromat so you exacly
what field go where
......
Answer: SSL cert can be a secret. Then that secret can be mounted on a
pod and that pod can whatever it wants with it (e.g. host a SSL web
site)
......
Answer: kubectx
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 7/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: k9s
......
20. "kubectl explain" command is great, but you must know the exact name of the
resource (e.g. pod/services/persistentvolume) to get the details, unless you do
recursive. How do you get the names of these resources from command line?
......
21. Name some of the other verbs that kubectl has besides "run" "create" or "apply" ?
Some of more frequently used ones are: logs, get, port-forward and
label.
......
22. What might you get when you run kubectl api-resources?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 8/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
23. How else can you get help with kubectl? (besides kubectl explain command)
......
24. You ran "kubectl --help" , but you want a little more help. What to do?
Answer:
kubectl get --help
kubectl top --help
kubectl describe --help
......
25. Outline the steps to deploy additional scheduler on a Kubernetes cluster (not
GKE)
Answer:
Package the new scheduler in a docker image
Put that image in a registry
Create a deploymentment file with type: deployment and component:
scheduler (in namespace kube-system)
Deploy the the scheduler with apply -f scheduler.yaml command
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 9/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
26. List out 2 use cases for Daemonsets and explain why it is more appropriate to use
daemonset than deployment for those use case:
Answer:
1. Pod that collects logs. Better to use daemonsets for this because
you can logs to be fed from all pods (e.g. to kibana). Otherwise you
have to make this part of EVERY deployment which would be annoying and
repetitive.
2. Pod that runs monitoring (e.g. dynatrace or datadog). Reason is
the same as above.
......
......
Ans: Private
......
29. Which one will allow to access your services from internet: cluster ip or nodeport?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 10/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
30. For a service, when we use nodeport, EVERY node does what?
......
31. What does it mean when we say that a node proxy's a service?
Answer: The node forwards the traffic to a pod that is part of the
service.
......
......
33. How can a container have access to secret via ENV variable?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 11/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: You can define a ENV in yaml file just like everyhing else and
container can just do echo $WHATEVER
......
......
......
......
37. Whenever you run a kubectl command, it runs in the the default namespace. How
do you make in run in a different namespace?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 12/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
39. When using kubectl command, how do you to get output in json format?
......
Answer:
port : on the cluster
targetport: on the container (just like ALB)
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 13/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
......
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 14/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
46. If you want your kubernetes command to have a scope of ALL namespaces, how
do you do that?
......
Answer: No
......
48. By default, can a pod in one namespace talk to another pod in another
namespace?
Answer: Yes.
......
49. How to generate a yaml file from an imperative command you know works ?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 15/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
50. Write a kubectl command to Create a static pod, have it run a command (so it does not exit).
dryrun so that you get yaml file saved :
......
51. By default, where does yaml files for static POD files go:
......
......
53. Kubectl command to take all the details for a.yaml file and create the resource it
tells API to crate:
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 16/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
55. There is pod named foo. it is in crashloopbackoff state. How to find the cause
using a kubectl command?
......
56. Scenario Question: You have a container that keeps crashing because its
"command" section has a misspelling. How do you fix this?
Answer:
1. generate the yaml file,
2. fix it,
3. kill the pod,
4. re-run with the correct yaml file (kubectl apply -f)
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 17/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
.......
......
......
60. Kubectl command to make a new yaml file for a service by exposing a already
running deployment that runs a pod. Name of the deployment: foo.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 18/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
61. jsonpath example of getting "everything" (about nodes) . This is not really an
interview question. But, its goog to know this in case JSON PATH topic comes up.
......
62. jsonpath example of getting just the level "status" for all nodes
......
63. jsonpath comamnd to get only status.nodeInfo of each node . This is not really an
interview question. But, its goog to know this in case JSON PATH topic comes up.
.......
64: Your computer has no access to internet. Which kubectl command can you use to
find out syntax of making a pv.yaml :
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 19/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
......
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 20/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
69. Some example of commands the master server can send to etcd (once
authenticated with certs and key):
Answer:
member list
snapshot save /tmp/etcd-backup.db
snapshot status /tmp/etcd-backup.db -w table
.......
70. Steps to create a pod called foo with image redis with CPU Request set to 2 CPU
and Request as 400MiB
Answer:
a. first create a yaml file: (dry-run command)
kubectl run --generator=run-pod/v1 foo --image=redis --dry-run -
o yaml > foo.yaml
b. edit the yaml file:
in the resources section of "spec" section:
cpu: 2
memory: 400MiB
c. kubectl apply -f ./foo.yaml
......
71. True or False: POD DEFINITION (yaml) ONLY points to PVC (claim), it does not
refer to the PV anywhere.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 21/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: True
.......
......
......
74. kubectl command to change the image version of a deployment on the fly:
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 22/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: For one thing, the API server won't talk to you , if you don't
have a signed client certificate. So, any client who wants to do
ANYTHING with the API server (e.g. even kubectl) better have a signed
certificate!
......
77. Why are .csr files have CSR extension? What is CSR all about?
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 23/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
end.
......
79. What's an easy way lookup kubernetes documenation on the fly simply using
kubectl command?
......
80. Kubernetes Security: How are some of the ways you can protect your container
images?
Answer:
a. Update them (to get latest security patches at the OS level)
b. Scan them regularly
c. Sign them digitally
......
81. Can you think of some general areas of Kubernetes where you would want to
think about security:
Answer:
a. Your container images
b. Your container registry
c. Your kubernetes run time infrastructure (e.g. etcd)
d. Hosts (where Kubernetes nodes are running)
e. Kubernetes Secrets
f. Kubernetes Certificates
g. RBAC entities
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 24/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
82. Processes within a container: How to they (security-wise) talk to API server
running on the master node?
......
......
Answer:
a. create a .csr file using openssl command (and a private key, but
does not matter to Kubernetes)
b. encode it
c. create a yaml file (Kind: CertificateSigningRequest) using the
encoded CSR
d. kubectl apply -f CertificateSigningRequest.yaml
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 25/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
85. If you have created CertificateSigningRequest, but you have not approved it yet,
what status do you get if you run "kubectl get csr" command?
.......
......
......
......
Answer: etcd data store all your Kubernetes data including Kubernetes
secrets
......
Answer: Master Node (because clients will authenticate with the API
server using client certificates)
.......
Answer: (On a managed Kubernetes like GKE and EKS, you don't need to do
this):
a. create a private key
b. create CSR
c. self-sign the CSR
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 27/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
Answer: Yes, but horrible idea, basically all traffic do and from etcd will not be
encrypted
.......
......
94. When you tell Kubernetes to run a pod, who decides which node gets that pod?
Answer: Scheduler
......
95. What if you don't like the default scheduler that comes with Kubernetes?
.......
96. If a node has taint, what you have to do to your pod, for it to be able to run on
that node?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 28/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
97. If you want a pod to run on specific node, which feature do you have to use?
......
Answer: There are times, when a container fails liveness probe and yet we do not want
to container to be killed. For example, if a container takes time to ready (loads large
data set). In this case, liveness probe would fail and (without a readiness probe),
Kubernetes would kill the container. A readiness probe tell Kubernetes to wait for the
container finish doing all its prep work.
......
99. What does it mean for Kubernetes to drop support for Docker?
.......
Answer: Docker has the ability to send logs to various places (e.g. awslogs or fluent and
many more). Each one of these is a logging driver.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 29/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: cAdvisor (which is part of kubelet on worker nodes) Those are then sent to
Metric Server (running on master nodes). Metrics Server exposes them via kube-api
(also running on the master node)
.......
102. When you run "kubetcl top", which component are you talking to?
......
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 30/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
we can limit what can the container do on the host. This is "Security
Context"
.......
Answer: When the sidecar proxy's the connections from the main
container to the outside world.
.......
......
107. Can you describe a use-case where the ambassador pattern can be of use?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 31/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
......
.......
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 32/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
112. Why do we need HPA when we already have maxSurge and maxUnavailable?
......
......
114. You are configuring a service and you have made a mistake with labels and/or
selectors. How does this manifest itself often?
Answer: You will see the service and there will be no endpoint.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 33/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
115. You are logged in to conext via kubectl on your Mac. How can you see if you
have permission to update pods?
......
116. Let's say you manage 100 GKE Clusters. You want to run a kubectl command.
How do you make sure your command will be executed on the right cluster?
Answer: You will have 100 contexts (one for each cluster you have
logged in to). You must switch to to the right context before running
the command. There is a open-source CLI tool called kubectx that helps
you with this.
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 34/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
.......
119. If you are on a node, how do you look for running container?
......
120. Let's say you know how to run a pod via command line. You can do this very
easily because you have done it many times. Given that, how can you quickly
generate a YAML file for doing the same thing?
......
121. You ran: kubectl get po foo -o yaml > foo.yaml . The problem is that this YAML
file has lots on info about the running pod in addition to the "core" yaml content
need. How do you get a clean YAML file out of this?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 35/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: You can delete most of those lines (e.g. the status fields
and many others)
.......
.......
123. If you want a pod to be associated with a service account name, how do you do
it in yaml file?
......
124. What does a YAML file for a pod that has 2 containers look like?
containers
- image nginx
name ONE
env
- name ONE
value foo
- image busybox
name TWO
command sleep 1000
.....
125. How to see what network policies you have in default namespace?
........
Answer: Yes.
.......
127. What is the deal with "api-versions". What is the context for this?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 37/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
128. How to see the correct network api version to use in neteork policy yaml file?
......
.......
130. You have a deployment named foo. How can you scale it up via cli: (imperative
way) ?
......
131. You suspect something is wrong with the control plane pods. What should your
run?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 38/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
132. You see that a pod is in "imagepullbackoff" state (ie not running),
Answer: You should see which image that pod is configured to use.
"imagepullbackoff" means that, for some reason, Kubernetes
could not pull the docker image.
This could be because image is not there OR there are
permission issues prohibiting the download of that image.
.......
You found out that the controller-manager pod on the master had issues.
You fixed that so, controller-manager pod
is now running. What do you have to do next so that scaling finally
happens?
......
134. How do you list out all pods running in the namespace foo?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 39/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
........
Answer:
Imperative: Basically via commands
Declarative: basically via yaml files
.......
136. Assume that you are connected to the cluster and context, how do you quickly
create an NGINX pod using an imperative approach?
........
Answer:
It's like an isolation process. e.g. If you namespaces dev and prod,
you can have pods named foo in both namespaces and there is no conflict.
(In the same cluster)
In Kubernetes, you can have the dev team their own namespace and prod
can have its own namespace.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 40/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
........
Outline the steps that you use to troubleshoot and the kubectl
command you use to diagnose the problem.
Answer:
Step 1: run the describe pod command and read through events
Step 2: run the kubectl logs -p podname and see what is going on with
pods (use --previous option, since pod has already crashed)
......
139. What are the functions of Kubernetes control plane? Where do those functions
reside?
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 41/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: scheduler
.......
142. When a new GKE cluster is created, what are the main namespaces created?
........
Answer: So that you can select something based on those labels. They
are like tags in AWS. Let's say I want to use node-affinity. We can use
labels to select (selector argument in yaml or command) the ones
desired.
.......
Answer:
kubetcl label pods pod1 owner=mamun
kubectl label pods pod2 owner=foo
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 42/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer:
kubetcl get pods --selector owner=mamun
kubectl get get pods -l owner=foo
........
146. What are annotations use for in Kubernetes and how are they different from
labels and selectors
.......
147. Is deployment and service the same - Explain the difference or the sameness
between the 2 concepts
Answer: No.
Deployment is like terraform apply (of pods) that you can run a
bunch of time with changing configurations (Kubernetes keeps track and
so you can roll back).
Service is basically an entrypoint for users to hit the pods with
the right application. Users only know about service and not the pods
behind it.
........
.........
149. What are the 3 main characteristics you should focus on to troubleshoot what
can go wrong between pods and services?
.........
150. What are the mechanisms to expose an application running in Kubernetes to the
outside world?
Answer: pods ---> service ---> Public IP ---> DNS ---> External Users
.........
..........
152. List some useful commands to troubleshoot Pods issues: (These will come in
handy on various interview questions)
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 44/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer:
Kubectl describe pod
Kubectl port-forward podname 3000:80 (example)
Kubectl get pods -o wide
Kubectl logs podname
Kubectl get pod podname
Kubectl exec -ti podname bash
.......
........
154. Pods can have startup and runtime errors - Explain what some of these errors
mean and 2-3 common culprits (These wil come in handy for various interview
questions)
Imagine the interviewer asking you about each specific one and you
having explain that one.
Answer:
ImagePullBackOff
: the docker image could not be gotten
Registry name is bad or not reachable
Docker image name is bad or image no longer exists
CrashLoopBackOff
: container comes up and crashes/exists
Container has nothing to do, so it shuts down
Initial value of readiness probe is too small compared to what is
needed by container¿s tasks
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 45/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
RunContainerError
: container could not be kicked off
Pod network solution is not working
Authorization Issues
........
155. Can you schedule regular pods on the master node (general Kubernetes, not
GKE).
Answer: Yes. BUT, the noschedule taint (which is there by default) has
to be removed first.
.........
156. You have a node A with taint=blue. You have a Pod X with toleration for
taint=blue. Would pod X always be placed on Node A. Explain your answer in detail
(Why yes or no)
Answer:
Taint is a barrier. The fact that pod X has toleration for blue means
that it CAN be scheduled on node A.
However, if there are other nodes with no taint or taint of blue, X
can land there too.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 46/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
...........
Answer:
nodeSelector is simplistic based on labels whereas node affinity
allows much more complex matching, soft-matching and un-matching.
nodeSelector use cases: pods belonging to a team go on the same
node(s). Pods belonging to an environment (e.g. dev) go on the same
node(s).
node affinity use cases: geographic location. Pods go on nodes where
some pods live (OR do not live)
........
158. How do you find out what image of the running container (in a pod)?
.......
159. Command used to find out what node the pods are running on:
........
160. What does the READY column in the output column of the "kubectl get pods"
command indicate?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 47/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: How many containers are supposed to run in the pod and how many
are actually running.
........
161. What happens if all master nodes are unavailable on (GKE) ? would that impact
workloads running on the worker nodes?
......
162. Why are worker nodes spread out on multiple availability zones in GKE?
Answer:
If Google Cloud has an outage in one AZ, application will still be
available.
.......
163. What is the difference between setting up a GKE cluster as regional versus zonal.
This will require you read up on GKE implementation of K8s
Answer:
Multi-zonal cluster: master is present in only one zone + nodes are
in N zones
Regional cluster: masters are present in N zones + nodes are in N
zone
So, In Regional cluster, master is HA at the regional level, whereas
in Multi-zonal cluster, it is not.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 48/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: Sometimes there is a need to have some pods on EVERY node (e.g.
DNS server or a log collector). One can deploy these ¿sets¿ as a daemon
set on each node.
Deployment is a declarative definition of replicasets/pods. You
define what needs to go on (how many, what type etc) and the deployment
controller ensures that the "desired state" is always there.
........
.......
166. In a replica set definition how do we tell the replica set that a set of pods is part
of the replica set?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 49/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
.......
Answer: kube-system
........
Answer: no, because kubectl does not recognize "pods" as valid 2nd level
command
.......
Answer: This is the way to make sure the containers do not consume more resources
than desired. This way, 2 things can happen: Runaway containers do no affect others
We get alerted when resource increase over time does not reach a certain limit.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 50/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
........
.......
172. Explain what is meant by resource request and resource limits setting.
Answer:
Request: amount of resources a container asks for and scheduler only
schedules IF that amount IS available on a node. ("entrypoint")
Limit: container is killed or throttled IF a container ever tries to
get this much resource.("bad boy level")
........
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 51/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
replicas: 3
........
Answer: True
.......
176. Why would you have many Deployments work together in the virtual network of
the cluster?
Answer: There are many use cases for this. One example would be to
deploy many micro-services. Each micro-service would be a deployment.
......
177. To expose a pod so that users can get to it, you need to create ________ ?
Answer: Service
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 52/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
179. Deployments are meant to contain stateless services. If you need to store a state
you need to create ________ instead (e.g. for a database service).
Answer: StatefulSet
.......
180. How do you see which pods or nodes are using the most resources?
.......
Answer: No
.......
Answer: Yes
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 53/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
183. Let's say that you want to add a "sleep" command to your container. Where does
that go in the YAML file?
........
........
185. Can you edit any live object using "kubectl edit" command?
Answer: No
........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 54/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
........
......
.......
189. Pods come and go. So, how in the world, does Kubernetes provide any real
service?
Answer: Service's IP NEVER changes. You can point DNS to it. Behind the
"service" are the ephemeral pods.
........
190. (Real Interview Question asked 2022): You run "k get po" and you ass a pod that
is in "completed" state. What does that mean?
Answer: This means that pod came up, did its job and finished. It did
not crash. It is not running. You can still get to its logs
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 55/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
191. (Real Interview Question asked 2022): What kind of troubleshooting have you
done in Kubernetes?
........
192. (Real Interview Question asked 2022): How is Anthos Service Mesh compared to
Istio?
.........
Answer: kube-proxy
.........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 56/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: service
..........
........
...........
..........
Answer: On each node. You can think of this as any other network proxy
(e.g. HAProxy or Nginx or Squid) running on each node managing traffic
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 57/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.........
199. Why are there 3 versions of NGINX ingress controller for Kubernetes?
.......
200. Why would you go with Nginx Ingress Controller (and not the Kubernetes
Community One)
Answer: With Nginx one, you get HTTP Load Balancing (You don't get
with community one)
Source: https://www.youtube.com/watch?v=OM_N0jjghqI
............
201. When impleneting Prometheus, why is it best use the Adapter pattern?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 58/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
............
...........
203. (Actual interview question 2022): What is the difference between Docker
Compose and Kubernetes ?
........
..........
205. When we run "kubectl run pods" , that gets to the API server on the master
node. What does the API server do with that request?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 59/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
206. How do you combine kubectl and jsonpath to get the info you need?
..........
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 60/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
..........
211. How can you verify that your binary executables (Kubernetes) have not been
corrupted?
Answer: Create SHA256 Hash of the binary and compare the message
digest with the one given on the official web site.
..........
212. (Not really an interview question, more a real life question) . You are trying to
run a pod with "kubectl run" command, but running into issues with exact formats
and options, what do you do (besides googling)?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 61/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
213. (Not really an interview question, more a real life question) . When you are
creating a pod using "kubectl run" command, How can you supply a command to
run on the container (like sleep 3600)
..........
214. How can you login into a pod (assuming it only has 1 container) ?
..........
215. When you create a pod you can give it 3 restart options. What are they?
Answer: 1. Always
2. Never
3. OnFailure
..........
216. When you create a pod you can give it 3 restart options. What are the use cases
for each?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 62/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
217. If there is a pod already running and you want to restart using a DIFFERENT
image, how do you do that using command line?
..........
217. When your run k get pods , how do you sort by name?
..........
218. When your run k get pods , how do you sort by creationtime?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 63/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
219. In the YAML file for a pod that has more than 1 containers, how do they
container specs show up?
..........
Answer: apiVersion:
..........
221. In the YAML file , how do you define what you are building (pod. replicaset,
secret, etc.) ?
..........
222. How to get logs from a container (not a pod) via command line?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 64/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
Answer: Imagine if you had a set of pods that did MYSQL for you. You
would have a leader pod and several read-only pods etc. If a reader pod
crashed, a human will have to
go in and restart it. If the leader pod carshed, a human
would find a way to get it up and running or promote a read-only pod to
a leader pod. In Kubernetes stateful sets, an operator
pod would do all of that automatically.
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 65/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
Answer: ~/.kube/config
..........
Answer: Yes
..........
228. What is the esiest quickest way to create a service for a running pod?
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 66/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
230. If you are using minikube or kubeadm etc., what is a big limitation in terms or
Load Balancing?
..........
231. When does Kubernetes pull new version of image upon Pod creation ?
Answer: if either
1. Using images tagged :latest
2. imagePullPolicy: Always is specified
Source: https://stackoverflow.com/questions/33112789/how-do-i-force-
kubernetes-to-re-pull-an-image
..........
232. What is super quick way to create a service pointing to a running pod?
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 67/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: Conatiners
..........
233. Why do we need Ingress when we alrady have "service" that can send traffic to
many pods of the same type?
Answer: One big reason is this: Without Ingress, you would have to
have a Load Balancer for every single web application you are hosting in
your cluster.
That can get very expensive and hard to manage.
With Ingress , you can have ONE load balancer that can take
in traffic for many web applications and forward them to the right pods.
..........
234. In the kube confi file, what does the URL point to? (for each context)
..........
Answer: 1. (If you want 1, then you cna leave out that option in
an imperative command)
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 68/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
236. How can you update the image of a running deployment using an imperative
command ?
..........
..........
238. In the definition of a service what is "port" and what is "Target Port"?
..........
239. Your pod uses a Config Map. How Can you automatically restart pod if the
Config Map changes?
Answer: For this, you have to use deployment. In the config of the
deployment, use the CM.
When CM changes, and the new CM values breaks things,
Deployment is smart enough NOT to scale down.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 69/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
..........
Answer: 3 parts
1. Control Pane (Not much you can do)
2. Worker Nodes (making sure you are autoscaling)
3. Optimal usage of cpu/memory by pods (use Metrics Server
or open source tool kubecost)
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 70/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
newer version of Kubernetes and THEN running the pods on the new nodes
(Opposite of draining)
..........
..........
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 71/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
..........
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 72/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: You can create a deployment using nginx image. That would
be one ay of doing it.
..........
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 73/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
..........
255. When you create Nginx Ingress Controller via YAML file, what would be the
"Kind" ? (e.g. pod, secret, service ....)
..........
256. How can you create an YAML file on the fly without creating a resource ?
..........
257. How do you deploy 3rd-party applications (built on Kubernetes) to your cluster?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 74/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
..........
..........
Infrastructure as Code?
..........
..........
..........
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 76/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
..........
Answer: Kyverno
OPA Gatekeeper
..........
..........
.......
267. You have web application hostend on containers on Kubernetes. This web app is
accessed via a domain e.g. foobar.com. You need to add a SSL certificate to
somewhere in your Kubernetes infrastructure for this domain.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 77/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer: This page does a fantastic job of explaning step by step with
lots of details.
https://devopscube.com/configure-ingress-tls-kubernetes/
Summary:
1. Get a certificate (either self-signed or otherwise)
2. deploy the application in Kubernetes cluster (this should
already be done)
3. create a TLS secret in Kubernetes
4. add TLS block to ingress object
5. Validate using simple curl command (e.g. curl
https://foobar.com -kv )
.......
268. What if you want to to actively prohibit pods of certain type to be created (e.g.
previleged containers)? How do you accomplish that?
Answer:
.......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 78/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
.......
......
......
......
273. Easiest to get a bearer token for Kubernetes API server auth.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 79/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
......
276. How does API Server authenticate a request for object creation in etcd?
......
277. How can you a list of types of resources (like pods, secrets, nodes, services and
lot more)
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 80/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
278. What is the MAIN difference between stateless and stateful sets (in terms of what is being
used in Kubernetes) ?
......
279. What are the main 3 things that a worker node will run?
Answer:
Kubelet
Proxy
Caontainer Run Time Engine
.....
Answer: kubelet
......
Answer: YAML
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 81/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
282. Kube Proxy runs on each worker node. For all practical
purposes, what is it, really?
......
.......
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 82/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
286. How can you have a VM (kubernetes node ) that is small in size
and does not any extra packages (e.g. 100s of MBs instead of Gig+)?
Answer: You can convert a Docker container image (e.g. Ubuntu) and add 2
packages (one of them is a File System package)
......
Answer: ?????
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 83/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
......
290. If you have a YAML file that has codes for 10 different resources
(pods, deployments etc). How can delete all resources made from
this YAML file?
......
291. In order to follow DRY principle, your code should work across
all enviroments (dev, staging , prod). How can you do this when you
know things will be different across various environments?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 84/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
292. Why do we need PV and PVC? Why not just PV or just PVC?
Answer: de-coupling. This way, you can define your PVs not knowing when
they will be used. Similarly, you can create PVC knowking PV already
exists.
......
Answer: Again, de-coupling. You can define many kinds of storage (fast,
slow, EBS, GCS, NFS, on and on). You can just use them as you see fit.
......
......
295. Explain the flow from a CSR all the way to a user having
permission to describe a pod?
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 85/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
Answer:
1. CSR is created
2. That is submitted to Kubernetes cluster
3. Someone approves the csr within Kubernetes.
4. That creates a valid certificate which has an embedded user
5. On the other side of things, a role is create with certain
permissions (e.g. describe a pod)
6. That user/certificate is associated with that role via roleBinding.
This completes the path.
......
......
297. You are applying a YAML file. But, you get an error , something
like: "expecting X got Y" (e.g. expecting map, got string). How do
you fix this?
Answer: Note the line number the error message tells you. See, which
attribute is mentioned in that line. Then, use kubectl explain command
to see what type of a thing is expected. May there is supposed to be an
array of strings. But, because of a typo, to Kubernetes, it looks like a
string or map/object. This will give a great clue as to what the typo
is.
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 86/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: Node Pools are nodes that share the same configurations (e.g.
cpu/memory etc.). What if some of your pods needs more resources and you
want those pods to go into only a certian node pool. And, you do not
want other normal pods to go into those nodes. In this case, having 2
node pools would be very useful. Node pools can also be used to segment
out usage by different teams/environments/departments.
......
Answer: values.yaml in Helm charts save all the env specific values
(lets say , server type, application name etc.). This way, we cna follow
DRY principles of coding when we code for multiple environments. These
"values" in turn can "feed" the configmaps in Kubernetes environments.
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 87/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
Answer: Sometimes there is a need for pod to be created for the sole
reason of doing a task ONLY once. "job" is how you define that.
......
......
Answer: Interviwer may not ask this directly, but he or she will want to
know how you have the experience that you have. This is because people's
experience with Kubernetes vary widely. Be truthful. If your experience
is that you have done labs on your own or as part of certification exam
prep, state THAT! If you fake the experience, it will show and you will
come across as unauthentic. Be ready for this question.
......
......
304. You just created a cluster. How do you know what is running
there by default?
......
......
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 89/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
......
307. All I am giving you a docker image (that runs a web server).
You don't even have a cluster. Walk me through how you take this
service live. Assume that you don't scaling or HA.
Answer: Create a cluster. Upload the image one GCP container registry.
Creat a YAML file that creates a deployment using that image. Create a
service (Type Load Balancer) using that deployment. Create a DNS
recording pointing to the endpoint of that service.
......
.
More Unformatted questions:
You have created a PV using hostpath. How do you know if all is well. ans: describe and
status should say "available" Can you use 2 PVCs with 1 PV? no! 1:1 3 recycle policies
for PV: retain, recycle, delete If retain , then: pvs goes away, PV will still just sitv there
Can multiple pods use the same PVC? yes Tell me when you will use a label selector You
have 5 departments on 1 cluster. Each has their own namespace. How can you keep
dept1 from using up all the resources? use quota. quota is applied at namespace level.
Once you have MYSQL pods running, how can you make a service out of them? port
3306 targetport 3306 use label selector to select pods for backend You have 20 nodes.
You want to use 10 of then ONLY for production pods. How? taint the nodes Pods in
pending state. why? nodes tainted or not enough resources left or node affinity set
wrong
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 90/91
9/9/23, 2:29 PM kubernetes_interview_questions/kubernetes_interview_questions.md at main · mamun001/kubernetes_interview_questions · …
https://github.com/mamun001/kubernetes_interview_questions/blob/main/kubernetes_interview_questions.md 91/91