CloudWiki

Amazon Web Service (AWS)

ReplicaSet

Kubernetes
A ReplicaSet maintains a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.
kubernetes_deployment
ReplicaSet
attributes:
  • replicas - (Optional) The number of desired replicas. This attribute is a string to be able to distinguish between explicit zero and not specified. Defaults to 1. For more info see Kubernetes reference
Associating resources with a
ReplicaSet
Resources do not "belong" to a
ReplicaSet
Rather, one or more Security Groups are associated to a resource.
Create
ReplicaSet
via Terraform:
The following HCL creates a deployment with 3 replicas
Syntax:

resource "kubernetes_deployment" "example" {
 metadata {
   name = "terraform-example"
   labels = {
     test = "MyExampleApp"
   }
 }

 spec {
   replicas = 3

   selector {
     match_labels = {
       test = "MyExampleApp"
     }
   }

   template {
     metadata {
       labels = {
         test = "MyExampleApp"
       }
     }

     spec {
       container {
         image = "nginx:1.21.6"
         name  = "example"

         resources {
           limits = {
             cpu    = "0.5"
             memory = "512Mi"
           }
           requests = {
             cpu    = "250m"
             memory = "50Mi"
           }
         }

         liveness_probe {
           http_get {
             path = "/"
             port = 80

             http_header {
               name  = "X-Custom-Header"
               value = "Awesome"
             }
           }

           initial_delay_seconds = 3
           period_seconds        = 3
         }
       }
     }
   }
 }
}

Create
ReplicaSet
via CLI:
Parametres:

apiVersion: apps/v1

kind: ReplicaSet

metadata:

 name: frontend

 labels:

   app: guestbook

   tier: frontend

spec:

 # modify replicas according to your case

 replicas: 3

 selector:

   matchLabels:

     tier: frontend

 template:

   metadata:

     labels:

       tier: frontend

   spec:

     containers:

     - name: php-redis

       image: gcr.io/google_samples/gb-frontend:v3

Example:

kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml

Best Practices for
ReplicaSet

Categorized by Availability, Security & Compliance and Cost

No items found.
Explore all the rules our platform covers
All Resources