Google Cloud Platform command line Flashcards
To learn the Google Cloud Platform command line commands
Command to list your projects that are accessible by the active account
gcloud projects list
Command to set the region for your project
gcloud config set compute/region “region name”
where “region name” is us-east1 or us-central1 or europe-west1
Command to set your default project
gcloud config set project myProjects
Command to set the zone for your project
gcloud config set compute/zone “zone name”
where “zone name” is us-central1-c, europe-west1-a
Command to list the zones where the compute service is available (i.e. us-central1-a, us-central1-b, europe-west1-a)
gcloud compute zone list
Command to secure shell into a virtual machine or compute instance
gcloud compute ssh “virtual-machine-name”
You can’t have spaces in the name so you must have it all one word or put dashes in
Command to list the regions where you can do Cloud Functions (AWS equivalent of Lambdas)
gcloud functions region list
Command to list all the URI (Uniform Resource Identifier) in a zone
gcloud compute zones list –uri
Command to list a project’s DNS info
gcloud dns projects-info describe
Command to provide detailed information about a project
gcloud compute project-info describe –project
Command to list credentialed accounts
gcloud auth list
Command to create a project
gcloud projects create [Project_ID]
Project_ID is different from the Project Name. It can’t be changed but is still basically just a name with letters and numbers between 6 and 30 characters long
Command to create a project and also give it a name
gcloud projects create [Project_ID] –name=”myProjectName”
Command to delete a project
gcloud projects delete [Project_ID]
Command to show metadata for a project
gcloud projects describe [Project_ID]
Command to get IAM policies for a project
gcloud projects get-iam-policy [Project_ID]
Command to add an IAM policy binding to the existing IAM policy of a project
gcloud projects add-iam-policy-binding [Project_ID] –member [Member] –role [Role]
Command to remove an IAM policy binding to the existing policy of a project
gcloud project remove-iam-policy-binding [Project_ID] –member=[Member] –role=[Role]
Command to set the IAM policy of a project (the initial step)
gcloud projects set-iam-policy [Project_ID] [Policy_File]
Policy_File is the YAML or JSON file that contains all of your IAM settings (the policy)
Command to update the name of a project
gcloud projects update [Project_ID] –name=”the-new-project-name”
Command to install Stackdriver monitoring agent
curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh
Command to install Stackdriver logging agent
curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
Command to create a deployment
gcloud deployment-manager deployments create [Deployment_Name] –config configfile.yaml –description “MyDeployment”
The –config and –description flags are optional
Command to delete a deployment
gcloud deployment-manager deployments delete [Deployment_Name]
Command to provide information about a deployment
gcloud deployment-manager deployments describe [Deployment_Name]
Command to list deployments associated with the current project
gcloud deployment-manager deployments list
Command to stop a currently running or pending operation on a deployment
gcloud deployment-manager deployments stop [Deployment_Name]
Command to update a deployment with new configuration information
gcloud deployment-manager deployments update [Deployment_Name] –config new_config_file.yaml
Command to reserve an IP address for your project
gcloud compute addresses create [name for address] –addresses [XX.XXX.XXX.XXX (the IP address you want)]
Command to get info on an IP address for your project
gcloud compute address describe [name of address]
Command to list IP address of your project
gcloud compute addresses describe
Command to create disks
gcloud compute disks create [Disk_Name] –zone us-east1-a
Gcloud disk commands
gcloud compute disks [command]
command can be create, delete, describe, list, move, resize, snapshot, update
Gcloud firewall rules commands
gcloud compute firewall-rules [command]
command can be create, delete, update, list, describe
Gcloud health-checks commands
gcloud compute health-checks [command]
command can be create, delete, update, list, describe
create and update can also have protocols with them
gcloud compute health-checks create [protocol]
protocol can be http, https, ssl, and tcp
Gcloud image related commands
gcloud compute images [command]
command can be create, delete, update, list, describe, add-labels, remove-labels, export, import
Gcloud instance template related commands
gcloud compute instance-templates [command]
command can be create, delete, list, describe
Gcloud instance related commands
gcloud compute instances [command]
command can be create delete, list, describe, start, stop, move, update, update-container
Gcloud commands to get project information
gcloud compute project-info [command]
command can be describe, update, add-metadata, remove-metadata, set-usage-bucket
Gcloud region commands
gcloud compute region [command]
command can be describe or list
Gcloud snapshot commands
gcloud compute snapshot [command]
command can be delete, describe, list, update, add-labels, remove-labels
Gcloud configuration commands
gcloud config [command]
command can be get-value, list, set, unset
It can also be configurations [subcommand]
where subcommand is activate, create, delete, describe, list
Gcloud builds commands
gcloud builds [command]
commands can be cancel, describe, list, log submit
Gcloud clusters commands
gcloud container clusters [command]
command can be create, delete, describe, get-credentials, list, resize update, upgrade
Gcloud node pool commands
gcloud container node-pools [command]
command can be create, delete, describe, list, rollback, update
Gcloud container operations commands
gcloud container operations [command]
command can be describe, list, wait
Gcloud container registry commands
gcloud container images [command]
command can be add-tag, delete, describe, list, list-tags, untag
Gcloud IAM roles commands
gcloud iam roles [command]
command can be copy, create, delete, describe, list, undelete, update
Gcloud IAM service account commands
gcloud iam service-accounts [command]
command can be create, delete, describe, list, update, add-iam-policy-binding, remove-iam-policy-binding, set-iam-policy, sign-blob
Kubernetes commands to create a pod with a yaml configuration file
kubectl create -f podinfo.yaml
Kubernetes command to get info about a resource
kubectl get [resource type]
resource type can be pods, deployment, replicationcontroler
Kubernetes command to create and run an image
kubectl run [name] –image=[image name]
Kubernetes command to expose a resource to a new Kubernetes service
kubectl expose [resource type] [resource name]
example:
kubectl expose pod valid-pod –port=444 –name=frontend
Kubernetes command to delete a resource
kubectl delete [resource] [resource name]
example: deletes pods and services with the label “myLabel”
kubectl delete pods,services -l name=myLabel