No more details than official document.
https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/
It enables HA, auto scaling, multi node controll (across nodes). This is the first fancy function in k8s!!
ReplicaSet is kind of newer version of ReplicationController.
https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#replicaset
In stead of ReplicationController and ReplicaSet, we create “Deployment” object to manage Pods. Actually, Deployment use ReplicaSet and when we create a Deployment it creates ReplicaSet automatically.
By labels, Selectors can select the Pod which should be monitored by the Selector.
If there already exist replicas selected by Selectors in ReplicaSet, creation of ReplicaSet wouldn’t create a new Pods in template section. But when existing Pods are down, then ReplicaSet create the Pod based on its templates.
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-nginx-deployment
labels:
app: myapp
type: nginx
spec:
template:
metadata:
name: my-nginx
labels:
app: myapp
type: nginx
spec:
containers:
- name: simple-nginx
image: nginx:latest
replicas: 4
selector:
matchLabels:
app: myapp
$ kubectl get all --all-namespaces
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 4h16m
$ kubectl apply -f Deployment.md
deployment.apps/my-first-deployment created
$ kubectl get all --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default pod/my-first-deployment-5b9f678469-6b72p 0/1 ContainerCreating 0 4s
default pod/my-first-deployment-5b9f678469-9jwn7 0/1 ContainerCreating 0 4s
default pod/my-first-deployment-5b9f678469-mdzh4 0/1 ContainerCreating 0 4s
default pod/my-first-deployment-5b9f678469-mhcjz 0/1 ContainerCreating 0 4s
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 4h16m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
default deployment.apps/my-first-deployment 0/4 4 0 4s
NAMESPACE NAME DESIRED CURRENT READY AGE
default replicaset.apps/my-first-deployment-5b9f678469 4 4 0 4s
4 Pods, 1 ReplicaSet, and 1 Deployment are created.
kubectl edit deployment/{deployment}
and edit the number of replicas
.