GKE - Google Kubernetes Engine

Playground Instructions

General Instructions Linux Machine

Prepare an isolated Ubuntu VM to run Google Cloud commands without relying on Cloud Shell. This approach centralizes your workflows on a dedicated environment and gives you full control over the CLI configuration.

Table of Contents

  1. Launch the Ubuntu VM
  2. Install Prerequisites
  3. Add the Google Cloud SDK Repository
  4. Install the Google Cloud CLI
  5. Authenticate and Configure gcloud
  6. Optional Configuration
  7. References

Launch the Ubuntu VM

  1. In your Playgrounds console, choose Ubuntu.
  2. Click Launch Now.
  3. Wait until the VM status shows Ready.

Note

Assign a static external IP if you need consistent SSH access over time.


Install Prerequisites

SSH into your new VM and install the required packages:

sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates gnupg curl
PackagePurpose
apt-transport-httpsEnables APT to use repositories accessed via HTTPS
ca-certificatesProvides SSL certificates
gnupgManages GPG keys
curlDownloads files from the command line

Add the Google Cloud SDK Repository

  1. Import Google’s public key for APT:

    curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
      | sudo gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg
    
  2. Add the Cloud SDK repo to your sources list:

    echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] \
    https://packages.cloud.google.com/apt cloud-sdk main" \
      | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
    

Install the Google Cloud CLI

Update the package index and install the SDK:

sudo apt-get update
sudo apt-get install -y google-cloud-cli

Wait for the installation to finish; you’ll now have access to gcloud, gsutil, and other SDK components.


Authenticate and Configure gcloud

Run the initialization wizard:

gcloud init

Follow these steps:

  1. Select or create a configuration (press Enter for [default]).
  2. Choose an account:
    [1] [email protected]
    [2] Log in with a new account
    Enter your choice: 2
    
  3. Approve usage of a personal account (Y).
  4. Authorize:
    • Copy the URL shown in your terminal.
    • Open it in an incognito/private browser window.
    • Sign in with your Google credentials.
    • Grant permissions and copy the authorization code.
  5. Paste the code back into the terminal.
  6. Select your project ID:
    Pick cloud project to use:
    [1] your-project-id
    
  7. (Optional) Set default region/zone now or skip.

Warning

Do not share your authorization code. Anyone with this code can access your Google Cloud resources.


Optional Configuration

Use these commands to set your default compute region and zone:

SettingCommand
Default Compute Regiongcloud config set compute/region YOUR_REGION
Default Compute Zonegcloud config set compute/zone YOUR_ZONE

You can always update these later with gcloud config set.


References

Watch Video

Watch video content

Previous
General Instructions GKE Playground