Skip to main content

kubernetes controllers explanation and commands

Replication controller

It helps to ensure that the specified number of pods are running at any time.

It also helps us to spin new pods and nodes as an when the load / num of user increases

There are 2 similar terms
replication controller and replica set
both sound similar but are not the same
replication controller is the older tech which is being replaced by the replica set.

how do we create a replication controller:

for the replicationController in the spec we provide the template of the controller
so copy all the yml definition of yml file of pod except apiVersion and kind and paste it under the template

apiVersion: v1

kind: ReplicationController

metadata:
  name: myapp-rc
  labels:
    name: myapp
    type: front-end

spec:
  template:
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    spec:
      containers:
        - name: nginx-controller
          image: nginx
  replicas: 3



execute it using the command
kubectl create -f filename.yml

first, the pod is create using the pod definition

we can also see the desired num of replicas or PODs, the current number if replicas and how many of them are already in the output
kubectl get replicacontroller

if we want to see the pods that were created by the replicationController , run the
kubectl get pods

ReplicaSet

appVersion for replicaset will be -> apps/v1
The major difference between the replication controller and replica set is SELECTOR

usage:
let us say there were pods created as part of replica that matches labels specified in the selector, the replica set will also take those cards into consideration when creating replicas

apiVersion: apps/v1

kind: ReplicaSet

metadata:
  name: myapp-rc
  labels:
    name: myapp
    type: front-end

spec:
  template:
    metadata:
      name: myapp-pod
      labels:
        app: myapp
        type: front-end
    spec:
      containers:
        - name: nginx-controller
          image: nginx
  replicas: 3
  selector:
    matchLabels:
      type: front-end



To ensure that a particular number of replicas are running for a type we use labels

How do we scale the replica set
let's say we started with 3 but in future we decided it to increase it to 6

1st way
1. update the definition in the replica file to 6
run the following command
kubectl replace -f filename

2nd way
kubectl scale --repliacs=6 -f ymlfile
but this will not change the value inside of the file

commands

1. kubectl create -f filename
2. kubectl get replicaset
3. kubectl delete replicaset myapp-replcaset
*also deletes the underlying pods
4. kubectl replace -f replicaset-definition.yml
5. kubectl scale -replicas=6 -f filename
6. kubectl describe replicaset
7. kubectl get pods
8. kubectl get pods -o wide
we get to see the ip and the node of pods too

Comments

Popular posts from this blog

opening multiple ports tunnels ngrok in ubuntu

Location for the config yml file /home/example/.ngrok2/ngrok.yml content of config file authtoken: 4nq9771bPxe8ctg7LKr_2ClH7Y15Zqe4bWLWF9p tunnels: app-foo: addr: 80 proto: http host_header: app-foo.dev app-bar: addr: 80 proto: http host_header: app-bar.dev how to start ngrok with considering the config file: ngrok start --all

rename field in elastic Search

https://qiita.com/tkprof/items/e50368eb1473497a16d0 How to Rename an Elasticsearch field from columns: - {name: xxx, type: double} to columns: - {name: yyy, type: double} Pipeline API and reindex create a new Pipeline API : Rename Processor PUT _ingest/pipeline/pipeline_rename_xxx { "description" : "rename xxx", "processors" : [ { "rename": { "field": "xxx", "target_field": "yyy" } } ] } { "acknowledged": true } then reindex POST _reindex { "source": { "index": "source" }, "dest": { "index": "dest", "pipeline": "pipeline_rename_xxx" } }

Sumeru enterprise tiger privacy policy

Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. Data Privacy Policy At Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. we are committed to providing you with digitalization software products and services to meet your needs. Our commitment includes protecting personally identifiable information we obtain about you when you register to use one of our websites or become our customer (“Personal Information”). We want to earn your trust by providing strict safeguards to protect your Personal Information. This Policy applies to members, customers, former customers, users, and applicants. In the course of our business activities, Sumeru Enterprise Tiger Business Solutions Pvt. Ltd. collects, processes, and shares Personal Information. Indian law gives individuals the right to limit some but not all sharing. This Policy explains what Personal Information we collect, process, and share. We describe how we do so, and why. The Policy also describes your rights to access a...