...

Cloud Computing - Kubernetes

Back to Course

Lesson Description


Lession - #1211 Kubernetes replicationset


What is replication set in Kubernetes?

A ReplicaSet is an interaction that runs different cases of a Pod and keeps the predetermined number of Pods constant. Its motivation is to keep up with the predefined number of Pod occurrences running in a cluster at some random chance to keep clients from losing access to their application when a Pod comes up short or is distant.

creating a Kubernetes ReplicaSet
We will make a model ReplicaSet utilizing the below design, very much like we made a Pod to some extent 3 of this series.

Before we start, you ought to as of now have a running Kubernetes cluster and configured the kubectl command line tool to speak with the group. If not, subtleties on how you can get a group running utilizing KubeOne can be viewed as here. Essential information on Pod is proposed to follow the activity.

Stage 1: Create a YAML file utilizing vim on the order line:


$vim replicaset-app.yaml

Stage 2: Copy, glue, and save the setup beneath into your YAML document. The space is urgent!


apiVersion: applications/v1
kind: ReplicaSet
metadata:
  name: my-replicaset
spec:
  copies: 2
  selector:
    matchLabels:
      application: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      container:
      - name: my-container
        picture: nginx
    

Stage 3: Create the ReplicaSet with this command:

$kubectl create -f replicaset-app.yaml
replicaset.apps/my-replicaset created

Stage 4: Once the ReplicatSet is running, you can really look at its status:

$kubectl get replicaset my-replicaset

NAME           DESIRED    CURRENT    READY      AGE
my-replicaset    2         2          2         17s

Name: ## This is the name of the ReplicaSet pronounced as the offspring of the metadata property

Wanted: ## This is the reproduction number determined in the YAML manifest record

Current: ## This compares to the present status of the ReplicaSet; that two reproductions are up

Prepared: ## The two copies indicated are prepared and in the running state

Age: ## How long the copies have been in the running state

Stage 5: Next, you can check the situation with the Pods running in the ReplicaSet:

$ kubectl get Pods

NAME                    READY        STATUS     RESTARTS     AGE
my-replicaset-ccjfj      1/1         Running       0      5m18s
my-replicaset-m4bb7      1/1         Running       0      5m18s