Replication controller
It helps to ensure that the specified number of pods are running at any time.
It also helps us to spin new pods and nodes as an when the load / num of user increases
There are 2 similar terms
replication controller and replica set
both sound similar but are not the same
replication controller is the older tech which is being replaced by the replica set.
how do we create a replication controller:
for the replicationController in the spec we provide the template of the controller
so copy all the yml definition of yml file of pod except apiVersion and kind and paste it under the template
execute it using the command
kubectl create -f filename.yml
first, the pod is create using the pod definition
we can also see the desired num of replicas or PODs, the current number if replicas and how many of them are already in the output
kubectl get replicacontroller
if we want to see the pods that were created by the replicationController , run the
kubectl get pods
usage:
let us say there were pods created as part of replica that matches labels specified in the selector, the replica set will also take those cards into consideration when creating replicas
To ensure that a particular number of replicas are running for a type we use labels
How do we scale the replica set
let's say we started with 3 but in future we decided it to increase it to 6
1st way
1. update the definition in the replica file to 6
run the following command
kubectl replace -f filename
2nd way
kubectl scale --repliacs=6 -f ymlfile
but this will not change the value inside of the file
commands
1. kubectl create -f filename
2. kubectl get replicaset
3. kubectl delete replicaset myapp-replcaset
*also deletes the underlying pods
4. kubectl replace -f replicaset-definition.yml
5. kubectl scale -replicas=6 -f filename
6. kubectl describe replicaset
7. kubectl get pods
8. kubectl get pods -o wide
we get to see the ip and the node of pods too
It helps to ensure that the specified number of pods are running at any time.
It also helps us to spin new pods and nodes as an when the load / num of user increases
There are 2 similar terms
replication controller and replica set
both sound similar but are not the same
replication controller is the older tech which is being replaced by the replica set.
how do we create a replication controller:
for the replicationController in the spec we provide the template of the controller
so copy all the yml definition of yml file of pod except apiVersion and kind and paste it under the template
apiVersion: v1 kind: ReplicationController metadata: name: myapp-rc labels: name: myapp type: front-end spec: template: metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-controller image: nginx replicas: 3
execute it using the command
kubectl create -f filename.yml
first, the pod is create using the pod definition
we can also see the desired num of replicas or PODs, the current number if replicas and how many of them are already in the output
kubectl get replicacontroller
if we want to see the pods that were created by the replicationController , run the
kubectl get pods
ReplicaSet
appVersion for replicaset will be -> apps/v1
The major difference between the replication controller and replica set is SELECTOR
let us say there were pods created as part of replica that matches labels specified in the selector, the replica set will also take those cards into consideration when creating replicas
apiVersion: apps/v1 kind: ReplicaSet metadata: name: myapp-rc labels: name: myapp type: front-end spec: template: metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-controller image: nginx replicas: 3 selector: matchLabels: type: front-end
To ensure that a particular number of replicas are running for a type we use labels
How do we scale the replica set
let's say we started with 3 but in future we decided it to increase it to 6
1st way
1. update the definition in the replica file to 6
run the following command
kubectl replace -f filename
2nd way
kubectl scale --repliacs=6 -f ymlfile
but this will not change the value inside of the file
commands
1. kubectl create -f filename
2. kubectl get replicaset
3. kubectl delete replicaset myapp-replcaset
*also deletes the underlying pods
4. kubectl replace -f replicaset-definition.yml
5. kubectl scale -replicas=6 -f filename
6. kubectl describe replicaset
7. kubectl get pods
8. kubectl get pods -o wide
we get to see the ip and the node of pods too
Comments
Post a Comment