Create Replicaset in Kubernetes Cluster

Ticker

6/recent/ticker-posts

Create Replicaset in Kubernetes Cluster

 Question : The Nautilus DevOps team is going to deploy some applications on kubernetes cluster as they are planning to migrate some of their applications there. Recently one of the team members has been assigned a task to write a template as per details mentioned below:

Create a ReplicaSet using httpd image with latest tag only and remember to mention tag i.e httpd:latest and name it as httpd-replicaset.

Labels app should be httpd_app, labels type should be front-end. The container should be named as httpd-container; also make sure replicas counts are 4.

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 that might differ. So please read task carefully before executing.
 All the Best 👍

Solution:  

1. At first  kubectl  utility configure and working from jump server, run below commands   

thor@jump_host /$  kubectl get deploy

No resources found in default namespace.

thor@jump_host /$ kubectl get services

NAME         TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE

kubernetes   ClusterIP   10.96.0.1    <none>        443/TCP   3m28s

thor@jump_host /$

2.  Create  httpd.yaml  file with all the parameters given in task

    ( Refer Below Video for more clarity )

thor@jump_host /$ vi /tmp/httpd.yaml

thor@jump_host /$ cat /tmp/httpd.yaml

apiVersion: apps/v1

kind: ReplicaSet

metadata:

  name: httpd-replicaset

  labels:

    app: httpd_app

    type: front-end

spec:

  replicas: 4

  selector:

    matchLabels:

      app: httpd_app

  template:

    metadata:

      labels:

        app: httpd_app

        type: front-end

    spec:

      containers:

        - name: httpd-container

          image: httpd:latest

thor@jump_host /$



3.  Run below command to create pod

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

replicaset.apps/httpd-replicaset created

thor@jump_host /$



4.  Wait for  pods to get running status

thor@jump_host /$ kubectl get pods

NAME                     READY   STATUS    RESTARTS   AGE

httpd-replicaset-2qp9s   1/1     Running   0          32s

httpd-replicaset-4hgxw   1/1     Running   0          32s

httpd-replicaset-9ghzh   1/1     Running   0          32s

httpd-replicaset-cmrcq   1/1     Running   0          32s

thor@jump_host /$

 

5.  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