Kubernetes CKAD Q&A (DevOpsfi)
1. What is Kubernetes?
Kubernetes Is a tool used for managing containers. it manages clusters of container hosts and the containers which are enclosed in a pod that is managed bt Kubernetes.
2. What are the benefits of using Kubernetes?
Monitoring-Kubernetes monitor the availability of the container in every millisecond and whenever the OS/Container goes down it will launch the identical container and serve the requests coming.
It’s portable and 100% open source.
Auto-Scaling-As load of the container increase the k8s launch more containers to handle the client request and as the load decrease the k8s shutdown the containers which causing less resource utilization
3. In which architecture does Kubernetes work?
Kubernetes work on Master-Slaves Architecture. There is a node also called controller node on which k8s is running is called a master node and the container is running on the other node called slaves node.
4. What is a multinode cluster and single-node cluster in Kubernetes?
When the controller program and the container node are running on the same machine or on the same operating system then it is called a single-node cluster MultiNode-Cluster-when the controller program of k8s is running on the one machine (master-node) and the container is running on the different container host machine (worker-node).
5. What do you mean by a pod in Kubernetes?
the pod is the smallest deployable unit of computing you can create and manage in k8s.
6. What is minikube?
Minikube is a program or software that helps to set up Kubernetes or K8s
7. How to install minikube and kubectl?
For minikube, go to google and download the software and then double click the exe file to get minikube installed.
Navigate to the Directory where Minikube is installed
cmd> cd C:\Program Files\Kubernetes\Minikube
and then run the command "minikube.exe start --driver=virtualbox --kubernetes-version=v1.20.0", so that it starts creating minikube vm in the virtual box which in turn acts as a k8s server.
8. Whereas, for kubectl, you need to download the program file using curl -lo command, and then it will get installed.
9. How to run any pod through kubectl?
kubectl run pod_name --image=image_name
10. What do you mean by exposing the pod?
Exposing the POD is equivalent to exposing a container, what exactly happens here is that particular ip and port number of POD gets internet access by the internal PAT/NAT mechanism.
11. How to expose the pod?
kubectl.exe expose deployment pod_name --port=Port_Number --type=NodePort
- Difference between pod and deployment?
The main reason why we take the help of k8s server is that even if the pod goes down, k8s can create a backup container for that one immediately.
But who exactly, inside k8s, gonna do this is the controller program called deployment.
There is no way to re-launch the pod once it's deleted.
But deployment keeps on tracking the desired state of a pod. So that if a pod goes down then the controller program will launch pods automatically.
12. What is a single node cluster?
Single node cluster is the environment where we have the container host and the Kubernetes residing in the same OS or same server.
13. What is a deployment controller?
A deployment controller is a program that deploys the pods and checks the health of running pods. If the pod goes down it will re-launch the replica of the same pod.
14. What is failover?
It means to re-launch the new pods when the older ones are down or get deleted.
15. What is kube API/API server?
- In the k8s server program which runs on the master node and, receives and processes the requests from the clients it's called kube API.
16. What are ways to send request to kubernete Server?
- There are 2 ways to send requests to the k8s server by using kubectl program, by writing the code in YAML lang.
17. What is YAML language? How to write code in YAML language?
- YAML is programming lang. which is used to write a code in Kubernetes, for doing the tasks.
- For writing the code in YAML we must understand yaml lang first. Proper indentation is must require in yaml programs.
- YAML lang. uses ( .yml ) extension for its file.
18. What is kubelet program?
- Kubelet is a program that is used by the k8s for communicating with the container engine.
19. What are Kubernetes resources?
- In simple term, we can say Kubernetes resources are basic parts of the k8s system by which we can use Kubernetes technology.
- These resources are called by the keywords.
- E.g. Pod, Deployment, Service, Replicas,
20. Use of getting and describe command?
- By using the get command we can get the list of all the resources which is created on the cluster, with their status.
- By the using describe command we can get every detail of all or given specific resources.
21. What is the use of spec and kind keyword?
- In YAML lang,
- Spec keyword is used for declaring any specifications to the resources.
- Kind keyword is used for declaring what kind of resource is this.
22. What is RC?
RC stands for Replication Controller. We know that k8s will do the management of containers. Actually, the program in k8s that exactly does this management of container tasks is RC. This is not done by deployment. Behind deployment, k8s will actually do this? Management means ensuring the container is always up.
23. What is replica?
Replica is a parameter in the specifications of yaml code in k8s. This parameter actually denotes the number of copies of containers created by container hosts.
24. Difference between creat and apply?
Create and apply looks similar in implementing the yaml code with a slight difference.
Create is used for creating the container using yaml code, whereas apply is used for updating the already created container (via yaml code) by making some changes to native yaml code file and then forcing them to apply on the container by using apply keyword in kubectl command.
For example kubectl create -f rc.yaml
kubectl apply -f rc.yaml
25. the command to see replication controller?
'kubectl get rc'. Also, we can use 'kubectl get services' or 'kubectl describe rc <name of rc>
26. What are labels?
We know that RC is a program in k8s, that does the management of PODs (Or containers). But to do this, RC has to know the IP of PODs. Even though it has acquired the IPs of PODs, k8s can't really rely on these IPs because IPs keep on cv hanging whenever the PODs reboot. To prevent this, RC has to use another parameter instead of relying on IPs. This is provided by labels. Labels are like tags to PODs, so that even the POD reboots, still, the label remains the same. Hence, RC uses labels to monitor the PODs.
27. How and where is Reverse Proxy used in Kubernetes?
'service' kind of resource will actually make use of loadbalancing and reverse proxy in k8s. This program will actually acts like the client for backend PODs and forwards the requests from actual end-users to the backend and then gives the response to end-users as soon as it gets the response from backend servers.
28. What are the different types of services in Kubernetes?
There are particularly 3 main services in k8s.
They are 1) Cluster IP 2) Node IP 3) External (Literally, we call it as a load balancer)
Cluster IP is the default load balancer in k8s. The drawback is that any node within the cluster can connect to LB but from outside no one can connect. In Node port type, LB has access to the outside world or even the internet. If you had created PODs in your k8s, and want to have the load balancer with them then we need to connect to ELB of 3rd party like AWS.
29. What is the importance of labels?
Labels act as a tag for the PODs, this helps the selector program of k8s to monitor their presence and include them whenever required for load balancing or managing.
30. How does the NodePort service work?
Node port works on the logic of doing the reverse proxy two times. Assume that k8s is running on minikube and try to randomly assume any empty port as 30k. Now in the yaml file, you need to mention node port as 30k. What exactly happens is if anyone tries to connect the minikube IP with 30k as port then the node port program will do reverse proxy to the actual loadbalancer 'service' Again load balancer will internally do reverse proxy from the requests (That is coming from node port program) to the pods. In this way, because we are doing two times reverse proxy hence we are able to make our PODs or LB's have internet access.
#k8s #CKAD #Linkedinlearning #Devops