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.
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 |
replicationcontroller/nginx-replicationcontroller created thor@jump_host /$ |
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
/$ |
Happy Learning!!!!
0 Comments