Secret IT Engineer

Blogs you've never heard of

ReplicaSet & ReplicationController

Multiple versions of the same pod can be configured using either ReplicaSet, Replication Controller or Deployments (which create a ReplicaSet).  Replication Controllers are deprecated and as such ReplicaSet (or Deployments with ReplicaSets) should be used to create and control multiple versions of the same Pod.  information about Replication Controllers is here to simply be informative.

ReplicationControllers

Replication controllers are created by using a YAML based definition file, the base contents of the file are the same as a pod definition file and therefore we will need the following information as a minimum:

 
 

apiVersion: v1

kind: ReplicationController

metadata: Metadata is the same as we would have with Pod.

spec:

 

The specification ( spec: ) section is important here, under the spec we create two sections called ‘template:’ and ‘replicas:’   The ‘template:’ section is a template of a POD, basically what the pod will look like when they are deployed using the ReplicationController, effectively this is the metadata: and spec: sections of a pod YAML file.

 

The other child of spec: is a section called replicas: which will define how many of the pods are created.  The overall YAML descriptor file should look something like below:

 

apiVersion: v1

kind: ReplicationController

metadata:

name: myapp-rc

labels:

app: myapp

type: front-end

spec:

template:

metadata:

name: redis

labels:

app: myapp

type: front-end

spec:

containers:

– name: redis-container

image: redis

replicas: 3

 

Deploy the ReplicationController descriptor file using kubectl create -f <FileName.yaml>. 

 

Once deployed check on the status of the number of Desired (number of replicas) Current (Deployed) and Ready.

 

ubuntu@kube1:~$ kubectl get replicationcontroller

NAME DESIRED CURRENT READY AGE

myapp-rc 3 3 3 13s

 


 

Published by

Leave a comment