How to deploy on GKE¶
Google Kubernetes Engine (GKE) is a highly scalable and fully automated Kubernetes service.
GKE web interface: console.cloud.google.com/compute
Prerequisites¶
A physical or virtual machine running Ubuntu 24.04+
Juju 3.6+ installed via snap
Install GKE tooling¶
Install the Google Cloud command-line tools via snap:
user@host:~$ Install the kubectl CLI tools via snap:
user@host:~$ To check they are correctly installed, run
user@host:~$ Google Cloud SDK 474.0.0
...
user@host:~$ Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Authenticate¶
Log in to Google Cloud:
user@host:~$ This should open a page in your browser starting with https://accounts.google.com/o/oauth2/... where you can complete the login.
If successful, the command prompt will show:
You are now logged in as [<account>@gmail.com].
Configure project ID¶
Next, you must associate this installation with GCloud project using “Project ID” from resource-management :
user@host:~$ Updated property [core/project].
Install additional auth plugin¶
As a last step, install the Debian package google-cloud-sdk-gke-gcloud-auth-plugin using this official Google Cloud documentation .
Create a new GKE cluster¶
The following command will start three compute engines on Google Cloud and deploy a K8s cluster. You can imagine the compute engines as three physical servers in clouds.
user@host:~$ Next, assign your account as an admin of the newly created K8s cluster:
user@host:~$ Bootstrap Juju on GKE¶
Add a Juju K8s cloud:
user@host:~$ K8s credentials on Juju
This known issue forces non-snap Juju usage to add-k8s credentials on Juju.
Bootstrap a Juju controller:
user@host:~$ See also: Juju | Google GKE and Juju
Deploy charms¶
Create a Juju model (K8s namespace):
user@host:~$ At this stage, Juju is ready to use GKE. Check the list of currently running K8s pods with:
user@host:~$ The following commands deploy PostgreSQL and PgBouncer:
user@host:~$ user@host:~$ Display deployment information¶
To list GKE clusters:
user@host:~$ >NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION >NUM_NODES STATUS
>mykola-18187 <region-name>-c 1.25.9-gke.2300 31.210.22.127 <compute-engine> 1.25.9-gke.2300 3 >RUNNING
>taurus-7485 <region-name>-c 1.25.9-gke.2300 142.142.21.25 <compute-engine> 1.25.9-gke.2300 3 >RUNNING
Juju can handle multiple clouds simultaneously. To see a list of clouds with registered credentials on Juju, run:
user@host:~$ >Clouds available on the controller:
>Cloud Regions Default Type
><k8s-cloud-name> 1 <region-name> k8s
>
>Clouds available on the client:
>Cloud Regions Default Type Credentials Source Description
><k8s-cloud-name> 1 <region-name> k8s 1 local A Kubernetes Cluster
>localhost 1 localhost lxd 1 built-in LXD Container Hypervisor
>microk8s 0 k8s 1 built-in A local Kubernetes context
>
Clean up¶
Always clean cloud resources that are no longer necessary; they could be costly!
See all controllers in your machine with
user@host:~$ Controller Model User Access Cloud/Region Models Nodes HA Version
<controller-name> <model-name> admin superuser <cloud-name>/<region-name> 1 1 none 3.6.1
The following command will destroy the Juju controller and remove the cloud instance - meaning all your data will be permanently removed:
user@host:~$ To delete the Juju cloud, run
user@host:~$ To delete GKE clusters, run
user@host:~$ user@host:~$ Revoke the Google Cloud user credentials (you should see a confirmation output):
user@host:~$ >Revoked credentials:
>- <account>@gmail.com