Deploy a K8s Replication Controller

MD
R
Markdown

Pods are fine but the next level is Replication Controllers. - Implement desired state (eg. 5 replicas of Pod x) - Reconciliation Loop

Declarative file for the Replication Controller (*.yml)

apiVersion: v1
kind: ReplicationController
metadata:
  name: sampleapp-rc
spec:
  replicas: 10
  selector:
    app: sampleapp
  template:
    metadata:
      name: nginx
      labels:
        app: sampleapp
        env: production
    spec:
      containers:
      - name: myapp-container
        image: nginx
        ports:
        - containerPort: 8080

Load the yml on the apiserver {}

kubectl create -f rc-blueprint.yml kubectl get pods kubectl describe pods

Re-apply the Replication Controller

replicas: 10 kubectl apply -f rc-blueprint.yml

Check status of the replicas

kubectl get rc -o wide NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR sampleapp-rc 20 20 20 6m myapp-container nginx app=sampleapp

Created on 5/21/2018