Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views3 pages

GCP K8s Lab

This document provides a step-by-step guide for setting up a Kubernetes (K8s) cluster on Google Cloud Platform (GCP), including creating a project, cluster, and virtual machines. It outlines commands to deploy an Nginx application, expose it using LoadBalancer, and access it via a web browser. Additionally, it mentions deprecated commands and recommends using manifest files for creating deployments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

GCP K8s Lab

This document provides a step-by-step guide for setting up a Kubernetes (K8s) cluster on Google Cloud Platform (GCP), including creating a project, cluster, and virtual machines. It outlines commands to deploy an Nginx application, expose it using LoadBalancer, and access it via a web browser. Additionally, it mentions deprecated commands and recommends using manifest files for creating deployments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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>

You might also like