Juju with 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.
This page covers the following topics:
- Installing prerequisite software
- Provisioning a Google Kubernetes Engine cluster
- Connecting Juju to your Kubernetes cluster
- Deploy workloads
Using Juju to drive Kubernetes workloads on GKE requires installing some pre-requisite software:
A. Juju client
A. Juju client
You will need to install Juju. If you’re on Linux, we recommend using
sudo snap install juju --classic
We also provide other installation methods as described on our detailed installation documentation.
B. 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.
C. Kubernetes client
kubectl is the command-line client for directly interacting with a Kubernetes cluster. Visit the Kubernetes documentation for manual
kubectl installation instructions.
2. Provision a Kubernetes cluster on Google Kubernetes Engine
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.
Linking the cluster to the local environment
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 `kubectl` setup
To check that you have configured
kubectl correctly, execute a command:
kubectl get nodes
3. Connecting Juju to your Kubernetes cluster
There are three distinct stages to configuring your GKE cluster for management with Juju:
A. Register the cluster as a "K8s 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.
B. 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.
C. 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>
D. Cleanup 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>
4. 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!
Last updated a month ago.