Kubernetes command based tasks

Task 1: Launch a pod using image , check it and delete the pods

kubectl run ncdnginx --image=nginx         # Start a nginx pod
kubectl get pods

kubectl run ncdnginx1 --image=nginx --port=80    #Start nginx1 pod,  and let the container expose port 80
kubectl get pods 



kubectl delete pod ncdnginx
kubectl get pods 

kubectl delete pod ncdnginx1
kubectl get pods 

Task 2: Create a deployment named ncd-tomcat1 , scaleit up, scaleit down

kubectl create deployment ncd-dep-tomcat1 --image=tomcat
kubectl get pods            # pods related to the deployment will start
kubectl get deployments     # ncd-tomcat1 deployment will be visible 



kubectl scale deployment ncd-dep-tomcat1 --replicas=10  # scale the replicaset side to 10. Run the next command immediately
watch -n .5 kubectl get pods                        # you should see new pods being created


kubectl scale deployment ncd-dep-tomcat1 --replicas=5   # scaledown the no.of replicas to 5. run watch command immediately
watch -n .5 kubectl get pods                        # you should see new pods being Terminated

Task 3: Expose this deployment as a service (type NodePort)

kubectl expose deployment ncd-dep-tomcat1 --port=31000 --target-port=8080 --type=NodePort --external-ip=<ip-of-vm>
kubectl get svc   #list the services

Leave a Comment

MFH IT Solutions (Regd No -LIN : AP-03-46-003-03147775)

Consultation & project support organization.

Contact

MFH IT Solutions (Regd)
NAD Kotha Road, Opp Bashyam School, Butchurajupalem, Jaya Prakash Nagar Visakhapatnam, Andhra Pradesh – 530027