Page History

ReplicaSet

yhornisse edited this page on 26 Mar 2023

Clone this wiki locally

ReplicaSet

YAML

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80
$ kubectl apply -f sample.yml
replicaset.apps/nginx-deployment created
$ kubectl get rs -o wide                                                                                                                                               [~/work/k8s]
NAME               DESIRED   CURRENT   READY   AGE   CONTAINERS   IMAGES         SELECTOR
nginx-deployment   3         3         3       4s    nginx        nginx:1.14.2   app=nginx
$ kubectl describe rs nginx-deployment                                                                                                                                 [~/work/k8s]
Name:         nginx-deployment
Namespace:    default
Selector:     app=nginx
Labels:       app=nginx
Annotations:  <none>
Replicas:     3 current / 3 desired
Pods Status:  3 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=nginx
  Containers:
   nginx:
    Image:        nginx:1.14.2
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                   Message
  ----    ------            ----  ----                   -------
  Normal  SuccessfulCreate  64s   replicaset-controller  Created pod: nginx-deployment-9794d
  Normal  SuccessfulCreate  64s   replicaset-controller  Created pod: nginx-deployment-crmz5
  Normal  SuccessfulCreate  64s   replicaset-controller  Created pod: nginx-deployment-nfj9z