Skip to main content
In this guide, you’ll learn how to install the Kubernetes CLI (kubectl), set up the GKE authentication plugin, and configure access to your Google Kubernetes Engine (GKE) cluster. By the end, you’ll verify your setup and deploy a sample Nginx application.

Prerequisites

  • A Google Cloud project with GKE API enabled.
  • gcloud CLI installed and authenticated (gcloud init).
  • A GKE cluster created (e.g., name: gke-deep-dive, region/zone: us-west1).

1. Install or Verify kubectl

If you’re using Google Cloud Shell, kubectl comes pre-installed. You can skip directly to verifying its version.
Update your package list and install kubectl:
Confirm the installation:
Example output:

2. Install the GKE Authentication Plugin

GKE clusters require gke-gcloud-auth-plugin to retrieve authentication tokens for kubectl. Choose one of the methods below:
If you see
switch to Method B.
Verify the plugin installation:
Sample output:

3. Configure GKE Cluster Credentials

Fetch and merge your cluster’s credentials into your local kubeconfig:
This updates ~/.kube/config with the cluster’s API endpoint, certificates, and user context.

4. Verify kubectl Configuration

4.1 List All Namespaces

Expected output:

4.2 Inspect Full Kubeconfig

A typical snippet:
Your context and cluster names are prefixed with your project and location. Use these exact identifiers with flags like --cluster or --context.

5. Deploy a Sample Nginx Application

Run an Nginx pod using the Google Cloud Marketplace image:
Check the pod status:
You should see:
Congratulations! You’ve successfully installed kubectl, configured GKE authentication, and deployed your first application.

Watch Video