Cluster Management

How to Manage Your Cluster #

Login via service account #

gcloud auth activate-service-account --key-file=<path-to-service-account-json>

View Clusters #

gcloud container clusters list

gcloud container clusters describe [CLUSTER_NAME]

Set default cluster #

gcloud config set container/cluster [CLUSTER_NAME]

View Current contect for kubectl #

kubectl config current-context

View Kubeconfig #

kubectl config view

Login to a cluster via kubeconfig #

gcloud container clusters get-credentials [CLUSTER_NAME]

Enable Stackdriver Logging #

When you create a cluster, the –enable-cloud-logging flag is automatically set, which enables Stackdriver Logging in the cluster. To disable this default behavior, set the –no-enable-cloud-logging flag.

  • For existing cluster

gcloud container clusters update [CLUSTER_NAME] --logging-service logging.googleapis.com

Enabling Stackdriver Monitoring #

When you create a cluster, the –enable-cloud-monitoring flag is automatically set, which enables Stackdriver Monitoring in the cluster.

To disable this default behavior, set the –no-enable-cloud-monitoring flag.

  • For existing cluster

gcloud beta container clusters update [CLUSTER_NAME] --monitoring-service monitoring.googleapis.com

Cluster Labeling #

gcloud container clusters create [CLUSTER_NAME] --labels [KEY]=[VALUE]
gcloud container clusters create example-cluster --labels env=dev
  • For existing clusters
gcloud container clusters update [CLUSTER_NAME] --update-labels [KEY]=[VALUE]
gcloud container clusters update example-cluster --update-labels env=dev,release=stable