k8s Questions
k8s Questions
3. What is Kubeadm
Kubeadm helps for installing and configuring Kubernetes cluster using
command line.
8. What is Scheduler ?
etcd is light weight key-value database, it stores information like about current
state of cluster,..etc.
Worker node can be any Physical Server or Virtual Machine where containers
are deployed , containers can be docker,rocket,.etc.
Using namespace, we can logically organize objects in the cluster like pod
and deployments. When you create Kubernetes cluster , default, kube-system
and kube-public namespace are available.
We can deploy Pods, deployment, service within each Virtual Cluster called as
Kubernetes Namespace.
22. What is use of Namespace in Kubernetes ?
Suppose you have Dev, QA and Prod Environment in your project and you
want separate each environment in same cluster and deploy pods,
deployments and services also.
Using Ingress we can expose pod’s port like 80 ,443 from outside network of
Kubernetes over internet.
Replication Controller and Replica Set do almost the same thing. Both of them
ensure that a specified number of pod replicas are running at any given time.
The difference comes with the usage of selectors to replicate pods. Replica
Set use Set-Based selectors which gives more flexibility while replication
controllers use Equity-Based selectors.
A container or pod may crash because of multiple reasons. The main purpose
of using Replication is Reliability, Load Balancing, and Scaling. It ensures that
the pre-defined pods always exists.
Lets assume we are running our application on a single pod. What if for some
reason our application crashes and the pod fails. Users will no longer be able
to access our application.
To prevent users from losing access to our application we would like to have
more than one instances of our application running at the same time. That
way if one pod fails we still have our application running on the other one. The
replication controller helps us run multiple instances of a single pod in the
Kubernetes cluster. Thus providing high availability.
Cilium and Calico are both popular networking solutions used in Kubernetes
environments,
but they have some different features and focuses which might make one
more suitable than the other depending on the specific needs of a
deployment.
Cilium:
1. BPF-based Networking:
2. Security:
Cilium integrates well with service mesh technologies like Istio, providing
efficient load balancing and networking capabilities.
Calico:
1. Flexibility in Data Planes:
Calico provides options to use either standard Linux networking and routing
capabilities or eBPF for more advanced scenarios.
3. Cross-Platform Support:
4. Performance:
While Calico can use eBPF for high performance, its standard mode using IP
routing and iptables is also very efficient and scalable.
Ultimately, the choice between Cilium and Calico will depend on the specific
requirements of your infrastructure, such as performance needs, security
requirements, existing technology stack, and your team’s familiarity with these
tools.
Answer:
• 𝗘𝗺𝗽𝘁𝘆𝗗𝗶𝗿
-> created when the Pod is assigned to a node
-> RAM & Disk based mounting options
-> Volume is initially empty
• 𝗟𝗼𝗰𝗮𝗹
-> represents a mounted local storage device
-> only be used as a statically created PV
-> Dynamic provisioning not supported
-> must set a PV nodeAffinity
• 𝗛𝗼𝘀𝘁𝗽𝗮𝘁𝗵
-> mounts a file or dir from the host node’s FS to Pod
-> presents many security risks- Avoid it
-> Mostly useful for Static Pod! 𝗪𝗵𝘆?
↳ static Pods cannot access CM
• 𝗣𝗩𝗖
-> expanding PVC is enabled by default
-> used to mount a PersistentVolume
-> we can pre-bind PV & PVC
• 𝗦𝗲𝗰𝗿𝗲𝘁
-> secret volumes are backed by tmpfs (a RAM-backed fs) so they are never
written to non-volatile storage
-> A Secret is always mounted as readOnly
• 𝗖𝗼𝗻𝗳𝗶𝗴𝗠𝗮𝗽
-> Provides a way to inject config data into pods
-> You must create a CM before you can use it
-> CM is always mounted as readOnly.
• 𝗖𝗦𝗜
-> defines standard interface for container orchestration
-> CSI compatible volume driver need to deployed
-> Most widely used Option
Answer:
1. Check the deployment logs: The first step is to check the logs
of the deployment to see if there are any errors or warnings. You
can use the kubectl logs command to view the logs of a pod.
2. Check the pod status: You can also use the kubectl get
pods command to check the status of the pods in the deployment.
Make sure that all of the pods are running and that they are in a
healthy state.
3. Check the service status: If the pods are healthy, but the
application is still not working, you can check the status of the
service that exposes the application. Make sure that the service is
running and that it is configured correctly.
Answer:
Answer:
1. Kubelet will restart pods: The Kubelet on the failed node will
detect that the node is down and will restart the pods that were
running on that node on other healthy nodes in the cluster.
3. New node can be added: Once the failed node has been
replaced, the Kubelet on the new node will report to the master
node and join the cluster. The master node will then reschedule
the pods that were running on the failed node to the new node.
Answer: You can scale a deployment using the kubectl scale command. For
example, to scale a deployment named “app-deployment” to three replicas,
you would use:
bash
kubectl scale --replicas=3 deployment/app-deployment
This will ensure that three pods are running to handle increased traffic.
Answer: To perform a rolling update, you can use the kubectl set
image command. For instance, to update the image of a deployment named
“app-deployment” to a new version, you would use:
bash
kubectl set image deployment/app-deployment container-name=new-
image:tag
Kubernetes will gradually replace the old pods with new ones, ensuring zero
downtime during the update.
Answer: First, use kubectl get pods to check the status of the pod. Then,
use kubectl describe pod <pod-name> to get detailed information, including
events and container statuses. Inspecting the pod’s logs using kubectl logs
<pod-name> for each container can provide insights into issues. Additionally,
using kubectl exec -it <pod-name> -- /bin/sh allows you to access the
pod’s shell for further debugging.
Answer: Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) are
used for storage. A PV represents a physical storage resource, and a PVC is
a request for storage by a pod. Admins create PVs, and users claim storage
by creating PVCs. Pods reference PVCs. Storage classes define the type and
characteristics of the storage. The YAML files for PVs, PVCs, and the
deployment or pod need to be configured accordingly.
Answer: Kubernetes uses DNS for service discovery. Each service gets a
DNS entry formatted as <service-name>.<namespace>.svc.cluster.local .
Pods within the same namespace can communicate using this DNS. To
enable communication between services in different namespaces, use the full
DNS name, including the namespace. Kubernetes Services abstract the
underlying pods, providing a stable endpoint for communication.
Answer: Use StatefulSets for stateful applications like databases, where each
pod needs a unique identity and stable network identity. StatefulSets provide
guarantees about the ordering and uniqueness of pods. Pods in a StatefulSet
get a unique and stable hostname (e.g., <pod-name>-0, <pod-name>-1). This is
crucial for applications requiring persistent storage and where the order of
deployment and scaling matters.
Conclusion: