In this Lab, we shall learn how to Perform the following Tasks
- Provision a Kubernetes cluster using Kubernetes Engine
- Depl0y and Manage Docker Containers using
kubectl
-
Place your provisioned zone into an environment variable called MY_ZONE as follows:
`export MY_ZONE=us-central-1a`
-
Create a Cluster for Web servers called mywebfrontend with 2 Nodes:
`kubectl container clusters create mywebfrontend --zone $MY_ZONE --num-node 2`
Give it about 2 minutes to setup
-
Check Installed version of Kubernetes using the command below:
`kubectl version`
-
Using Cloud Shell prompt, launch a Single instance of the nginx container
kubectl create deploy nginx --image=nginx:1.17.10
-
View the Pods created
kubectl get pods
-
Allow web access of the nginx pod to internet and set it as Load Balancer
kubectl expose deployment nginx --port 80 --type LoadBalancer
-
Check Running Services to confirm pod is exposed and set as Load Balancer:
kubectl get services
Take note of the External IP address displayed.
-
Type this External IP address in your web browser. You should get the default nginx page.
-
Scale Up the number of pods :
kubectl scale deployment nginx --replicas 3
-
Confirm the new pods were added:
kubectl get pods
-
Confirm the IP address has not changed
kubectl get services
-
Verify the nginx webserver is still running by going ot web browser and refresh the web page from 5 above.
-
Exit the Command Line
exit