logo
Published on

EKS ReplicaSets

Authors
  • avatar
    Name
    Bowen Y
    Twitter

ReplicaSets in Amazon Elastic Kubernetes Service (EKS)

Overview

ReplicaSets are a fundamental workload management resource in Kubernetes, and by extension, in Amazon Elastic Kubernetes Service (EKS). They ensure that a specified number of pod replicas are running at any given time.

Purpose of ReplicaSets

  • Maintain Stability: ReplicaSets maintain a stable set of replica Pods running at any given time.
  • Self-Healing: If a pod fails, the ReplicaSet replaces it to maintain the desired state.
  • Scaling: Automatically scales the number of pods in response to changes in configuration or environment.

How ReplicaSets Work

  1. Defining ReplicaSets: A ReplicaSet is defined with fields, including the number of replicas and a pod template which describes the pods to manage.

  2. Label Selector: Uses a label selector to identify the pods it should manage.

ReplicaSet Spec Example

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: example-replicaset
spec:
  replicas: 3
  selector:
    matchLabels:
      app: example-app
  template:
    metadata:
      labels:
        app: example-app
    spec:
      containers:
      - name: example-container
        image: nginx