Skip to content

Latest commit

 

History

History
58 lines (45 loc) · 1.7 KB

4.2.-replica-sets.md

File metadata and controls

58 lines (45 loc) · 1.7 KB

Replica Sets

With Pods we manage to declare the definition of one unit of deployment, e.g. one instance of Nginx. In a cluster environment we probably want to have more than one instances of our applications for example for the sake of redundancy and throughput.

In order to manage this need we'll use Replica Sets. A Replica Set defines the Pods that needs to run and the number of their replicas.

We'll use the same example of Nginx before but now we'll run multiple instances.

NOTE: Make sure you are pointing to the "kubernetic-tutorial" namespace.

Deploy kubernetic/replicaset-nginx Chart.

Here is the Replica Set definition:

{% code-tabs %} {% code-tabs-item title="nginx-replicaset.yaml" %}

apiVersion: extensions/v1beta1
kind: ReplicaSet
metadata:
  name: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
      template: replicaset
    matchExpressions:
      - {key: app, operator: In, values: [nginx]}
  template:
    metadata:
      labels:
        app: nginx
        template: replicaset
    spec:
      containers:
      - name: nginx
        image: nginx:1.10-alpine
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: 100m
            memory: 100Mi

{% endcode-tabs-item %} {% endcode-tabs %}

Now go to the Replica Sets section. You'll see the nginx Replica Set with two Pods generated.

Controllers > Replica Sets

Cleanup

Go to the Releases section and delete the release of the replicaset-nginx chart.

This will trigger the deletion of all items generated by the Chart.