Kubernetes Questions and Answers
Kubernetes Questions and Answers
All rights reserved. No part of this book can be reproduced or stored in any retrieval system or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, uploading on server and scanning without the prior
written permission of the Dot Net Tricks Innovation Pvt. Ltd.
The author of this book has tried their best to ensure the accuracy of the information described in this book. However,
the author cannot guarantee the accuracy of the information contained in this book. The author or Dot Net Tricks
Innovation Pvt. Ltd. will not be liable for any damages, incidental or consequential caused directly or indirectly by this
book.
Further, readers should be aware that the websites or reference links listed in this book may have changed or disappeared
between when this book was written and when it is read.
All other trademarks referred to in this book are the property of their respective owners.
Release History
● Initial Release 1.0 - 3rd Nov 2020
About Dot Net Tricks
Dot Net Tricks was founded by Shailendra Chauhan (Microsoft MVP), in Jan 2010. Dot Net Tricks came into existence in
the form of a blog post over various technologies including .NET, C#, SQL Server, ASP.NET, ASP.NET MVC, JavaScript,
Angular, Node.js and Visual Studio, etc.
The company which is currently registered by a name of Dot Net Tricks Innovation Pvt. Ltd. came into the shape in 2015.
Dot Net Tricks website has an average footfall on the tune of 300k+ per month. The site has become a cornerstone when
it comes to getting skilled-up on .NET technologies and we want to gain the same level of trust in other technologies. This
is what we are striving for.
We have a very large number of trainees who have received training from our platforms and immediately got placement
in some of the reputed firms testifying our claims of providing quality training. The website offers you a variety of free
study material in the form of articles.
● .NET Development
● Front-end Development
● Cloud
● DevOps
● Programming Languages
● Database - SQL and NoSQL
● Mobile Development
● ML/AI and many more...
Start your journey today to learn coding. Because learning to code is the first step and forward to advance your career.
Corporate Training
Dot Net Tricks having a pool of mentors who help the corporate to enhance their employment skills as per changing the
technology landscape. Dot Net Tricks offers customized training programs for new hires and experienced employees
through online and classroom mode. As a trusted and resourceful training partner, Dot Net Tricks helps the corporate to
achieve success with its industry-leading instructional design and customer training initiatives.
Apart from these, we also provide on-demand boot camps and personalized project consultation.
DotNetTricks unlimited membership unlock unlimited access to all courses, learning paths, study mode quizzes, hands-
on labs, source code and study material. Upgrade your skills with our structured learning paths tailored to today's
developers and technology needs. DotNetTricks Unlimited Live training membership includes the benefits of
DotNetTricks Plus membership and Unlimited live online training.
The detail about Unlimited Live Training can be found here: https://www.dotnettricks.com/instructor-led-courses
● .NET Development
● Front-end Development
● Cloud
● DevOps
● Programming Languages
● Database - SQL and NoSQL
● Mobile Development
● ML/AI and many more...
Join us today, learn to code, prepare yourself for interviews, and get hired!
Dedication
I would like to say many thanks to my father who gave me the opportunity to make my carries as I wanted when I was in
10th standard. I gave the speech about “Beti bachao” and I got national awards for the first time. I have lots of expertise
on DevOps and one day Ankur Mistry saw my technical knowledge and he inspired me to write a book and share the
knowledge to others. The Next day I started the book and also, I believe reading and writing is the most important part
of gaining knowledge in life.
I would like to say thanks to my father and mother for teaching me nothing is impossible and be the best version of
yourself.
Also, thanks to my heroes(brothers) Vipul and Pankaj, who always remind me who I am and what I can do, always support
me no matter what situation.
“Keep your mind open to change all the time. Welcome it. Always go with the
choice that scares you the most, because that’s the one that is going to help you
grow”
● Container Orchestration
● Fundamentals of Kubernetes
● Minikube
● Kubernetes Architecture
● Kubernetes Object and Workload
● Kubernetes Master Components
● Kubernetes Node Components
● Kubernetes Installation
● Kubernetes Commands
● Kubernetes Service
● Kubernetes Pods
● Kubernetes Deployments
● Kubernetes Networking
Our best wishes are always with you for your learning and growth!
About the Author
Dharti Sutariya - DevOps Engineer and Author
She achieved great technical knowledge in a short period of time in DevOps
Technology, she has vast experience in DevOps area. She graduated from Gujarat
Technology University (GTU)- India. She has an ability to set up a fully DevOps
oriented process.
She has explicit Technical Knowledge and hands-on experience of DevOps processes and practices, Automation,
Auto scaling, Monitoring, and Configuration Management. Gained expertise in SDLC and Agile implementation.
Experienced in maintaining the Continuous flow from Code phase to Deployment and Production Phase.
Experienced DevOps Model, CI/CD with Jenkins and Azure DevOps 2019 server.
How to Contact Us
Although the author of this book has tried to make this book as accurate as it possible but if there is something strikes
you as odd, or you find an error in the book please drop a line via e-mail.
● [email protected]
● [email protected]
We are always happy to hear from our readers. Please provide your valuable feedback and comments!
You can follow us on YouTube, Facebook, Twitter, LinkedIn and Google Plus or subscribe to RSS feed.
Table of Contents
Kubernetes Interview Questions & Answers 2
Release History 2
About Dot Net Tricks 3
Dot Net Tricks Courses 3
Dot Net Tricks Plus 3
Corporate Training 4
Dot Net Tricks Unlimited Live Training 5
Dot Net Tricks eBooks 5
Dedication 6
Introduction 7
About the Author 8
How to Contact Us 9
Container Orchestration 19
Q1. What is a Container? 19
Q2. Why do we need containers? 19
Q3. What is the difference between containers and virtual machines? 19
Q4. Which types of platforms are supported by containers? 20
Q5. What are the benefits of containers? 20
Q6. Are there any disadvantages or Limitation of containers? 20
Q7. What is the difference between deploying applications on hosts and containers? 21
Q8. What is Container Orchestration? 21
Q9. What is container orchestration used for? 21
Q10. Mention the various container resource monitoring tools? 21
Q11. What are various Container orchestration tools? 22
Fundamentals of Kubernetes 23
Q1. What is Kubernetes? 23
Q2. Why use Kubernetes? 23
Q3. What are the benefits of Kubernetes? 23
Q4. What are different types of objects available in Kubernetes? 24
Q5. What are Kubernetes alternatives? 24
Q6. What is the difference between Kubernetes and docker swarm? 24
Q7. Can we use Kubernetes as an alternative to docker? 25
Q8. Can we install Kubernetes on the Windows platform? 25
Q9. Can we autoscale windows containers using Kubernetes? 26
Q10. Which platform is supported by kubernetes-master? 26
Q11. Which windows worker node is supported by Kubernetes? 26
Q12. Is there any limitation of Kubernetes? 26
Q13. Is Kubernetes secure? 27
Q14. How can we protect Kubernetes? 27
Q15. Does Kubernetes do load balancing? 27
Q16. What are the disadvantages of Kubernetes? 27
Q17. Which programming language is Kubernetes written in? 27
Q18. Can Kubernetes work without Docker? 27
Minikube 28
Q1. What is Minikube? 28
Q2. Do you explain the features of minikube? 28
Q3. What is the use of Minikube? 28
Q4. What are the disadvantages of Minikube? 29
Q5. What are the advantages of Minikube? 29
Q6. What is the difference between Kubernetes and minikube? 29
Q7. Can you use Minikube in production? 29
Q8. Does Minikube require Docker? 30
Q9. What command-line interface is used to interact with the Kubernetes cluster? 30
Q10. How do I Install Minikube on Windows? 30
Q11. How do I install Minikube on Mac? 31
Q12. How do I install Minikube on Linux? 32
Q13. How do I install a Helm in Minikube? 32
Q14. How do I get rid of Minikube for windows? 33
Q15. How do I get rid of Minikube for ubuntu? 33
Q16. What is Minikube, Kubectl and kubelet? 33
Q17. Does Minikube support Load Balancer? 33
Q18. How do I start Minikube in Ubuntu? 33
Q19. How do you make a pod on Minikube? 34
Q20. Where is the minikube config file location? 35
Q21. How to start minikube on a specific network? 35
Q22. How to create a deployment in minikube? 35
Q23. Is the minikube support dashboard? 35
Q24. What does Kubectl stand for? 36
Q25. Is Docker Desktop support Kubernetes? 36
Q26. Can we use the dashboard feature in Docker Desktop? 37
Q27. How can we apply Minikube in Docker Desktop? 38
Kubernetes Architecture 39
Q1. Do explain Kubernetes Architecture? 39
Q2. How does Kubernetes work? 40
Q3. How does the CI/CD pipeline work with Kubernetes? 40
Q4. How does Kubernetes Autoscaling work? 40
Q5. Explain Kubernetes Deployment strategies. 41
Q6. What is Etcd? 41
Q7. What is a Master? 41
Q8. What is a Worker node? 41
Q9. What are the different objects in Kubernetes? 41
Q10. Explain the Load balancer in Kubernetes? 42
Q11. What is Ingress in Kubernetes? 42
Q12. What is NodePort? 43
Q13. What is the Cluster IP? 43
Q14. Why do we need Kubernetes High Availability (HA)? 44
Q15. Is Kubernetes a container runtime? 44
Kubernetes Object & Workload 45
Q1. What is Namespace? 45
Q2. What are the different services within Kubernetes? 45
Q3. What are the built-in namespaces available in Kubernetes? 45
Q4. Explain Daemon sets? 46
Q5. Explain Replica set? 46
Q6. What is Heapster? 46
Q7. Explain Replication controllers? 46
Q8. What are the types of controller managers? 46
Q9. What are Kubernetes labels? 46
Q10. Why does the kubelet manage the hosts file? 46
Q11. How can we get a static IP for a Kubernetes load balancer? 46
Kubernetes Master Components 47
Q1. Which component can manage a Kubernetes cluster? 47
Q2. What are the main components of the master node? 47
Q3. What process runs on Kubernetes Master Node? 47
Q4. What is the API in Kubernetes? 48
Q5. How do I connect to Kubernetes API? 48
Q6. How do I run Kube API Server? 48
Q7. Where are the stored Credentials of the API server? 48
Q8. What is Kubernetes scheduler? 48
Q9. How does the Kubernetes scheduler work? 48
Q10. Can we implement a custom scheduler in Kubernetes? 48
Q11. What are the feasible nodes? 48
Q12. How does the kube scheduler do the selection of nodes? 48
Q13. How can we check the kube scheduler log in master node? 48
Q14. What is a kube-controller manager? 49
Q15. What is Etcd? 49
Q16. What is cloud-controller? 49
Q17. What is the job of the kube-scheduler? 49
Q18. What happens if Kubernetes master goes down? 49
Kubernetes Node Components 50
Q1. What is a node in Kubernetes? 50
Q2. Explain Kubernetes node components? 50
Q3. What is kubelet? 51
Q4. What is the kube-proxy in Kubernetes? 51
Q5. What task is Kube Proxy responsible for? 51
Q6. What is Container Runtime Interface (CRI)? 51
Q7. How does DNS work in Kubernetes? 51
Q8. What are the major functions of Kubelet as a node service component in Kubernetes? 51
Q9. What things do we need to take care before joining the node in k8s cluster? 51
Q10. How can we join Kubernetes nodes to existing clusters? 52
Q11. What does the node status Hold? 53
Kubernetes Installation 54
Q1. How do you Verify if Kubernetes is installed? 54
Q2. Is Kubernetes free? 54
Q3. What are the Prerequisites for Kubernetes? 54
Q4. Which ports need to open to create a k8s cluster? 55
Q5. How to check the MAC address and product_uuid are unique for every node? 55
Q6. How can we assure that iptable can see bridge traffic? 55
Q7. Why do we need Check network adapters when we are going to install k8s? 56
Q8. What is used by Kubernetes to run containers inside the pod? 56
Q9. How to install Kubernetes in Linux? 56
Q10. How to install kubectl in windows? 59
Q11. How to install kubelet on MacOS? 59
Q12. How to check if a Kubernetes cluster is running or not? 59
Q13. How to update Kubernetes cluster? 60
Q14. How to Restart the kubelet? 60
Kubernetes Commands 61
Q1. How to List pods with nodes info? 61
Q2. What is the command for List everything in Kubernetes cluster? 61
Q3. How can we Get all the services? 61
Q4. What is the command for Get all deployments? 61
Q5. How can we Show nodes with labels? 61
Q6. Can you tell the commands for Get resources with json output? 61
Q7. How to Validate a yaml file with dry run? 61
Q8. How to Get system config via configmap? 61
Q9. What is the command for Watching pods? 61
Q10. What is the Query health check endpoint? 61
Q11. How can we Open a bash terminal in a pod? 62
Q12. How can we check the environment variable of the pod? 62
Q13. How can we use the “kubectl apply command” on the folder where our yml file is located? 62
Q14. How can we Get services sorted by name? 62
Q15. How can we Get pods sorted by restart count? 62
Q16. How can we get a list of pods and images? 62
Q17. How can we list out all container images? 62
Q18. How can we Get node resource usage? 62
Q19. How can we Get pod resource usage? 62
Q20. How to List resource utilization for all containers? 62
Q21. What is the command for Delete pod? 62
Q22. What is the command for Delete pod by force? 63
Q23. How can we Delete pods by labels? 63
Q24. How can we Delete all resources filtered by labels? 63
Q25. How can we Delete persistent volumes by labels? 63
Q26. What is the command for List all critical pods? 63
Q27. How can we List Out pods with more info? 63
Q28. How can we get pod info? 63
Q29. How can we List all pods with labels? 63
Q30. How can we List all unhealthy pods? 63
Q31. How can we list out only running pods? 63
Q32. How can we Filter pods by label? 63
Q33. How can we Manually add labels to a pod? 63
Q34. What is the command for removing labels of pods? 63
Q35. How can we List secrets in Kubernetes? 64
Q36. How can we Generate secret? 64
Q37. How can we Get secret? 64
Q38. How can we List all Secrets currently in use by a pod? 64
Q39. How can we Get a specific field of a secret? 64
Q40. How can we List storage class? 64
Q41. How can we Check the mounted volumes? 64
Q42. How can we Check persistent volume? 64
Q43. How can we Copy local file to the pod? 64
Q44. How can we Copy pod file to local? 64
Q45. How can we View all events? 64
Q46. How can we List Events sorted by timestamp? 64
Q47. How can we Mark node as unschedulable? 64
Q48. How can we Mark node as schedulable? 65
Q49. How can we Drain node in preparation for maintenance? 65
Kubernetes Services 66
Q1. What is the Kubernetes service? 66
Q2. How does Kubernetes service work? 66
Q3. What is the difference between deployment and service Kubernetes? 66
Q4. How do services connect to the deployment? 67
Q5. What are the different types of services in Kubernetes? 67
Q6. How to Identify a Kubernetes service? 68
Q7. How do I access Kubernetes service? 68
Q8. What is the Kubernetes headless service? 68
Q9. What is the default protocol for a Service? 68
Q10. What is the command for Listing all Kubernetes services? 68
Q11. What is the command for listing service endpoints? 68
Q12. How can we Get service details? 68
Q13. How can we Get service cluster IP? 68
Q14. How can we get service cluster port? 68
Q15. How can we Expose service as load balancer service? 68
Kubernetes Pods 69
Q1. What is a pod and why are pods so important? 69
Q2. Does kubelet create pods? 69
Q3. How to check if a pod is running from the dashboard? 69
Q4. How do I start a pod in Kubernetes? 70
Q5. Do explain pod lifecycle? 70
Q6. When and how pods will be created? 71
Q7. Why do we need pods in Kubernetes? 71
Q8. How do you get pods in a pod? 71
Q9. How do I delete the POD forcefully in Kubernetes? 71
Q10. How do containers within a pod communicate? 71
Q11. How do I access Kubernetes pod from outside? 71
Q12. Can pods in different namespaces communicate? 71
Q13. What do containers share inside a pod? 71
Q14. What are the different types of multiple-container pods? 72
Q15. How do I delete all pods in Kubernetes? 72
Q16. Can we recover pods after deletion? 72
Q17. Can we run windows and Linux containers in the same pod? 72
Q18. How do I update all my pods if the image changed but the tag is the same? 72
Q19. What is the difference between the pod and the container? 72
Q20. How to configure Vertical pod autoscaler? 72
Q21. How to configure Horizontal pod autoscaler? 73
Q22. How many pods can run on a node? 73
Kubernetes Deployments 74
Q1. What are Kubernetes Deployments? 74
Q2. What are Kubernetes manifests? 74
Q3. How can we check if Deployment is created or not? 74
Q4. How do I rollback the Deployment? 74
Q5. How to determine the status of deployment? 75
Q6. How can we see ReplicaSet which is created by deployment? 75
Q7. How can we get details of the deployment? 75
Q8. How can we Delete deployments by labels? 75
Q9. How to Pause/Resume deployments? 75
Q10. How to Check update history of deployment? 75
Q11. How to Check the update status of Deployments? 75
Q12. How to scale-out deployment? 75
Q13. How to Rollback Deployment to the previous version? 75
Q14. How can we Expose deployment as a load balancer service? 75
Kubernetes Networking 76
Q1. What is Kubernetes networking? 76
Q2. What are the different types of Kubernetes networking? 76
Q3. How does the Kubernetes Network work? 76
Q4. What are the Kubernetes Networking Conditions? 76
Q5. Why do we need network policy in Kubernetes? 76
Q6. How to apply network policy on pod? 76
Q7. How Does Kubernetes Networking Compare to Docker Networking? 77
Q8. What is cbr0 in Kubernetes? 77
Q9. What is Container to Container network? 78
Q10. What is pod to pod network? 78
Q11. What is pod to service network? 78
Q12. Explain the Internet to Cluster Networking 79
Q13. What is Ingress? 79
Q14. What is Egress? 79
Q15. What is CNI (container network interface)? 80
Q16. How many Kubernetes Network drives are supported in windows? 80
Q17. What are the different types of CNI? 80
Q18. How do I check my network for Kubernetes? 80
Q19. What is a flannel network in Kubernetes? 80
References 81
1
Container Orchestration
Q1. What is a Container?
Ans. A container is an executable unit. It is small, as it does not contain device drivers like other machines. Containers
do not contain OS images due to this it is platform-independent, portable and lightweight.
● A container gives the ability for predictable environments which is isolated from other applications and
environments.
● Also contain necessary dependency of the application like version, software libraries.
● we can break down complex applications into smaller ones.
● We can scale application as per need
Each VM run its OS All container shares the same kernel of the host
Provide process level isolation, which is less secure Fully isolated and are more secure
Heavyweight Lightweight
1. Windows 10
2. Windows Server 2016(Native container support)
3. Windows Server 2019(Native container support)
4. Mac OS (Native container support)
5. Linux
6. Azure
7. Amazon AWS
8. Google Cloud
a. Grafana
b. Heapster
c. CAdvisor
d. InfluxDB
e. Prometheus
Q11. What are various Container orchestration tools?
Ans. There are so many tools for Container orchestration, here I have listed down those tools.
1. Kubernetes
2. Docker Swarm,
3. Nomad
4. Docker Compose
5. Minikube
6. Cloudify-Pure-play Cloud Orchestration & Automation
7. OpenShift
8. Rancher
9. Containership
10. Marathon on Apache Mesos
11. Amazon ECS
12. AZK
13. GiantSwarm
14. Lunchbadger
15. Google Container Engine
2
Fundamentals of Kubernetes
Q1. What is Kubernetes?
Ans. Kubernetes is Google's open-source system(tool) for managing Linux and Windows containers across
private, public and hybrid cloud environments. In short, it is a container management tool.
Kubernetes automates the application deployments, scaling the cluster and container, scheduling, maintenance, and
operation of multiple application containers across clusters of nodes.
Kubernetes contains tools for orchestration, service discovery and load balancing that can be used with different
containerized systems like Docker and Rocket containers.
Deploying applications in containers for production environments, if one container goes down another container needs
to start, but keep in mind you need to manage the containers that run the applications with zero downtime. Wouldn’t it
be easier if this behaviour was managed by a Kubernetes? That is why we need Kubernetes for hundreds of micro and
monolithic applications.
● Pod
● Node
● Service
● Replica Set
● Namespace
● Replication Controller
● Deployments
● Volume
● Secret
● kubectl
● Rancher
● Nomad
● Docker Swarm
● Cloud Foundry
● AWS Fargate
● Apache Mesos
● OpenStack
● Docker Compose.
Container Kubernetes handles the update process Docker Swarm container updates are done by
updates and progressively monitoring service health to retain informing the scheduler to use a new image
rollbacks availability throughout the update process instead. The update can be rolled out if
making changes to one pod at the time something goes wrong.
preventing a service outage.
Logging and Kubernetes supports multiple levels of logging, Docker Swarm is supported for only
monitoring monitoring and debugging when the resources monitoring with the third-party tools. Docker
are deployed within the cluster Swarm has an open API, it makes it easier to
connect with plenty of apps.
Networking Kubernetes uses flannel, Calico, Weave Net and Docker Swarm forms a multi-host ingress
others to accomplish container networking. network overlay that connects containers
Containers are joined in this network and running on all cluster nodes. Inter-container
announced through etcd. networks can be configured manually.
Connections between nodes are also
automatically secured through TLS
authentication with certificates.
Data volumes Volumes shared within pods Simple shared local volumes
Service Containers can be defined as easily discoverable Services are discoverable throughout the
Discovery services cluster network
● Ubuntu 16.04+
● Debian 9+
● CentOS 7
● Red Hat Enterprise Linux (RHEL) 7
● Fedora 25+
● HypriotOS v1.0.1+
● Container Linux
V1.14 Windows Server 1809/Windows Server EE-basic 18.09 Supported for Windows Server
2019 containers Builds 17763.* with Docker
V1.18 alpha Windows CSI CSI drivers (e.g. Azure Docker EE supported containerized CSI node
Disk, GCE PD, etc.) plugins in
Windows via new CSIProxy
● It is very complex
● It is hard to estimate how much effort is required to implement on a large scale of the software.
● It is more expensive than its alternatives
● Its network configuration is very hard with Windows OS
● It requires experience and extensive training for its debugging and troubleshooting in due time
● DNS
● NodePorts
● ConfigMaps and Secrets
● Dashboards
● Container Runtime: Docker, CRI-O, and containerd
● CNI (Container Network Interface)
● Ingress
● Local Kubernetes
● Load Balancer
● Multi-cluster
Q4. What are the disadvantages of Minikube?
Ans. The disadvantages are described below:
Load balancing Very powerful load balancing across Has limited support
the multi-cluster
Q9. What command-line interface is used to interact with the Kubernetes cluster?
Ans. Kubectl - The command-line interface for Kubernetes
● Make sure you have kubectl installed (order to start working on a Kubernetes cluster, it is necessary to install the
Kubernetes command line (kubectl))
● Install VirtualBox or Hyper-V first
● Download the minikube-installer.exe file from git repo
● Add C:\Program Files (x86)\Kubernetes\minikube or similar to the PATH (in System Settings > Environment
Variables)
● To confirm successful installation please run the following commands:
o minikube start --driver=<driver_name>
o Note: <driver_name> is enter the name of the hypervisor you installed in lowercase letters
● Once minikube start run the command below to check the status of the cluster
o minikube status
you can install helm in your minikube cluster and utilize its features.
For Windows:
● you can download the latest tar file with the Windows binary from Releases · helm/helm and extract its contents.
● Copy helm.exe to the bin directory
● Run helm init from the command line to install "tiller" in the Minikube cluster.
For Linux:
$ ./get_helm.sh
kubeadm reset
sudo apt-get purge kubeadm kubectl kubelet kubernetes-cni kube*
sudo apt-get autoremove
sudo rm -rf ~/.kube
● kubectl - command-line interface for k8s cluster. you can manage the Kubernetes resources like create, delete,
update components and debug stuff in k8s using kubectl.
● kubelet - k8s process that runs on each node to manage containers: starting, communicating with them etc. Its
job is to assure that a pod spec provided by the API server is healthy.
$ minikube start
$ kubectl api-versions
minikube dashboard
Note: you can't use the Kubernetes feature when you have windows container mode.
Q26. Can we use the dashboard feature in Docker Desktop?
Ans. Yes, we can use the dashboard feature in Docker Desktop.using that feature you can manage your
container from dashboard UI.also you can check the log, inspect your container, check the status of the
container.
From a high level, a Kubernetes environment consists of a control plane (master), a distributed storage system for keeping
the cluster state consistent (etcd), and many cluster nodes (Kubelets).
1. Master Components
● Kube-apiserver
● Etcd
● Kube-scheduler
● Kube-controller-manager
2. Node Components
● Kubelet
● Kube-Proxy
● Container Runtime
● Build Image
● Test Execution
● Push image to the repository
● Pull the latest image
● Run image (Up the container)
● HorizontalPodAutoscaler
● VerticalPodAutoscaler
● Cluster Autoscaler.
HorizontalPodAutoscaler - Increasing the number of Pods for the application, in response to the present
computational needs.
Cluster Autoscaler (CA)- Scales node clusters based on the pending pods.
● Pods
● Replication sets and controllers
● Deployments
● Distinctive identities
● Stateful sets
● Daemon sets
● Jobs and Cron jobs
Q10. Explain the Load balancer in Kubernetes?
Ans. Kubernetes load balancing is the distribution of load among different nodes using different methods. The load
balancer uses the Kubernetes Endpoints API to track the availability of pods. Which manages the virtual IPs used by
services.
It mainly helps in implementing rules to control traffic routes. Ingress is a set up to provide services to externally reachable
URLs, load balance traffic, offer name-based virtual hosting, terminate SSL (secure sockets layer) or TLS (transport layer
security), etc. It is very important to note that ingress doesn’t expose all ports, only HTTP and HTTPS.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
selector:
app: my-app
type: ClusterIP
ports:
- name: http
port: 80
targetPort: 80
protocol: TCP
● Cluster IP service
● Node Port service
● External Name Creation service and
● Load Balancer service
● Default
● Kube - system
● Kube – public
Q4. Explain Daemon sets?
Ans. A Daemon Set is a set of pods that are run only once on a host, It creates pods on each added node and
garbage collects pods when nodes are removed from the cluster.
● Endpoints controller
● Namespace controller
● Service account controller
● Replication controller
● Node controller
● Token controller
● Filtering: In the filtering, Method finds the set of Nodes where it’s feasible to schedule the Pod
● Scoring: The scheduler ranks the remaining nodes to choose the most suitable Pod placement. The scheduler
assigns a score to each Node that survived filtering, basing this score on the active scoring rules.
Q13. How can we check the kube scheduler log in master node?
Ans. For checking the log, you have to go in this file: /var/log/kube-scheduler.log
Q14. What is a kube-controller manager?
Ans. In kubernetes kube-controller is the main component of the cluster. It manages different control processes like
nodes, workloads, namespace, service accounts and many more in the cluster. Also control loop watches the live status
of the cluster using API server and manage the current state and desired state of the container.
● This machine performs the requested tasks. The Master Node controls each Node
● Runs containers inside pods
● This is the place where Docker engines run and allow images to download and start containers as per
requested
Kubernetes Domain Name Server schedules a DNS Pod and Service on the cluster, and set up the kubelet to inform
individual containers to use the DNS Service’s IP to resolve DNS names.
Q8. What are the major functions of Kubelet as a node service component in
Kubernetes?
Ans. Major operations of kubelet as node service is run the pod containers and Report the status of the node and
each pod to the API Server
Q9. What things do we need to take care before joining the node in k8s cluster?
Ans. Here is the list of steps:
● check your Kubernetes cluster is working – configured and working control plane node
● Make sure you have installed Container runtime (Docker, cri-o, containerd, e.t.c) and Kubernetes tools
(kubeadm and kubelet) in your Worker node.
● If using Firewall such as firewalld, ports 10250, 30000-32767 and ports required by your Pod network add-
on should be opened in the firewall.
● SSH access to the machine to be added
● Configured kubectl for checking if the node is available in your cluster
docker --version
Control-plane node(s)
Worker node(s)
Q5. How to check the MAC address and product_uuid are unique for every node?
Ans. Verify Mac address: ip link or ifconfig -a
Q6. How can we assure that iptable can see bridge traffic?
Ans. We need to set this configuration for assurity:
For Example:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
Q7. Why do we need Check network adapters when we are going to install k8s?
Ans. If we have more than one network adapter, and Kubernetes components are not reachable on the default
route, for that we need to add IP route(s) so Kubernetes cluster addresses go via the appropriate adapter.
Kubernetes supported runtimes: Docker, rkt, runc and any OCI runtime-spec implementation
● Ubuntu 16.04+
● Debian 9+
● CentOS 7
● Red Hat Enterprise Linux (RHEL) 7
● Fedora 25+
● HypriotOS v1.0.1+
● Container Linux (tested with 1800.6.0)
Hardware/Cluster:
● 2 GB or more of RAM per machine (any less will leave little room for your apps)
● 2 CPUs or more
● Full network connectivity between all machines in the cluster (public or private network is fine)
● Unique hostname, MAC address, and product_uuid for every node
● Certain ports are open on your machines.
● Swap disabled. You MUST disable swap for the kubelet to work properly
Recommend you add IP route(s) so Kubernetes cluster addresses go via the appropriate adapter
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
Make sure that the br_netfilter module is loaded before this step. This can be done by running lsmod | grep
br_netfilter. To load it explicitly call modprobe br_netfilter
Control-plane node(s)
Worker node(s)
chmod +x ./kubectl
5. Verify Installation:
systemctl daemon-reload
Q6. Can you tell the commands for Get resources with json output?
Ans. kubectl get pods --all-namespaces -o json
Q13. How can we use the “kubectl apply command” on the folder where our yml
file is located?
Ans. kubectl apply -R -f .
-o=’custom-columns=PODS:.metadata.name,Images:.spec.containers[*].image’
A service is responsible for enabling network access to a set of pods. Service is responsible to expose an application as
network service. To use service without deployment, you need to create pods individually rather than "all-at-once”. Then
service requests traffic rout the network requests based on their pod's labels.
Services and Deployments are totally different, but they work together nicely.
Q4. How do services connect to the deployment?
Ans. Using selectors you can connect service and deployment. Keep in mind, in Kubernetes it depends on the
YML file to check the system is running as according to the desired state to the YML file.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.17.0
services.yml file
kind: Service
metadata:
name: frontend
spec:
type: NodePort
selector:
app: nginx
ports:
- port: 80
targetPort: 80
nodePort: 30005
● ClusterIP - is one type of service and only other pods can access that service within the same cluster.
● NodePort - is an open port for every node within the same cluster so incoming traffic can route to your
service even if it is for a different node's application.
● LoadBalancer - can access the service from outside the Kubernetes cluster (using an external IP). Load
Balancers are great when you have a TCP level connection. for higher-level connection (http) use Ingress +
NodePort.
● ExternalName - can access the service to the contents of the externalName field (e.g., fn.bam.example.com)
Kube-proxy implements a form of virtual IP for services for all types other than ExternalName. To achieve this,
you can set three possible modes:
● Proxy-mode: userspace
● Proxy-mode: iptables
● Proxy-mode: ipvs
● DNS
● ENV Var
Pods are replicated when the app is scaled horizontally by the ReplicationSet.Pods are the most basic and one of the
foremost units in Kubernetes. Other cluster objects are here to serve them and all the tasks they do are to manage pods'
desired state.
● Pending: Pod has been accepted by the Kubernetes system, but one or more container images have not yet been
created.
● Running: In this state, pod has been bound to respective nodes and a container has been created inside the pod.
At least one container is running or is in a startup or restart state.
● Successful (Succeeded): All containers in the Pod are successfully terminated and will not be restarted.
● Failed: All containers in the Pod have been terminated, among them at least one container was terminated or
exited with non-zero status in the pod.
● CrashLoopBackoff: The container fails to start and is tried again and again. Unable to obtain the status of the Pod
for some reason, usually because of the communication with the host where the Pod is located fails.
Q6. When and how pods will be created?
Ans. When you run the command like kubectl create -f my app.yml The API will store this
configuration in the ETCD, and the Scheduler will assign your application pods to worker nodes.
● Same namespace: Calls to service-name allow Pods in the same namespace to communicate.
● Different Namespace: Calls to service-name.namespace allow Pods in different namespaces to communicate
● Sidecar: The Sidecar pattern is used as a single node pattern to enhance the functionality of the main application. It
contains the logic of the application and it sends the logic files to the registry.
● Adapter: It is used to standardize and normalize the output application or monitor data for aggregation. It performs
restructuring, reformatting and output correction.
● Ambassador: It is a proxy pattern that allows other containers with a port on the localhost.
Q17. Can we run windows and Linux containers in the same pod?
Ans. No, you can’t run Windows and Linux containers in the same pod because a pod is scheduled in node and node
has specific platform and architecture.
Q18. How do I update all my pods if the image changed but the tag is the same?
Ans. For that you need to set "imagePullPolicy: "Always"
Q19. What is the difference between the pod and the container?
Ans. Pods are the collection of containers in Kubernetes. Containers are the set of codes and binary to compile in a
pod of the application. Containers can communicate with other containers in the same pod.
resourcePolicy:
containerPolicies:
- containerName: '*'
minAllowed:
cpu: 10m
memory: 50Mi
maxAllowed:
cpu: 1
memory: 500Mi
controlledResources: ["cpu", "memory"]
my-hpa.yml
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: myapp
minReplicas: 1
maxReplicas: 10
metrics:
- type: Pods
pods:
metric:
name: myapp_requests_per_second
target:
type: AverageValue
averageValue: 2
On Amazon Elastic Kubernetes Service (EKS), the maximum number of pods per node depends on the node type and
ranges from 4 to 737.
On Google Kubernetes Engine (GKE), the limit is 100 pods per node, regardless of the type of node.
12
Kubernetes Deployments
Q1. What are Kubernetes Deployments?
Ans. Using Deployment, we can manage Pods updates and Replica Sets. You describe the desired state in a
Deployment, A Deployment runs multiple replicas of your application and automatically replaces any instances that fail
or become unresponsive. Deployments are managed by the Kubernetes Deployment controller.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.17.0
● Container-to-Container networking
● Pod-to-Pod networking
● Pod-to-Service networking
● Internet-to-Service networking
● All Pods can communicate with all other Pods without using network address translation (NAT)
● Nodes are the machines that run the Kubernetes cluster. agents on a node (e.g. system daemons, kubelet) can
communicate with all pods on that node
● Each Pod will see itself with the same IP that other Pods see it as having.
The CNI plugin is selected by passing Kubelet the --network-plugin=cni command-line option
● Load Balancer
● Ingress Controller
● Calico
● Canal (Flannel + Calico)
● flannel
● kopeio-vxlan
● kube-router
● romana
● Weave Net
● https://kubernetes.io/docs/concepts
● https://docs.docker.com/docker-for-windows