Google Kubernetes Engine (GKE)

Running through this guide will ensure that you’re ready to deploy and manage Kubernetes workloads on Google Kubernetes Engine (GKE) with Juju.
Juju provides built-in support for GKE. That means, once you’ve registered your cluster, you’ll be able to deploy workloads straight away.



Using Juju to drive Kubernetes workloads on GKE requires installing some pre-requisite software:

  • Juju client

  • Google Cloud SDK

  • Kubernetes client

Install the Juju client

You will need to install Juju. If you’re on Linux, we recommend using snap:

sudo snap install juju --classic

We also provide other installation methods as described on our detailed installation documentation.

Install the Google Cloud SDK

Installing the Google Cloud SDK is easiest via snap:

snap install google-cloud-sdk --classic

Instructions for other gcloud installation methods also also available.

Install the Kubernetes client

kubectl is the command-line client for directly interacting with a Kubernetes cluster. Visit the Kubernetes documentation for manual kubectl installation instructions.

Provision a Kubernetes cluster on GKE

You will need to have an GKE cluster available before Juju can connect to it. It’s easy to do that via the cloud console.

When creating the default node pool, ensure that you request a machine type that provides at least 6 GB memory. This provides sufficient resources to enable Juju to be deployed alongside your workloads. The default guided install on the GKE console for ‘my-first-cluster’ does not provide sufficient RAM unless you edit it.

The Google Cloud SDK will configure kubectl on your behalf via the gcloud container clusters get-credential command. Once executed, kubectl will be able to control your cluster directly.

Before getting the credentials, you need to login your Google Cloud account with:

gcloud auth login

And then get your credentials:

gcloud container clusters get-credentials <k8s-cluster> --zone <zone> --project <project>

Verify the kubectl setup

To check that you have configured kubectl correctly, execute a command:

kubectl get nodes

Connect Juju to your Kubernetes cluster

There are three distinct stages to configuring your GKE cluster for management with Juju:

  • Register the cluster as a Kubernetes cloud
  • Deploy a Juju controller to the cluster
  • Create a model to house your applications
  • Clean up the controller

Register the cluster as a Kubernetes cloud

In Juju’s vocabulary, a “cloud” is a space that can host deployed workloads. Juju will automatically detect locally configured Kubernetes contexts, see here for more information.

Alternatively to register a Kubernetes cluster with Juju, execute the juju add-k8s command. The <cloud> will be used by Juju to refer to the cluster later on.

juju add-k8s --gke <cloud>

This command is interactive and will request that you provide details of the cloud account, project and whether to register this on the current client only or an external controller.

Create a controller

Juju, as an active agent system, requires a controller to get started. Controllers are created with the juju bootstrap command that takes a cloud’s name and our intended name for the controller.

juju bootstrap <cloud>
(Optional) Specify a controller name

You can specify the name of your Juju controller if you wish:

juju bootstrap <cloud> <controller-name>

If you do not, Juju will generate the name using the name of the cloud.

Create a model

A model is a workspace for inter-related applications. They correspond (roughly) to a Kubernetes namespace. To create one, use juju add-model with a name of your choice:

juju add-model <model>

Clean up the controller

To cleanup a bootstrapped Juju controller the following can be run to have the Juju controller destroyed and cleaned up.

juju destroy-controller <controller-name>

Deploy workloads

You’re now able to deploy workloads into your model. Workloads are provided by charms (and sets of charms called bundles). You can find a list of Kubernetes charms on Charmhub!