ReplicationController in Kubernetes

Ticker

6/recent/ticker-posts

ReplicationController in Kubernetes

Question : The Nautilus DevOps team wants to create a ReplicationController to deploy several pods. They are going to deploy applications on these pods, which need some highly available infrastructure. Below you can find exact details, and please create the ReplicationController accordingly.

Create a ReplicationController using nginx image, preferably with latest tag, and name it as nginx-replicationcontroller.

Labels app should be nginx_app, and labels type should be front-end. The container should be named as nginx-container and also make sure replica counts are 3.

All pods should be running state.

Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.

Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍

Solution:  

1. At first  check existing deployment and  pods running status      

thor@jump_host /$ kubectl get namespace

NAME              STATUS   AGE

default           Active   74s

kube-node-lease   Active   81s

kube-public       Active   81s

kube-system       Active   82s

thor@jump_host /$

thor@jump_host /$ kubectl get pods

No resources found in default namespace.

thor@jump_host /$


2.  Create yaml  file with all the parameters , you can copy form gitlab

    https://gitlab.com/nb-tech-support/devops.git

    Refer Below Video for more clarity )

apiVersion: v1

kind: ReplicationController

metadata:

  name: nginx-replicationcontroller

  labels:

    app: nginx_app

    type: front-end

spec:

  replicas: 3

  selector:

    app: nginx_app

  template:

    metadata:

      name: nginx_pod

      labels:

        app: nginx_app

        type: front-end

    spec:

      containers:

        - name: nginx-container

          image: nginx:latest

          ports:

            - containerPort: 80 

 4. Run below command to create pod 

 thor@jump_host /$ kubectl create -f /tmp/replica.yaml

replicationcontroller/nginx-replicationcontroller created

thor@jump_host /$ 


5.  Wait for  pods to get running status

thor@jump_host /$ kubectl get pods

NAME        READY   STATUS    RESTARTS   AGE

nginx-replicationcontroller-6vvcf      1/1     Running   0          34s

nginx-replicationcontroller-jmkbc     1/1     Running   0          34s

nginx-replicationcontroller-shp9h     1/1     Running   0          34s

thor@jump_host /$


6.  Validate the task by running below command     

thor@jump_host /$ kubectl exec nginx-replicationcontroller-6vvcf  -- curl http://localhost

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:--<!DOCTYPE html>

<html>

<head>

<title>Welcome to nginx!</title>

<style>

    body {

        width: 35em;

        margin: 0 auto;

        font-family: Tahoma, Verdana, Arial, sans-serif;

    }

</style>

</head>

<body>

<h1>Welcome to nginx!</h1>

<p>If you see this page, the nginx web server is successfully installed and

working. Further configuration is required.</p>

 <p>For online documentation and support please refer to

<a href="http://nginx.org/">nginx.org</a>.<br/>

Commercial support is available at

<a href="http://nginx.com/">nginx.com</a>.</p>

 <p><em>Thank you for using nginx.</em></p>

</body>

</html>

100   612  100   612    0     0   298k      0 --:--:-- --:--:-- --:--:--  298k

thor@jump_host /$

7.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!


Apart from this if you need more clarity,  I have made a  tutorial video on this , 

please go through and share your comments. Like and share the knowledge



Post a Comment

0 Comments

Latest Posts

KodeKloud Kubernetes Security CKS  Lab Challenge 4 |  Audit-policy | Install & configure falco utility | Inspect the API server audit logs and identify the user