Managing Kubernetes clusters

With Cloud Code, you can create a Kubernetes cluster with Google Kubernetes Engine (GKE) or minikube. You can also work with a local cluster if you're using Docker Desktop.

Creating a GKE cluster and adding it to your KubeConfig

The Kubernetes section opens the Google Cloud console so that you can quickly create a cluster. To access the Kubernetes section and create a cluster, perform the following:

  1. Click Cloud Code icon Cloud Code and then expand the Kubernetes section.

  2. Click + Add a Cluster to the KubeConfig.

  3. Select Google Kubernetes Engine and then select Yes to enable container GCP API under your project.

  4. Choose Standard or Autopilot. For more information, see Comparing Autopilot and Standard modes.

  5. If prompted, click Open to permit Cloud Code to open the Cloud console.

  6. In Cloud console, choose any configuration options that you want to customize and then click Create.

  7. After the cluster is created, in VS Code, click Refresh Kubernetes cluster view Refresh.

  8. After the name of your new cluster appears in the list, click the cluster name. Your new cluster is added to the configuration and set as the default context.

Tip: To create a Kubernetes cluster using the Command Palette, launch the Command Palette (click Manage icon Manage > Command Palette or press Ctrl/Cmd+Shift+P) and then run the Cloud Code: Create GKE cluster command.

Cloud Code opens the Google Cloud console so that you can quickly create a cluster:

  1. To open the Kubernetes Explorer, click Kubernetes explorer button in IntelliJ Kubernetes Explorer or navigate to Tools > Cloud Code > Kubernetes > View Cluster Explorer.

  2. In the header of the Kubernetes Explorer pane, click + Add GKE Cluster.

  3. Choose Create a new GKE Cluster.

  4. Choose Standard or Autopilot. For more information, see Comparing Autopilot and Standard modes

  5. If prompted, click Open to permit Cloud Code to open the Cloud console.

  6. In Cloud console, choose any configuration options that you want to customize and then click Create.

  7. After the cluster is created, in IntelliJ, click Kubernetes explorer button in IntelliJ Refresh.

  8. After the name of your new cluster appears in the list, click the cluster name. Your new cluster is added to the configuration and set as the default context.

Working with an existing GKE cluster

If you have an existing Standard or Autopilot GKE cluster, you can set it as your active cluster and work with it using Cloud Code.

  1. In the header of the expanded Kubernetes section, click + Add a Cluster to the KubeConfig.
  2. Click Google Kubernetes Engine.
  3. Click your cluster name. Your cluster is added to the KubeConfig.
  1. In the header of the Kubernetes Explorer pane, click + Add GKE Cluster.
  2. Click Google Kubernetes Engine.
  3. Click your cluster name. Your cluster is added to the KubeConfig.

Setting a cluster as the default context

The active cluster is the cluster that your application is deployed to by default.

In the expanded Kubernetes section, right-click a cluster and then click Set as Active Cluster.

The active cluster is the cluster that your application is deployed to by default.

In the Kubernetes Explorer, right-click a cluster and then click Set as Current Context.

Removing a cluster from your KubeConfig

After you remove a cluster from your KubeConfig, the cluster is not available to deploy to.

In the expanded Kubernetes section, right-click a cluster and then click Remove Context Under Cluster.

After you remove a cluster from your KubeConfig, the cluster is not available to deploy to.

In the Kubernetes Explorer, right-click a cluster and then click Remove From KubeConfig.

Starting a minikube cluster

  1. Click the minikube status bar.

    minikube status bar

  2. After the Choose a Minikube (cluster) profile to control option populates, click minikube and then click Start.

Pausing or stopping a minikube cluster

  1. Click the minikube status bar.

    minikube status bar

  2. After the Choose a Minikube (cluster) profile to control option populates, click minikube and then click Stop or Pause.

Opening an interactive terminal to a container

  1. In the expanded Kubernetes section, expand your minikube cluster, expand Pods, and then expand Containers.
  2. Right-click a container and then click Get Terminal.

Opening an external IP address

  1. In the expanded Kubernetes, expand your minikube cluster and then expand Services.
  2. Expand External IPs, right-click an IP address, and then click Open Address.
  3. Click Open.

Creating and adding a cluster from another cloud provider

If you're using an on-prem cluster or a cluster from another provider such as Azure or AWS, use the provider's tools to create the cluster and add it to your KubeConfig.

Working with local clusters

In addition to minikube, you can work with Cloud Code if you're using Docker Desktop (for Mac or Windows).

To get Cloud Code working with a local cluster, make sure that your default configuration (for example, ~/.kube/config) contains your local cluster. This cluster must be set as the current context.

For example, if you were using a local cluster, docker-for-desktop, with Docker Desktop, set your preferred cluster by running the following command:

kubectl config use-context docker-for-desktop

Getting support

To submit feedback or report an issue in your IntelliJ IDE, go to Tools > Cloud Code > Help / About > Submit feedback or report an issue to report an issue on GitHub, or ask a question on Stack Overflow.

You can also join the #cloud-code channel, which is part of the Google Cloud Slack community.