Kubernetes - deep dive questions - Series 01

Kubernetes - deep dive questions - Series 01

  1. Node Affinity:

    • Describe what node affinity is and provide a scenario where you'd need to use it. Show a YAML configuration snippet demonstrating how to set a pod's affinity to nodes labeled with zone=west.
  2. StatefulSets:

    • How do StatefulSets differ from Deployments in Kubernetes? Given a scenario where you need persistent naming for your pods, which one would you choose and why? Provide a basic YAML configuration for a StatefulSet.
  3. Init Containers:

    • Describe the use case for init containers in a Pod lifecycle. Show a sample configuration where an init container prepares the environment for the main application.
  4. Network Policies:

    • You have two types of pods: frontend and backend. You want only the frontend pods to be able to access the backend pods. Provide a YAML configuration for a network policy to enforce this rule.
  5. Horizontal Pod Autoscaling (HPA):

    • Describe the primary metric types you can use for HPA in Kubernetes. Provide a YAML configuration to autoscale a deployment based on CPU utilization, with a target of 70%.
  6. Taints and Tolerations:

    • How do taints and tolerations work in Kubernetes for controlling pod placement? Demonstrate with a configuration where you taint a node to prevent any pods from scheduling on it unless they have a specific toleration.
  7. Custom Resource Definitions (CRD):

    • What is the purpose of a CRD in Kubernetes? Provide an example of a scenario where you'd need to define a custom resource and its corresponding controller.
  8. Pod Priority and Preemption:

    • Explain how pod priority and preemption work in Kubernetes. Demonstrate with a configuration where you define a high-priority class and assign it to a pod.
  9. Volume Snapshots:

    • Describe the functionality of volume snapshots in Kubernetes. How would you create a snapshot of a PVC named my-data?
  10. Ingress Controllers:

    • You've been given a task to route traffic to two different services: service-A and service-B, based on path. Service A should handle all requests with path /appA/*, and Service B with path /appB/*. Provide a basic YAML configuration using an Ingress resource to achieve this.