Creating Kubernetes Replication Controller in 5 Minutes

Let’s look at the following diagram to create Kubernetes Replication Controller:

What to remember when creating ReplicationController

  • apiVersion: v1
  • You can define number of replicas, selector and template under spec
  • spec->template has its own spec section along side metadata
  • You specify containers’ related attributes under template‘s spec

Create ReplicationController YAML file example

apiVersion: v1
kind: ReplicationController
metadata:
  name: nginx
spec:
  replicas: 3
  selector:
    app: nginx
  template:
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx
        ports:
        - containerPort: 80

Leave a Comment