Skip to main content
In this hands-on tutorial, you will:
  • Provision a private Google Kubernetes Engine (GKE) cluster with no external node IPs
  • Explore how private endpoints restrict API access
  • Attempt to authorize an external IP and observe the limitation
  • Create a public-endpoint cluster with Master Authorized Networks for controlled external access
Prerequisites
  • A Google Cloud project (set via gcloud config set project [PROJECT_ID])
  • Cloud Shell
  • gcloud CLI installed
Verify your active project:
The image contains the text "Demo: Creating a Private Cluster" on a plain white background, with a copyright notice for KodeKloud.

1. Set Your Compute Zone

Configure your default zone to us-west1-a:

2. Create a Private-Endpoint Cluster

We’ll build a VPC-native cluster called gke-deep-dive with:
Cluster provisioning may take 10–15 minutes.
You can monitor progress in the Cloud Console or via gcloud container operations list.

3. Verify the Private Cluster Configuration

Inspect the cluster to confirm private nodes and endpoint settings:
Look for:
GKE still creates a public endpoint for Google-managed operations, but by default it is not accessible from outside the VPC.

4. Try Authorizing an External IP

Fetch your Cloud Shell VM’s public IP and attempt to whitelist it:
You will receive:
Private-endpoint clusters only accept reserved VPC networks for API access.
External public IPs cannot be added to master authorized networks in this configuration.

5. Create a Public-Endpoint Cluster with Master Authorized Networks

To allow restricted external API access, we’ll spin up gke-deep-dive-public:
This cluster also takes 10–15 minutes to provision.

5.1 Authorize Your External IP

Retrieve your IP again and whitelist it for the new cluster:

5.2 Confirm Master Authorized Networks

Run:
You should see:

6. Access Your Public-Endpoint Cluster

Configure kubectl and list nodes:
You should see one node in the READY state.

7. Compare Your Clusters

List all clusters in the zone:

References

Watch Video