Kubernetes Interview Questions on ReplicaSet - Day 3

Kubernetes Interview Questions on ReplicaSet - Day 3
  1. What is a ReplicaSet in Kubernetes, and what problem does it solve?

    • A ReplicaSet is like a supervisor for your application in Kubernetes. It ensures that a specified number of identical copies (replicas) of your application are always running. This solves the problem of keeping your application available and reliable even if some parts of it fail.
  2. How does a ReplicaSet differ from a Deployment, and in what scenarios would you use one over the other?

    • A ReplicaSet is a simpler tool that just ensures a specific number of replicas are running. A Deployment is more advanced and can do rolling updates and rollbacks. You'd use a Deployment when you need to update your app without downtime or quickly revert to a previous version.
  3. What is the purpose of the 'selector' field in a ReplicaSet specification?

    • The 'selector' field tells the ReplicaSet which Pods to manage. It's like a filter that selects Pods based on their labels, so the ReplicaSet knows which Pods to control.
  4. How do you scale the number of replicas managed by a ReplicaSet?

    • You change the number in the 'replica' field in the ReplicaSet's instructions. If you want more replicas, you increase the number; if you want fewer, you decrease it.
  5. Explain the concept of 'Pod template' in the context of a ReplicaSet.

    • The Pod template is like a blueprint for the Pods managed by the ReplicaSet. It defines what each replica looks like, such as which container images to use, resource limits, and more.
  6. What happens when a ReplicaSet's 'replicas' field is set to a value less than the current number of Pods?

    • If you set 'replicas' to a number lower than the current number of Pods, the ReplicaSet will notice the extra Pods and gradually remove them, keeping only the specified number.
  7. Can you manually delete Pods managed by a ReplicaSet, and if so, what happens?

    • Yes, you can manually delete Pods. However, the ReplicaSet will notice and create new Pods to replace the deleted ones to maintain the desired number of replicas.
  8. How do you update the Pod template for an existing ReplicaSet?

    • To update the Pod template, you need to create a new ReplicaSet with the changes you want. Kubernetes will then gradually replace the old Pods with the new ones from the updated ReplicaSet.
  9. What is the significance of the 'matchLabels' field in a ReplicaSet selector?

    • 'matchLabels' specifies which Pods the ReplicaSet should manage based on their labels. It's like a tag system that helps the ReplicaSet find the right Pods to control.
  10. How can you ensure that a specific version of your application is maintained by a ReplicaSet?

    • By specifying the desired version in the Pod template, the ReplicaSet will ensure that all its replicas use that version. When you update the template, it'll use the new version.
  11. What is the difference between a ReplicaSet and a DaemonSet in Kubernetes?

    • A ReplicaSet manages a specified number of replicas for a generic application. A DaemonSet, on the other hand, ensures that a copy of your app runs on every node in the cluster.
  12. What happens if you delete a ReplicaSet? Do the associated Pods get deleted as well?

    • If you delete a ReplicaSet, by default, the associated Pods will also be deleted. This is because the ReplicaSet manages those Pods.