Task:
The Nautilus DevOps team is going to deploy some applications on kubernetes cluster as they are planning to migrate some of their existing 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 nginx image with latest tag only and remember to mention tag i.e nginx:latest and name it as nginx-replicaset.
Labels app should be nginx_app, labels type should be front-end. The container should be named as nginx-container; also make sure replicas counts are 4.
Note: The kubectl utility on jump_host has been configured to work with the kubernetes cluster.
Step 1) Create an yaml file with given specifications.
thor@jump_host ~$ cat rs.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: nginx-replicaset
labels:
app: nginx_app
type: front-end
spec:
replicas: 4
selector:
matchLabels:
type: front-end
template:
metadata:
labels:
type: front-end
spec:
containers:
- name: nginx-container
image: nginx:latest
Step 2) Deploy the replicaset yaml file
thor@jump_host ~$ kubectl create -f rs.yaml
replicaset.apps/nginx-replicaset created
Step 3) Validate the replica set
thor@jump_host ~$ kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-replicaset 4 4 4 40s
thor@jump_host ~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-replicaset-mgkwf 1/1 Running 0 48s
nginx-replicaset-ttj9l 1/1 Running 0 48s
nginx-replicaset-vp59p 1/1 Running 0 48s
nginx-replicaset-zkbhl 1/1 Running 0 48s
No comments:
Post a Comment