Kubernetes 2 Flashcards
What happens when you run the kubectl delete command on a Pod without specifying the –grace-period parameter?
The Pod will be marked for deletion, but it may take some time for it to be terminated, and it will go through the standard termination process.
How can you run a command inside a running Pod interactively using kubectl?
You can use the kubectl exec -it command followed by the Pod name and the program you want to run to open an interactive session inside the Pod.
What does the initContainer section in a Pod’s YAML definition specify?
The initContainer section specifies one or more containers that run before the main application container starts and are used to initialize or prepare the environment for the application.
What happens if an init container in a Pod fails?
If an init container fails, the kubelet will repeatedly restart it until it succeeds, unless the restart policy is set to “Never.”
What is the purpose of using init containers in Kubernetes?
Init containers are used to perform tasks such as waiting for dependencies, initialization, or setup before the main application container starts, helping to keep the main container focused on the application logic.
In the context of Kubernetes, what does the term “ephemeral” mean when referring to Pods?
In Kubernetes, “ephemeral” means that Pods are short-lived and disposable. They can be replaced easily and are not meant to store long-term data.
How do you specify environment variables for a container within a Pod’s YAML definition?
You can specify environment variables in the env section of a container’s definition within the Pod’s YAML file.
What is the purpose of labels in a Pod’s definition?
Labels are used to identify, describe, and group related sets of objects and resources, allowing for easy organization and selection of Pods based on specific criteria.
How does a Pod’s deletion process work in Kubernetes?
When you delete a Pod in Kubernetes, it is marked for deletion, and a grace period of 30 seconds is added. The kubelet sends a termination signal to the container, and if it doesn’t stop within the grace period, the container is killed.
Why is the kubectl describe command useful when troubleshooting Pods?
The kubectl describe command provides detailed information about a Pod, including events and statuses, making it valuable for diagnosing issues and understanding the state of the Pod.
What is the purpose of an init container in Kubernetes?
An init container in Kubernetes is used to perform setup tasks or checks before the main application container starts. It helps initialize the environment for the main container.
How do init containers differ from main application containers in terms of their behavior?
Init containers run to completion before the main application containers start. They are designed for one-time initialization tasks or checks and do not continuously run like the main containers.
Can a Pod have multiple init containers, and if so, how do they execute?
Yes, a Pod can have multiple init containers. They execute in sequence, and each init container must complete successfully before the next one starts.
What happens if an init container in a Pod fails to complete successfully?
If an init container fails to complete successfully (exits with a non-zero status), Kubernetes will repeatedly restart it until it succeeds, unless its restart policy is set to “Never.”
When would you use an init container in a Pod?
Init containers are useful when you need to perform tasks such as database initialization, service availability checks, or configuration setup before launching the main application container in a Pod.
How does an init container’s completion affect the start of the main application container?
The main application container in a Pod starts only after all init containers have successfully completed.
What happens if an init container fails to complete successfully and its restart policy is set to “Always”?
If an init container fails and its restart policy is set to “Always,” Kubernetes will keep restarting it in an attempt to make it succeed indefinitely.
Can init containers share volumes or network namespaces with the main application container?
Yes, init containers can share volumes and network namespaces with the main application container, allowing them to exchange data or access network resources.
Is it possible to run commands inside an init container like in a regular container?
Yes, you can run commands inside an init container just like in a regular container. Init containers are essentially lightweight containers.
In what scenarios might you use multiple init containers in a Pod?
Multiple init containers can be used when you have multiple initialization tasks that need to be completed sequentially before the main application container can start.
What is a node pool in Kubernetes?
A node pool in Kubernetes is a group of virtual machines (nodes) of the same size within a cluster.
How can a cluster have multiple node pools, and what’s the purpose of having them?
A cluster can have multiple node pools, and each node pool can host virtual machines of different sizes. Node pools allow you to manage different types of nodes within a single cluster, such as nodes with and without GPUs, to optimize resource allocation.
In the context of Docker Desktop, why is there usually only one node?
Docker Desktop typically runs with only one node because it’s designed for local development and testing, where running master components and application containers on the same node is sufficient.
What does network traffic in Kubernetes go through on each node?
In Kubernetes, network traffic goes through the kube-proxy (kube proxy) on each node.