Pods Flashcards
What is a multi-container pod in Kubernetes?
A multi-container pod in Kubernetes is a pod that runs multiple containers that share the same network namespace and storage volumes.
What is the purpose of using multi-container pods?
Multi-container pods are used to group containers that work together closely within the same pod, enabling them to share data and resources.
Can containers within a multi-container pod communicate with each other using localhost?
Yes, containers within the same pod can communicate with each other using localhost, as they share the same network namespace.
What are some common use cases for multi-container pods?
Common use cases for multi-container pods include using a sidecar container for log collection, an adapter container for data transformation, or an ambassador container for accessing external services.
How can you define a multi-container pod in a YAML file?
In a YAML file, you define a multi-container pod by listing multiple containers under the containers section within the pod’s specification.
What command is used to create a multi-container pod from a YAML file?
The kubectl create -f command followed by the YAML file name is used to create a multi-container pod.
How can you access and interact with a specific container within a multi-container pod?
You can access and interact with a specific container within a multi-container pod using the kubectl exec -it command, specifying the pod name and container name.
What is the purpose of using multi-container pods over single-container pods?
Multi-container pods are used when containers need to work closely together and share resources within the same pod, keeping related functionalities grouped together.
What happens if one container in a multi-container pod fails?
If one container in a multi-container pod fails, Kubernetes may restart it automatically, ensuring that the desired state of the pod is maintained.
Can multi-container pods have containers with different base images?
Yes, multi-container pods can have containers with different base images, allowing for flexibility in choosing the appropriate tools or functionalities for each container.
What is the fundamental networking model in Kubernetes?
The fundamental networking model in Kubernetes is a flat network, where most resources within a cluster can communicate with each other.
How are IP addresses assigned to pods in Kubernetes?
Pods in Kubernetes are assigned ephemeral IP addresses, meaning these IP addresses may change if a pod is rescheduled.
Can containers within the same pod communicate with each other directly?
Yes, containers within the same pod can communicate with each other directly using localhost and different port numbers.
How do pods communicate with each other in Kubernetes?
Pods communicate with each other through services, which act as load balancers for network traffic within the cluster.
What is a load balancer service in Kubernetes used for?
A load balancer service in Kubernetes is used to route external network traffic to pods within the cluster, providing external access to services.
Can pods on different nodes communicate with each other directly?
Yes, pods on different nodes within a Kubernetes cluster can communicate with each other directly.
What is the purpose of labels and selectors in Kubernetes networking?
Labels and selectors are used to identify, describe, and group related sets of objects or resources, allowing for easy filtering and selection.
How do labels and selectors work together in Kubernetes?
Selectors use labels to filter or select objects. Objects with labels that match the selector’s criteria are selected.
What are some common use cases for services in Kubernetes networking?
Common use cases for services in Kubernetes networking include load balancing traffic to pods, providing a stable endpoint for pods, and enabling service discovery.
What is the difference between ephemeral IP addresses and persistent IPs in Kubernetes?
Ephemeral IP addresses are assigned to pods and may change if a pod is rescheduled, while persistent IPs are assigned to services and remain stable for external access.
What is the primary purpose of multi-container pods in Kubernetes?
The primary purpose of multi-container pods is to allow multiple containers to run within the same pod and share resources.
How can you define multi-container pods in a Kubernetes YAML file?
Multi-container pods are defined in a Kubernetes YAML file by specifying multiple container sections under the same pod definition.
What is the benefit of using multi-container pods for log collection?
Using multi-container pods for log collection allows a sidecar container to collect and store log data, keeping the main application container clean and focused.
In the sidecar pattern, what role does the sidecar container play?
In the sidecar pattern, the sidecar container provides additional functionalities or services to the main application container, such as log collection or data backup.
What is the role of the Ambassador pattern in multi-container pods?
In the Ambassador pattern, the Ambassador container acts as an intermediary that connects the main application container to external services or data stores, abstracting the communication complexity.
Why is using multi-container pods beneficial for separating infrastructure code from application code?
Using multi-container pods allows infrastructure-related code, such as log collection or data synchronization, to be placed in separate helper containers, keeping the application code clean and focused.
How can you open a session inside a specific container within a multi-container pod?
You can open a session inside a specific container within a multi-container pod using the kubectl exec -it command with the pod name and container name.
What command can you use to get the logs for a specific container within a multi-container pod?
You can use the kubectl logs command with the pod name and container name to get the logs for a specific container within a multi-container pod.
How can you delete a multi-container pod using kubectl?
You can delete a multi-container pod using kubectl delete pod followed by the pod name.
What is a workload in the context of Kubernetes?
In the context of Kubernetes, a workload is an application or a set of containers running within a Kubernetes cluster.
What is the fundamental unit of a workload in Kubernetes?
What is the fundamental unit of a workload in Kubernetes?
How do workloads provide self-healing capabilities in Kubernetes?
Workloads, such as ReplicaSets and Deployments, provide self-healing capabilities by ensuring that the desired number of instances (Pods) are running, and if a Pod fails, it is automatically replaced.
What is the role of a ReplicaSet in Kubernetes?
A ReplicaSet’s primary role in Kubernetes is to manage the desired number of replica Pods, ensuring that they are running and maintaining the specified number.
What extra functionalities do Deployments provide on top of ReplicaSets?
Deployments provide extra functionalities on top of ReplicaSets, including rolling updates, version management, and the ability to define declarative desired states.
When is it recommended to use Deployments over ReplicaSets?
It is recommended to use Deployments over ReplicaSets when you need to manage application updates, rollback to previous versions, and maintain desired states more easily.
What are StatefulSets used for in Kubernetes?
StatefulSets are used in Kubernetes to manage stateful applications, ensuring stable and predictable network identities and persistent storage for each Pod.
What is the primary use case for DaemonSets in Kubernetes?
The primary use case for DaemonSets is to ensure that a specific Pod runs on every node in the cluster, typically for cluster-level operations or infrastructure-related tasks.
What are Jobs and CronJobs used for in Kubernetes?
Jobs and CronJobs in Kubernetes are used for running tasks that are expected to run to completion, such as batch processing or scheduled tasks.
What is the primary purpose of a ReplicaSet in Kubernetes?
The primary purpose of a ReplicaSet in Kubernetes is to ensure that a specified number of replica Pods are running at all times.
What happens if a Pod managed by a ReplicaSet fails or is deleted?
If a Pod managed by a ReplicaSet fails or is deleted, the ReplicaSet automatically replaces it to maintain the desired number of replicas.
How do you define the desired number of replica Pods in a ReplicaSet?
The desired number of replica Pods in a ReplicaSet is defined using the replicas field in the ReplicaSet’s configuration.
What is the difference between a ReplicaSet and a Deployment in Kubernetes?
A Deployment provides additional functionalities like rolling updates and version management on top of a ReplicaSet, making it more suitable for managing applications with changing versions.
How can you create a ReplicaSet in Kubernetes?
You can create a ReplicaSet in Kubernetes by defining a ReplicaSet configuration in a YAML file and then applying it using kubectl apply -f filename.yaml.
What command is used to list ReplicaSets in a Kubernetes cluster?
You can list ReplicaSets in a Kubernetes cluster using the kubectl get rs command.
How can you delete a ReplicaSet in Kubernetes?
You can delete a ReplicaSet in Kubernetes using the kubectl delete rs command followed by the name of the ReplicaSet.
What is the purpose of the selector field in a ReplicaSet?
The selector field in a ReplicaSet is used to specify the criteria for selecting which Pods are part of the replica set. It matches Pods based on their labels
Can you update the number of replicas for an existing ReplicaSet?
Yes, you can update the number of replicas for an existing ReplicaSet by modifying the replicas field in its configuration and then applying the changes using kubectl apply.
What is the role of a ReplicaSet’s template field?
The template field in a ReplicaSet specifies the Pod template to be used when creating new replica Pods. It defines the container images, labels, and other settings for the replica Pods.
In what situations is a ReplicaSet useful in Kubernetes?
A ReplicaSet is useful in Kubernetes when you want to ensure high availability and maintain a specific number of identical Pods, such as in stateless applications.
How does a ReplicaSet handle Pod failures or deletions?
When a Pod managed by a ReplicaSet fails or is deleted, the ReplicaSet controller automatically detects this and creates a replacement Pod to maintain the desired number of replicas.
Can a ReplicaSet be used for managing stateful applications?
ReplicaSets are typically used for managing stateless applications where each Pod is identical. Stateful applications are better managed using StatefulSets, which provide stable network identities and ordered pod creation.
What is the key difference between a ReplicaSet and a DaemonSet?
The key difference is that a ReplicaSet ensures a specified number of replica Pods are running in the cluster, while a DaemonSet ensures that exactly one Pod is running on each node in the cluster.