Google GKE now supported!


#1

You can now import a Google GKE cluster as a cloud into Juju and deploy workloads to it. This removes the need to first deploy a Kubernetes cluster using CDK or the kubernetes-core bundle.

The steps to set up require the use of gcloud to add the necessary credential information to the local kubeconfig file. Once that’s done, you just import the cluster into Juju using the juju add-k8s command and start deploying.

It’s a little convoluted right now - we’ll enhance the interactive juju add-cloud command to make this easier.

First, ensure gcloud is installed.

sudo snap install google-cloud-sdk --classic

Assuming you have created a running cluster for a project using the GKE dashboard, you can now import the credential information into kubeconfig using the following commands.

The attributes below can be obtained from the GKE dashboard:

<cluster> is the name of the cluster you want to import.
<zone> is the zone the cluster us running in.

gcloud config set container/use_client_certificate True
gcloud container clusters get-credentials <cluster-name> --zone <zone>

gcloud config set container/use_client_certificate False
gcloud container clusters get-credentials <cluster-name> --zone <zone>

kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user $(gcloud config get-value account) --user client

gcloud config set container/use_client_certificate True
gcloud container clusters get-credentials <cluster-name> --zone <zone>

Now that the kubeconfig file has been set up, you use juju add-k8s to import the cloud and credential information into Juju.

kubectl config view --raw | juju add-k8s k8stest --cluster-name=$(kubectl config current-context)

Your GKE cluster is now ready to use with Juju as a cloud called k8stest.

After adding a Kubernetes model, you’ll need to ensure a storage pool is set up for use by the application operators, as described here.

juju create-storage-pool operator-storage kubernetes storage-class=juju-operator-storage storage-provisioner=kubernetes.io/gce-pd parameters.type=pd-standard

And if you want to deploy a database or other charm requiring storage, you’ll need to create a storage pool for that as well, eg

juju create-storage-pool unit-storage kubernetes storage-class=juju-unit-storage storage-provisioner=kubernetes.io/gce-pd parameters.type=pd-standard


The Juju Show #41 - upgrading your Ubuntu infrastructure
#2

Following the instructions to setup operator storage:

juju create-storage-pool operator-storage kubernetes storage-class=juju-operator-storage storage- provisioner=kubernetes.io/gce-pd parameters.type=pd-standard

I get:

ERROR storage provider "kubernetes" not found (not found)

If anyone has any ideas please let me know.


#3

Ok - I figured it out. When I added the model, I just did:

juju add-model test-model

And not:

juju add-model test-model k8stest.

FWIW the link in the doc above about adding models does not actually talk about adding models.


#4

The wording was indeed a bit rubbish, I’ve made a correction.


Juju 2.5.0 Beta 1 Release Notes