Skip to content

Latest commit

 

History

History
83 lines (56 loc) · 1.43 KB

File metadata and controls

83 lines (56 loc) · 1.43 KB

Connecting to a GKE Cluster

Prerequisites

1. gcloud CLI

# macOS
brew install google-cloud-sdk

# verify
gcloud version

2. GKE auth plugin

gcloud components install gke-gcloud-auth-plugin --quiet

# verify
gke-gcloud-auth-plugin --version

3. kubectl

brew install kubectl

Authenticate

gcloud auth login
gcloud auth application-default login --project=<PROJECT_ID>

Connect to cluster

gcloud container clusters get-credentials <CLUSTER_NAME> \
  --region=<REGION> \
  --project=<PROJECT_ID>

Example with the test cluster:

gcloud container clusters get-credentials n-gke-test-01 \
  --region=us-central1 \
  --project=nuon-gcp-support

Verify

kubectl cluster-info
kubectl get namespaces
kubectl get nodes

Note: GKE Autopilot clusters show no nodes until pods are scheduled.

Troubleshooting

gke-gcloud-auth-plugin not found

gcloud components install gke-gcloud-auth-plugin --quiet

If installed via brew instead of gcloud installer:

export USE_GKE_GCLOUD_AUTH_PLUGIN=True

Unable to connect to the server

Check that cluster_endpoint_public_access = true in the terraform config, or that your IP is in master_authorized_networks.

Forbidden errors

Your Google account needs IAM permissions on the project. Ask for roles/container.developer or roles/container.admin on the GCP project.