### Add backend with custom metrics file example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example demonstrating how to specify a file path for custom metrics. ```bash --custom-metrics=path_to_file.(yaml|json) ``` -------------------------------- ### Initialize gcloud CLI Source: https://docs.cloud.google.com/sdk/cloudplatform Run this command to start the initialization process for the gcloud CLI. It handles authentication and configuration setup. ```bash gcloud init ``` -------------------------------- ### Add backend with custom metrics file path example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example demonstrating how to specify a file path for custom metrics. ```bash --custom-metrics-file=path_to_file.(yaml|json) ``` -------------------------------- ### Start multiple versions Source: https://docs.cloud.google.com/sdk/gcloud/reference/app/versions/start Use this command to start multiple versions simultaneously across all services when manual scaling is enabled. ```bash gcloud app versions start v1 v2 ``` -------------------------------- ### List Available and Installed Components Source: https://docs.cloud.google.com/sdk/docs/components Run this command to view a list of all components available for installation and those already installed in your gcloud CLI. This helps in understanding what can be managed. ```bash gcloud components list ``` -------------------------------- ### Start a specific version Source: https://docs.cloud.google.com/sdk/gcloud/reference/app/versions/start Use this command to start a single version across all services when manual scaling is enabled. ```bash gcloud app versions start v1 ``` -------------------------------- ### Start a specific instance Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/start Starts a stopped instance named 'example-instance' in the specified zone 'us-central1-a'. ```bash gcloud compute instances start example-instance --zone=us-central1-a ``` -------------------------------- ### Add backend with custom metrics JSON example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example showing the JSON format for defining custom metrics. ```bash --custom-metrics='[{"dryRun": boolean, "maxUtilization": float, "name": "string"}]' ``` -------------------------------- ### Add backend with custom metrics file shorthand example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example of using shorthand notation with a custom metrics file. ```bash --custom-metrics-file=dryRun=boolean,maxUtilization=float,name=string --custom-metrics-file=dryRun=boolean,maxUtilization=float,name=string ``` -------------------------------- ### Start instances Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-groups/managed Starts stopped instances within a managed instance group. ```bash gcloud compute instance-groups managed start-instances ``` -------------------------------- ### Create an instance with a container and startup script from file Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container This example shows how to create an instance with a container, providing a startup script whose content is read from a local file. ```bash gcloud compute instances create-with-container INSTANCE_NAME \ --zone=ZONE \ --machine-type=MACHINE_TYPE \ --container-image=IMAGE \ --metadata-from-file=startup-script=STARTUP_SCRIPT_FILE ``` -------------------------------- ### Run gcloud CLI Installation Script Source: https://docs.cloud.google.com/sdk/docs/install Execute the gcloud CLI installation script after extracting the archive. This script guides you through the setup process. ```bash ./google-cloud-sdk/install.sh ``` -------------------------------- ### Create a Docker repository Source: https://docs.cloud.google.com/sdk/gcloud/reference/artifacts/repositories/create Creates a Docker repository named 'my-repo' in the default project and location. This is a basic example for getting started. ```bash gcloud artifacts repositories create my-repo --repository-format=docker ``` -------------------------------- ### Create Instance Template with Boot Disk Options Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container Example showing how to configure boot disk properties like size, type, and interface when creating an instance template. ```bash gcloud compute instance-templates create-with-container INSTANCE_TEMPLATE --boot-disk-size=10GB --boot-disk-type=pd-standard --boot-disk-interface=SCSI ``` -------------------------------- ### Create a plugin instance with actions Source: https://docs.cloud.google.com/sdk/gcloud/reference/apihub/plugins/instances/create This example demonstrates how to create a plugin instance and specify actions, including action ID, curation configuration, and scheduling. The shorthand example shows multiple actions. ```bash --actions=actionId=string,curationConfig={curationType=string,customCuration={curation=string}},scheduleCronExpression=string,scheduleTimeZone=string,serviceAccount=string --actions=actionId=string,curationConfig={curationType=string,customCuration={curation=string}},scheduleCronExpression=string,scheduleTimeZone=string,serviceAccount=string ``` -------------------------------- ### Create Instance Template with Container Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container Creates an instance template named 'instance-template-1' that runs the 'busybox' container image. This is a basic example for getting started. ```bash gcloud compute instance-templates create-with-container instance-template-1 --container-image=gcr.io/google-containers/busybox ``` -------------------------------- ### Install a specific gcloud CLI component Source: https://docs.cloud.google.com/sdk/docs/install Example of installing an additional component, such as the App Engine Java extension, using apt-get. ```bash sudo apt-get install google-cloud-cli-app-engine-java ``` -------------------------------- ### Create instance from source snapshot Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create This example demonstrates creating an instance where the boot disk is initialized from a specified source snapshot. ```APIDOC ## gcloud compute instances create --source-snapshot ### Description Creates a Compute Engine instance using a boot disk initialized from a source snapshot. ### Method `gcloud compute instances create` ### Parameters #### Command-line Flags `--source-snapshot`=`SOURCE_SNAPSHOT` The source snapshot to initialize the boot disk from. ### Request Example ```bash gcloud compute instances create my-instance-from-snapshot \ --source-snapshot=my-snapshot-name ``` ``` -------------------------------- ### Install Optional gcloud CLI Component Source: https://docs.cloud.google.com/sdk/docs/install Example command to install a specific optional component for the gcloud CLI, such as the App Engine Java component. ```bash sudo dnf install google-cloud-cli-app-engine-java ``` -------------------------------- ### Install and Run Local Container Builder Source: https://docs.cloud.google.com/sdk/docs/release-notes Install the container-builder-local component to use the local builder for Google Cloud Container Builder. Run 'container-builder-local' to start. ```bash container-builder-local ``` -------------------------------- ### Create instance with specific image Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create This example demonstrates creating an instance using a specific boot image and specifying the image project. ```APIDOC ## gcloud compute instances create --image --image-project ### Description Creates a Compute Engine instance using a specified boot image. ### Method `gcloud compute instances create` ### Parameters #### Command-line Flags `--image`=`IMAGE` The boot image for the instance. A new boot disk will be created from this image. `--image-project`=`IMAGE_PROJECT` The Google Cloud project containing the specified image. ### Request Example ```bash gcloud compute instances create my-instance-from-image \ --image=debian-11-bullseye-v20230101 \ --image-project=debian-cloud ``` ``` -------------------------------- ### Get Help for gcloud transfer Jobs Create Source: https://docs.cloud.google.com/sdk/gcloud/reference/transfer To get started with creating transfer jobs, you can view the help documentation for the `gcloud transfer jobs create` command. ```bash gcloud transfer jobs create --help ``` -------------------------------- ### Create a basic plugin instance Source: https://docs.cloud.google.com/sdk/gcloud/reference/apihub/plugins/instances/create Use this command to create a plugin instance with a specified ID, plugin, display name, project, and location. ```bash gcloud apihub plugins instances create --plugin-instance=my-instance --plugin=my-plugin --display-name="My Instance" --project=my-project --location=us-central1 ``` -------------------------------- ### Create an API Hub instance with labels Source: https://docs.cloud.google.com/sdk/gcloud/reference/apihub/api-hub-instances/create This example demonstrates how to create an API Hub instance and apply labels for metadata. Labels can be provided in shorthand, JSON, or file format. ```bash --labels=string=string ``` ```bash --labels='{"string": "string"}' ``` ```bash --labels=path_to_file.(yaml|json) ``` -------------------------------- ### Create a future reservation with a duration Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/future-reservations/create This example shows how to create a future reservation by specifying a duration in seconds relative to the start time. The start time must also be provided. ```bash gcloud compute future-reservations create RESERVATION_NAME \ --start-time=START_TIME \ --duration=DURATION \ --total-count=TOTAL_COUNT \ --zone=ZONE ``` -------------------------------- ### Initialize Google Cloud SDK Source: https://docs.cloud.google.com/sdk/docs/scripting-gcloud Run this command to authorize access and perform common Google Cloud SDK setup steps for user account authorization. ```bash gcloud init ``` -------------------------------- ### Create a future reservation with specific start and end times Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/future-reservations/create This example demonstrates creating a future reservation with a specified start and end time. Ensure the times are in RFC3339 format. ```bash gcloud compute future-reservations create RESERVATION_NAME \ --start-time=START_TIME \ --end-time=END_TIME \ --total-count=TOTAL_COUNT \ --zone=ZONE ``` -------------------------------- ### Manage pluginInstances with specific parameters Source: https://docs.cloud.google.com/sdk/gcloud/reference/apihub/plugins/instances/manage-source-data This example demonstrates how to manage plugin instance data by specifying the action, data type, data, and relative path. Replace placeholders with your actual values. ```bash gcloud apihub plugins instances manage-source-data --action=upload --data-type=environment-manifest --data=./my-manifest.yaml --relative-path=conf/ --location=us-central1 --plugin=my-plugin --instance=my-instance ``` -------------------------------- ### Install gcloud CLI in a Docker image Source: https://docs.cloud.google.com/sdk/docs/install Install the gcloud CLI within a Docker image using a single RUN step to ensure proper setup of the repository and keys. ```bash RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && apt-get update -y && apt-get install google-cloud-cli -y ``` -------------------------------- ### Update a future reservation's total count, start, and end time Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/future-reservations/update This example demonstrates how to update the total count, start time, and end time for a Compute Engine future reservation in a specific zone. ```APIDOC ## gcloud compute future-reservations update FUTURE_RESERVATION ### Description Update Compute Engine future reservations. ### Method `gcloud compute future-reservations update` ### Endpoint `gcloud compute future-reservations update FUTURE_RESERVATION` ### Parameters #### Path Parameters * **FUTURE_RESERVATION** (string) - Required - Name of the future reservation to update. #### Query Parameters * **--total-count** (integer) - Optional - The total number of instances for which capacity assurance is requested at a future time period. * **--start-time** (string) - Optional - The start time for the reservation. Format: YYYY-MM-DDTHH:MM:SSZ. * **--end-time** (string) - Optional - The end time for the reservation. Format: YYYY-MM-DDTHH:MM:SSZ. * **--zone** (string) - Optional - The zone for the reservation. Example: us-central1-a. ### Request Example ``` gcloud compute future-reservations update my-future-reservation --total-count=1000 --start-time=2021-11-10T07:00:00Z --end-time=2021-12-10T07:00:00Z --zone=us-central1-a ``` ``` -------------------------------- ### Add backend with custom metrics shorthand example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example demonstrating the shorthand syntax for specifying multiple custom metrics with their properties. ```bash --custom-metrics=dryRun=boolean,maxUtilization=float,name=string --custom-metrics=dryRun=boolean,maxUtilization=float,name=string ``` -------------------------------- ### Get effective IAM policies for 2 resources in a project (by number) Source: https://docs.cloud.google.com/sdk/gcloud/reference/asset/get-effective-iam-policy This example demonstrates how to get effective IAM policies for resources within a project, using the project number for scope identification. The command supports batch retrieval of policies. ```bash gcloud asset get-effective-iam-policy --scope=projects/YOUR_PROJECT_NUMBER --names=RESOURCE_NAME1,RESOURCE_NAME2 ``` -------------------------------- ### Create Instance Templates with Containers (Beta) Source: https://docs.cloud.google.com/sdk/docs/release-notes Use beta commands to create instance templates for Google Compute Engine that include container configurations. ```bash gcloud beta compute instance-templates create-with-container ``` -------------------------------- ### Create a Compute Engine instance with a container and a run command Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container This example demonstrates how to create a Compute Engine instance that runs a specific container image and executes a custom command within that container upon startup. This is useful for initializing containers with specific tasks. ```bash gcloud compute instances create-with-container instance-1 --zone us-central1-a \ --container-image=gcr.io/google-containers/busybox \ --container-command=echo \ --container-arg="Hello world" ``` -------------------------------- ### Create a TPU VM with default settings Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/tpus/tpu-vm/create Creates a TPU VM instance using default configurations. This is a basic command to get started. ```bash gcloud compute tpus tpu-vm create ``` -------------------------------- ### Get token info using curl Source: https://docs.cloud.google.com/sdk/gcloud/reference/auth/application-default/print-access-token This example shows how to use the printed access token with `curl` to retrieve details about the token, such as the associated account and expiration time. ```bash curl -H "Content-Type: application/x-www-form-urlencoded" -d "access_token=$(gcloud auth application-default print-access-token)" https://www.googleapis.com/oauth2/v1/tokeninfo ``` -------------------------------- ### Get a JSON array of all API products in a specific organization Source: https://docs.cloud.google.com/sdk/gcloud/reference/apigee/products/list This example shows how to retrieve all API products for an organization named 'my-org' and format the output as a JSON array. ```APIDOC ## gcloud apigee products list --organization --format=json ### Description List Apigee API products for a specific organization and format the output as JSON. ### Method GET ### Endpoint `gcloud apigee products list --organization=my-org --format=json` ### Parameters #### Query Parameters - `--organization` (string) - Required - ID of the organization or fully qualified identifier for the organization (e.g., 'my-org'). - `--format` (string) - Optional - Specifies the output format, in this case, 'json'. ### Request Example ```bash gcloud apigee products list --organization=my-org --format=json ``` ### Response #### Success Response (200) - The response will be a JSON array containing all API products for the specified organization. ``` -------------------------------- ### Create Instance with Stateful Configuration Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-groups/managed/create-instance Creates an instance with specified metadata, a stateful disk, a stateful internal IP, and a stateful external IP using an existing address reservation. This example demonstrates how to configure various stateful properties for a new instance within a managed instance group. ```bash gcloud compute instance-groups managed create-instance my-group --region=europe-west4 --instance=instance-1 --stateful-disk='device-name=foo,source=https://compute.googleapis.com/compute/alpha/projects/my-project/zones/europe-west4/disks/disk-1,mode=rw,auto-delete=on-permanent-instance-deletion' --stateful-metadata='my-key=my-value' --stateful-internal-ip=address=192.168.0.10,auto-delete=on-permanent-instance-deletion --stateful-external-ip=address=/projects/example-project/regions/europe-west4/addresses/my-address,interface-name=nic1 ``` -------------------------------- ### Create an instance with a container and specific network tier Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container This example shows how to create an instance with a container, specifying a particular network tier for the interface. ```bash gcloud compute instances create-with-container INSTANCE_NAME \ --zone=ZONE \ --machine-type=MACHINE_TYPE \ --container-image=IMAGE \ --network-interface=network=NETWORK,subnet=SUBNET,network-tier=PREMIUM ``` -------------------------------- ### Perform maintenance on nodes in a node group Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/sole-tenancy/node-groups/perform-maintenance This example demonstrates how to perform maintenance on specified nodes within a node group, including setting a start time for the maintenance window. ```APIDOC ## gcloud compute sole-tenancy node-groups perform-maintenance NAME --nodes=NODE,[`NODE`,…] [--start-time=START_TIME] [--zone=ZONE] ### Description Perform maintenance on nodes in a Compute Engine node group. ### Method `gcloud compute sole-tenancy node-groups perform-maintenance` ### Parameters #### Positional Arguments * **NAME** (string) - Required - Name of the node group to operate on. #### Required Flags * **--nodes** (list of strings) - Required - The names of the nodes to perform maintenance on. #### Optional Flags * **--start-time** (string) - Optional - The requested time for the maintenance window to start. The timestamp must be an RFC3339 valid string. * **--zone** (string) - Optional - Zone of the node group to operate on. ### Request Example ```bash gcloud compute sole-tenancy node-groups perform-maintenance my-node-group --nodes=node-1,node-2 --start-time=2023-05-01T00:00:00.000-08:00 ``` ``` -------------------------------- ### Add a pre-shared key to MACsec configuration Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/interconnects/macsec/add-key This example demonstrates how to add a pre-shared key named 'default-key' to the MACsec configuration of an interconnect named 'example-interconnect', with a specified start time. ```APIDOC ## gcloud compute interconnects macsec add-key ### Description Adds a pre-shared key to the MACsec configuration of a Compute Engine interconnect. ### Method `gcloud compute interconnects macsec add-key` ### Endpoint `gcloud compute interconnects macsec add-key NAME --key-name=KEY_NAME [--start-time=START_TIME] [GCLOUD_WIDE_FLAG ...]` ### Parameters #### Positional Arguments * **NAME** (string) - Required - Name of the interconnect to update. #### Required Flags * **--key-name**=`KEY_NAME` (string) - Required - A name of pre-shared key being added to MACsec configuration of the interconnect. The name must be 1-63 characters long, and comply with RFC1035. #### Optional Flags * **--start-time**=`START_TIME` (string) - Optional - A RFC3339 timestamp on or after which the key is valid. startTime can be in the future. If the keychain has a single key, --start-time can be omitted. If the keychain has multiple keys, --start-time is mandatory for each key. The start times of two consecutive keys must be at least 6 hours apart. ### Request Example ``` gcloud compute interconnects macsec add-key example-interconnect --key-name=default-key --start-time=2021-02-01T12:12:12Z ``` ``` -------------------------------- ### Create an instance with a container and a private IP Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container This example demonstrates creating an instance with a container, assigning a specific private IP address to its network interface. ```bash gcloud compute instances create-with-container INSTANCE_NAME \ --zone=ZONE \ --machine-type=MACHINE_TYPE \ --container-image=IMAGE \ --network-interface=network=NETWORK,subnet=SUBNET,private-network-ip=PRIVATE_IP_ADDRESS ``` -------------------------------- ### Create a GKE cluster with accelerators Source: https://docs.cloud.google.com/sdk/gcloud/reference/container/clusters/create This example demonstrates how to create a GKE cluster and attach NVIDIA Tesla T4 GPUs to its nodes. It specifies the accelerator type, count, and the GPU driver version to be installed. ```APIDOC ## gcloud container clusters create CLUSTER_NAME ### Description Creates a Google Kubernetes Engine (GKE) cluster. ### Method `gcloud container clusters create` ### Endpoint Not applicable (gcloud command) ### Parameters #### Positional Arguments * `NAME` (string) - Required - The name of the cluster to create. The name may contain only lowercase alphanumerics and '-', must start with a letter and end with an alphanumeric, and must be no longer than 40 characters. #### Flags * `--accelerator`=[`type`=`TYPE`,[`count`=`COUNT`,`gpu-driver-version`=`GPU_DRIVER_VERSION`,`gpu-partition-size`=`GPU_PARTITION_SIZE`,`gpu-sharing-strategy`=`GPU_SHARING_STRATEGY`,`max-shared-clients-per-gpu`=`MAX_SHARED_CLIENTS_PER_GPU`],…] - Attaches accelerators (e.g. GPUs) to all nodes. * `type` (string) - Required - The specific type (e.g. nvidia-tesla-t4 for NVIDIA T4) of accelerator to attach to the instances. Use `gcloud compute accelerator-types list` to learn about all available accelerator types. * `count` (integer) - Optional - The number of accelerators to attach to the instances. The default value is 1. * `gpu-driver-version` (string) - Optional - The NVIDIA driver version to install. Must be one of: `default`, `latest`, `disabled`. * `gpu-partition-size` (string) - Optional - The GPU partition size used when running multi-instance GPUs. * `gpu-sharing-strategy` (string) - Optional - The GPU sharing strategy (e.g. time-sharing) to use. * `max-shared-clients-per-gpu` (integer) - Optional - The max number of containers allowed to share each GPU on the node. * `--additional-zones`=`ZONE`,[`ZONE`,…] - (DEPRECATED) The set of additional zones in which the specified node footprint should be replicated. Use --node-locations instead. * `--addons`=[`ADDON`[=`ENABLED`|`DISABLED`],…] - Addons are additional Kubernetes cluster components. Default addons: HttpLoadBalancing, HorizontalPodAutoscaling. * `--alpha-cluster-feature-gates`=[`FEATURE`=`true`|`false`,…] - Selectively enable or disable Kubernetes alpha and beta kubernetes feature gates on alpha GKE cluster. * `--anonymous-authentication-config`=`ANONYMOUS_AUTHENTIZATION_CONFIG` - Enable or restrict anonymous access to the cluster. Must be one of: `ENABLED`, `LIMITED`. * `--async` - Return immediately, without waiting for the operation in progress to complete. * `--auto-monitoring-scope`=`AUTO_MONITORING_SCOPE` - The scope of monitoring to use for the cluster. ### Request Example ```bash gcloud container clusters create example-cluster \ --zone us-central1-a \ --accelerator type=nvidia-tesla-t4,count=2,gpu-driver-version=latest \ --num-nodes=1 ``` ### Response Details about the operation to create the cluster. ``` -------------------------------- ### Create Instance Template with Container Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create-with-container Example of creating an instance template that will launch a container. This command specifies the machine type, disk image, and container image to use. ```bash gcloud compute instance-templates create-with-container my-instance-template \ --machine-type=n1-standard-1 \ --image-project=cos-cloud \ --image-family=cos-stable \ --container-image=gcr.io/google-containers/hello-app:1.0 ``` -------------------------------- ### Create Instance Templates with Containers (Beta) Source: https://docs.cloud.google.com/sdk/docs/release-notes Promoted to beta: commands for creating instance templates with container configurations in Google Compute Engine. ```bash compute instance-templates create-with-container ``` -------------------------------- ### gcloud transfer Source: https://docs.cloud.google.com/sdk/gcloud/reference/transfer The gcloud transfer command group lets you create and manage Transfer Service jobs, operations, and agents. To get started, run: `gcloud transfer jobs create --help` ```APIDOC ## gcloud transfer ### Description The gcloud transfer command group lets you create and manage Transfer Service jobs, operations, and agents. ### Synopsis `gcloud transfer` `GROUP` | `COMMAND` [`GCLOUD_WIDE_FLAG …`] ### Groups - `agent-pools`: Manage on-premise transfer agent pools. - `agents`: Manage Transfer Service agents. - `jobs`: Manage transfer jobs. - `operations`: Manage transfer operations. ### Commands - `authorize`: Authorize an account for all Transfer Service features. ### Gcloud Wide Flags These flags are available to all commands: `--help`. Run `$ gcloud help` for details. ### Notes This variant is also available: `gcloud alpha transfer` ``` -------------------------------- ### Extend :stable Image with Custom Build Configuration Source: https://docs.cloud.google.com/sdk/docs/migrate-docker-images This example shows how to use a custom build configuration file to extend the :stable Docker image, installing specific Python packages and a Cloud SDK component. ```yaml steps: - id: 'extend-stable' name: gcr.io/google.com/cloudsdktool/google-cloud-cli:499.0.0-stable args: - gcloud - version env: - 'APT_PACKAGES=python3-google-auth python3-requests' - 'COMPONENTS=google-cloud-cli-pubsub-emulator' ``` -------------------------------- ### Create an instance with a container Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container Example of creating a Compute Engine instance that runs a container. This command demonstrates basic network interface configuration. ```bash gcloud compute instances create-with-container INSTANCE_NAME \ --zone=ZONE \ --machine-type=MACHINE_TYPE \ --container-image=IMAGE \ --network-interface=network=NETWORK,subnet=SUBNET ``` -------------------------------- ### Request advice for future reservation of VMs Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/advice/calendar-mode Use this command to get advice for a future reservation of specific VM instances. Ensure you specify the region, machine type, VM count, duration range, and start time range. ```bash gcloud compute advice calendar-mode --region=fake-region --machine-type=a3-megagpu-8g --vm-count=8 --duration-range=min=7d,max=14d --start-time-range=from=2025-02-20,to=2025-03-25 ``` -------------------------------- ### Create Instance Template (Preview) Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instance-templates/create Use this command to create an instance template using the preview version of the Compute Engine API. ```bash gcloud preview compute instance-templates create ``` -------------------------------- ### Create a Compute Engine reservation using an instance template Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/reservations/create Use this command to create a reservation by specifying VM properties through an existing instance template. Ensure the instance template exists and is accessible. ```bash gcloud compute reservations create my-reservation --vm-count=1 --source-instance-template=example-instance-template --zone=fake-zone ``` -------------------------------- ### List versions of a package by partial name using wildcard Source: https://docs.cloud.google.com/sdk/gcloud/reference/artifacts/versions/list Use the `--filter` flag with a wildcard character (`*`) in the name to list versions that match a partial name pattern. This example matches versions starting with '1.0' and versions ending with 'SNAPSHOT'. ```bash gcloud artifacts versions list --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/1.0*"' ``` ```bash gcloud artifacts versions list --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/*SNAPSHOT"' ``` -------------------------------- ### Configure network interface with specific properties Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/bulk/create This example demonstrates how to configure a network interface for an instance using the `--network-interface` flag. It shows how to specify the network, network tier, subnet, NIC type, and queue count. ```bash gcloud compute instances bulk create --network-interface=network=NETWORK,network-tier=NETWORK_TIER,subnet=SUBNET,nic-type=NIC_TYPE,queue-count=QUEUE_COUNT ``` -------------------------------- ### Request advice for future reservation of TPUs Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/advice/calendar-mode Use this command to get advice for a future reservation of TPUs. Specify the region, TPU version, chip count, workload type, duration range, and start time range. You can also define location policies for specific zones. ```bash gcloud compute advice calendar-mode --region=fake-region --location-policy=fake-zone-1=DENY,fake-zone-2=ALLOW --tpu-version=V5E --chip-count=16 --workload-type=BATCH --duration-range=min=30d,max=90d --start-time-range=from=2025-02-25,to=2025-06-25 ``` -------------------------------- ### Create Compute Engine Instances with Containers (Beta) Source: https://docs.cloud.google.com/sdk/docs/release-notes Promoted to beta: commands for creating Google Compute Engine instances pre-configured to run containers. ```bash compute instances create-with-container ``` -------------------------------- ### Install a New Component Source: https://docs.cloud.google.com/sdk/gcloud/reference/components Install a specific component that is not currently part of your Google Cloud CLI installation. ```bash gcloud components install COMPONENT ``` -------------------------------- ### Create Compute Engine Instances with Containers (Beta) Source: https://docs.cloud.google.com/sdk/docs/release-notes Use beta commands to create Google Compute Engine instances that are pre-configured to run containers. ```bash gcloud beta compute instances create-with-container ``` -------------------------------- ### Windows Installer Log to File Source: https://docs.cloud.google.com/sdk/docs/release-notes The Windows Installer can now use the `/logtofile` flag to write installation logs to `CloudSDKInstall.log` in the same directory. ```bash CloudSDKInstaller.exe /logtofile ``` -------------------------------- ### Install gcloud CLI Components Source: https://docs.cloud.google.com/sdk/gcloud Installs specific components for alpha, beta, or preview release levels if they are not already installed. The gcloud CLI will prompt for installation if a command from these levels is used without the component present. ```bash gcloud components install ``` -------------------------------- ### Get Help for Composer Environments Source: https://docs.cloud.google.com/sdk/gcloud/reference/composer Run this command to view detailed help and options for managing Cloud Composer environments. ```bash gcloud composer environments --help ``` -------------------------------- ### Start a Compute Engine instance Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/start Starts a stopped Compute Engine virtual machine instance. Only a stopped virtual machine can be started. ```APIDOC ## gcloud compute instances start ### Description Starts a stopped Compute Engine virtual machine instance. Only a stopped virtual machine can be started. ### Method `gcloud compute instances start` ### Parameters #### Positional Arguments * **INSTANCE_NAMES** (string) - Required - Names of the instances to operate on. #### Flags * **--async** (boolean) - Optional - Return immediately, without waiting for the operation in progress to complete. * **--csek-key-file**=`FILE` (string) - Optional - Path to a Customer-Supplied Encryption Key (CSEK) key file. * **--zone**=`ZONE` (string) - Optional - Zone of the instances to operate on. ### Example To start a stopped instance named 'example-instance' in zone 'us-central1-a', run: ``` gcloud compute instances start example-instance --zone=us-central1-a ``` ``` -------------------------------- ### gcloud workstations start Source: https://docs.cloud.google.com/sdk/gcloud/reference/workstations Start a workstation. ```APIDOC ## gcloud workstations start ### Description Start a workstation. ### Command gcloud workstations start ``` -------------------------------- ### Add backend with custom metrics file JSON example Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/backend-services/add-backend Example showing the JSON format for custom metrics when using a file. ```bash --custom-metrics-file='[{"dryRun": boolean, "maxUtilization": float, "name": "string"}]' ``` -------------------------------- ### Install libxcrypt-compat for DNF Source: https://docs.cloud.google.com/sdk/docs/install Install the `libxcrypt-compat` package, which is a dependency for installing the gcloud CLI using DNF on certain Red Hat-based systems. ```bash sudo dnf install libxcrypt-compat.x86_64 ``` -------------------------------- ### Create an instance from a source snapshot with a regional disk Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create Create an instance using an existing snapshot as the boot disk source and attach a regional persistent disk. The snapshot URL and disk details must be accurate. ```bash gcloud compute instances create instance-1 --source-snapshot=https://compute.googleapis.com/compute/v1/projects/myproject/global/snapshots/instance-snapshot --zone=us-central1-a --disk=name=disk1,scope=regional ``` -------------------------------- ### Install Google Cloud CLI with Homebrew Source: https://docs.cloud.google.com/sdk/docs/downloads-homebrew Use this command to install the gcloud CLI using Homebrew. Ensure Homebrew is installed first. ```bash brew update && brew install --cask gcloud-cli ``` -------------------------------- ### Add metadata to a Compute Engine instance Source: https://docs.cloud.google.com/sdk/gcloud/reference/compute/instances/create Provides key-value pairs to the guest OS. Special keys like 'startup-script' can execute commands on instance start. Metadata size is limited to 512 KB total. ```bash gcloud compute instances create INSTANCE_NAME --metadata=KEY=VALUE,KEY=VALUE ``` -------------------------------- ### Install a Specific gcloud Component Source: https://docs.cloud.google.com/sdk/docs/managing-components Use this command to install a specific component by its ID. The gcloud CLI will install the specified component at its current version. ```bash gcloud components install [COMPONENT-ID] ``` ```bash gcloud components install kubectl ``` -------------------------------- ### Remove Old Snap Package Source: https://docs.cloud.google.com/sdk/docs/downloads-snap If you have the old `google-cloud-sdk` snap package installed, remove it before installing the new one. This is necessary because both installations require the same aliases. ```bash snap remove google-cloud-sdk ``` -------------------------------- ### Install specific gcloud components Source: https://docs.cloud.google.com/sdk/gcloud/reference/components/install Installs the specified components (e.g., COMPONENT-1, COMPONENT-2) and any components they depend on. The command will list all components to be installed and ask for confirmation. ```bash gcloud components install COMPONENT-1 COMPONENT-2 ``` -------------------------------- ### Describe a backup using beta version Source: https://docs.cloud.google.com/sdk/gcloud/reference/sql/backups/describe This command is also available in the beta version of the Cloud SDK. ```bash gcloud beta sql backups describe ```