GCP K8s Lab:
1. Login to GCP: https://console.cloud.google.com/
2. Create a project:
3. Creater k8s cluster:
4. You can create 1 or 2 VM as part of cluster:
5.
6. Once cluster is ready then click on connect and run Gcloud Shell
7. Once your shell is ready then type below commands:
kubectl run --image=nginx:latest myweb
kubectl get deployments
kubectl get pods
How to expose your deployments to outside the word using LoadBalancer or NodePort
syntax:
kubectl expose deployment <deployment name> --port=80 --target-port=80 --type=LoadBalancer
ex:
kubectl expose deployment myweb --port=80 --target-port=80 --type=LoadBalancer
kubectl get services
then copy load balancer’s IP and paste in Google Chrome Browser:
In backend GCP will create a Network Load Balancer: you can also check in console
points to remember:
below commands are deprecated
kubectl run --image=nginx:latest myweb
kubectl run --generator=deployment/apps.v1 my-web2 --image=nginx
K8s recommends to use create command by having manifest file:-
kubectl create -f <manifest file name>