k8s replication controller

replication controller is to manage HA with the pods in short terms .

apiVersion: v1
kind: ReplicationController
metadata:
 name: myapp-rc
 labels:
   app: myapp
   type: front-end
spec:
    template:
        metadata:
             name: myapp-rc
             labels:
               app: myapp
               type: front-end
        spec:
               containers:
                       - name: nginx-container
                         image: nginx
    replicas: 10

root@master:/tmp# k create -f test-rc.yaml
replicationcontroller/myapp-rc created
root@master:/tmp#

root@master:/tmp# k get pods -o wide
NAME             READY   STATUS    RESTARTS   AGE    IP             NODE                NOMINATED NODE   READINESS GATES
myapp-rc-5hvjr   1/1     Running   0          103s   10.244.64.6    node2.ckalab4.com   <none>           <none>
myapp-rc-7jzld   1/1     Running   0          103s   10.244.192.5   node1.ckalab4.com   <none>           <none>
myapp-rc-88m6r   1/1     Running   0          103s   10.244.192.4   node1.ckalab4.com   <none>           <none>
myapp-rc-c7q67   1/1     Running   0          103s   10.244.64.2    node2.ckalab4.com   <none>           <none>
myapp-rc-f2lxq   1/1     Running   0          103s   10.244.192.7   node1.ckalab4.com   <none>           <none>
myapp-rc-fzhns   1/1     Running   0          103s   10.244.192.6   node1.ckalab4.com   <none>           <none>
myapp-rc-mgx6k   1/1     Running   0          103s   10.244.64.3    node2.ckalab4.com   <none>           <none>
myapp-rc-ph578   1/1     Running   0          103s   10.244.64.5    node2.ckalab4.com   <none>           <none>
myapp-rc-tm746   1/1     Running   0          103s   10.244.192.3   node1.ckalab4.com   <none>           <none>
myapp-rc-zrp5f   1/1     Running   0          103s   10.244.64.4    node2.ckalab4.com   <none>           <none>
root@master:/tmp#
root@master:/tmp# k describe rc
Name:         myapp-rc
Namespace:    default
Selector:     app=myapp,type=front-end
Labels:       app=myapp
              type=front-end
Annotations:  <none>
Replicas:     10 current / 10 desired
Pods Status:  10 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=myapp
           type=front-end
  Containers:
   nginx-container:
    Image:        nginx
    Port:         <none>
    Host Port:    <none>
    Environment:  <none>
    Mounts:       <none>
  Volumes:        <none>
Events:
  Type    Reason            Age   From                    Message
  ----    ------            ----  ----                    -------
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-mgx6k
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-tm746
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-c7q67
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-7jzld
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-ph578
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-zrp5f
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-88m6r
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-f2lxq
  Normal  SuccessfulCreate  7m6s  replication-controller  Created pod: myapp-rc-fzhns
  Normal  SuccessfulCreate  7m6s  replication-controller  (combined from similar events): Created pod: myapp-rc-5hvjr
root@master:/tmp#

Deleting the replication controller will delete all the pods

root@master:/tmp# k get all
NAME READY STATUS RESTARTS AGE
pod/myapp-rc-5hvjr 1/1 Running 0 27m
pod/myapp-rc-7jzld 1/1 Running 0 27m
pod/myapp-rc-88m6r 1/1 Running 0 27m
pod/myapp-rc-c7q67 1/1 Running 0 27m
pod/myapp-rc-f2lxq 1/1 Running 0 27m
pod/myapp-rc-fzhns 1/1 Running 0 27m
pod/myapp-rc-mgx6k 1/1 Running 0 27m
pod/myapp-rc-ph578 1/1 Running 0 27m
pod/myapp-rc-tm746 1/1 Running 0 27m
pod/myapp-rc-zrp5f 1/1 Running 0 27m

NAME DESIRED CURRENT READY AGE
replicationcontroller/myapp-rc 10 10 10 27m

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 443/TCP 4h47m
root@master:/tmp#
root@master:/tmp# k delete replicationcontroller/myapp-rc
replicationcontroller “myapp-rc” deleted
root@master:/tmp# k get pods
No resources found in default namespace.
root@master:/tmp#

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *