We have seen the word 'replicas' in the Docker Swarm services definition time.
How to work with ReplicaSet?
What does ReplicaSet do?
How to create ReplicaSet?
ReplicaSet relationship with Pod
ReplicaSet will define the group of pods. You can tell how many replicas of pods for your application. The template section will define how many pods and their specification will be defined. Defining ReplicaSet allows you to deploy podand keep it alive as per configuration.
How to create ReplicaSet?
ReplicaSet relationship with Pod
apiVersion: apps/v1 kind: ReplicaSet metadata: name: my-tcat-rs labels: version: "3.0" spec: replicas: 2 selector: matchLabels: project: MyWeb role: frontend template: metadata: labels: project: MyWeb role: frontend env: dev spec: containers: - name: mytomcat image: tomcat:latest resources: requests: cpu: 100m memory: 256Mi ports: - containerPort: 8080Create the replicaset using the YAML manifestat file.
kubectl create -f replicasets.yml
2. Describe the ReplicaSet
In the spec, section is where the important things happen: we have defined a set of labels for the ReplicaSet, but we have also defined a pod template (in this case, with a single container) and specified that we want two pod instances of it (replicas: 2).
In the spec, section is where the important things happen: we have defined a set of labels for the ReplicaSet, but we have also defined a pod template (in this case, with a single container) and specified that we want two pod instances of it (replicas: 2).
kubectl -n vybhava describe rs # another option to see the replicaset kubectl -n vybhava describe replicaset my-tcat-rs
3. How to Scale the ReplicaSet?
a. Scale-up ReplicaSet
You can specify the increased number for replicas configuration
a. Scale-up ReplicaSet
You can specify the increased number for replicas configuration
kubectl -n vybhava scale --replicas=6 rs my-tcat-rs kubectl -n vybhava get all
b. Scale down ReplicaSet
You cna brought down the replicas to 0 as well.
You cna brought down the replicas to 0 as well.
kubectl -n vybhava scale --replicas=0 rs my-tcat-rs kubectl -n vybhava get all
4. Print wide output of the ReplicaSet
Deleting the ReplicaSet using 'delete' sub-command provide the name of the replicaset.
kubectl -n vybhava delete rs my-tcat-rs kubectl -n vybhava get rs
6.
6. How to get the ReplicaSets output to YAML or JSON format?
No comments:
Post a Comment