# GCP

#### Compute

<table><thead><tr><th width="340">Description</th><th>Command</th></tr></thead><tbody><tr><td>Create a Compute Engine instance</td><td><code>gcloud compute instances create [INSTANCE_NAME] --machine-type=[MACHINE_TYPE] --image-project=[IMAGE_PROJECT] --image-family=[IMAGE_FAMILY]</code></td></tr><tr><td>SSH into a Compute Engine instance</td><td><code>gcloud compute ssh [INSTANCE_NAME]</code></td></tr><tr><td>Create a Kubernetes Engine cluster</td><td><code>gcloud container clusters create [CLUSTER_NAME]</code></td></tr><tr><td>Deploy a container to a Kubernetes Engine cluster</td><td><code>kubectl create deployment [DEPLOYMENT_NAME] --image=[IMAGE_NAME]</code></td></tr><tr><td>Scale a Kubernetes Engine deployment</td><td><code>kubectl scale deployment [DEPLOYMENT_NAME] --replicas=[REPLICA_COUNT]</code></td></tr><tr><td>View Kubernetes Engine cluster information</td><td><code>gcloud container clusters describe [CLUSTER_NAME]</code></td></tr></tbody></table>

#### Storage

<table><thead><tr><th width="374">Description</th><th>Command</th></tr></thead><tbody><tr><td>Create a Cloud Storage bucket</td><td><code>gsutil mb gs://[BUCKET_NAME]</code></td></tr><tr><td>Copy files to a Cloud Storage bucket</td><td><code>gsutil cp [LOCAL_FILE_PATH] gs://[BUCKET_NAME]/[REMOTE_FILE_PATH]</code></td></tr><tr><td>Download files from a Cloud Storage bucket</td><td><code>gsutil cp gs://[BUCKET_NAME]/[REMOTE_FILE_PATH] [LOCAL_FILE_PATH]</code></td></tr><tr><td>List objects in a Cloud Storage bucket</td><td><code>gsutil ls gs://[BUCKET_NAME]</code></td></tr></tbody></table>

#### Networking

| Description                                                                                                                                                          | Command                                                                                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Create a VPC network                                                                                                                                                 | `gcloud compute networks create [NETWORK_NAME]`                                                                                      |
| Create a firewall rule with the specified name and allows traffic on the specified protocol and port from the specified IP range to instances with the specified tag | `gcloud compute firewall-rules create [FIREWALL_RULE_NAME] --allow [PROTOCOL]:[PORT] --source-ranges [IP_RANGE] --target-tags [TAG]` |

#### Other

| Description                                                       | Command                                  |
| ----------------------------------------------------------------- | ---------------------------------------- |
| List available GCP projects                                       | `gcloud projects list`                   |
| Set the active GCP project to the one with the given `PROJECT_ID` | `gcloud config set project [PROJECT_ID]` |
