Posted by : at

Category : cloud   google

Gcloud commands

gcloud help

//list the active account name

gcloud auth list 

//list the project ID

gcloud config list project 

// Create a new virtual machine instance

gcloud compute instances create --help

gcloud compute instances create gcelab2 --machine-type n1-standard-2 --zone asia-south1-c

// set the default region and zones

gcloud config set compute/zone asia-south1-c

gcloud config set compute/region  asia-south1

// Open ssh session

gcloud compute ssh gcelab2 --zone asia-south1-c

// View the list of configurations in your environment:

gcloud config list 

// List your components

gcloud components list 

// create a kubernetes engine cluster

gcloud container clusters create [cluster-name]

gcloud container clusters create my-cluster

// Authentication Credentials for the cluster

gcloud container clusters get-credentials [CLUSTER-NAME]

// Delete a Kubernetes engine cluster

gcloud container clusters delete [CLUSTER-NAME]

// Create instance template

gcloud compute instance-templates create nginx-template

// Create Target Pool

gcloud compute target-pools create nginx-pool

// Create a managed instance group using the instance template:

gcloud compute instance-groups managed create nginx-group --base-instance-name nginx   --size 2 --template nginx-template  --target-pool nginx-pool

//List the compute engine instances and you should see all of the instances created:

gcloud compute instances list

// Create an L3 network load balancer targeting your instance group:

gcloud compute forwarding-rules create nginx-lb   --region us-central1 --ports=80 --target-pool nginx-pool

//List all Google Compute Engine forwarding rules in your project.

gcloud compute forwarding-rules list

// Health Check http request

gcloud compute http-health-checks create http-basic-check

// Define an HTTP service and map a port name to the relevant port for the instance group. Now the load balancing service can forward traffic to the named port:

gcloud compute instance-groups managed   set-named-ports nginx-group  --named-ports http:80