Charmed MySQL K8s

Channel Revision Published Runs on
8.0/stable 127 22 Mar 2024
Ubuntu 22.04
8.0/candidate 150 Today
Ubuntu 22.04
8.0/beta 150 Today
Ubuntu 22.04
8.0/edge 150 Yesterday
Ubuntu 22.04
juju deploy mysql-k8s --channel 8.0/stable
Show information


Deploy Charmed MySQL K8s on GKE

Google Kubernetes Engine (GKE) - the most scalable and fully automated Kubernetes service from Google. To access GKE WEB interface, open

Install GKE and Juju tooling

Install juju and gcloud tool using SNAP:

> sudo snap install juju --classic
> sudo snap install kubectl --classic
> sudo snap install google-cloud-cli --classic

Login to Google Account

> gcloud auth login

Go to the following link in your browser:

Enter authorization code: 4/0Absad3s...

You are now logged in as [].

Now you need to associate this installation with GCloud project, using “Project ID” from resource-management:

> gcloud config set project <PROJECT_ID>

Updated property [core/project].

As a last step, install the Debian package google-cloud-sdk-gke-gcloud-auth-plugin using Google manual.

Create new GKE cluster

The following command will start three compute engines on Google Cloud (imagine them as three physical servers in clouds) and deploy K8s cluster there. To simplify the manual, the following command will use high-availability zone europe-west1 and compute engine type n1-standard-4 (which can be adopted for your needs if necessary):

gcloud container clusters create --zone europe-west1-c $USER-$RANDOM --cluster-version 1.25 --machine-type n1-standard-4 --num-nodes=3 --no-enable-autoupgrade

Now, let’s assign our account as an admin of newly created K8s:

kubectl create clusterrolebinding cluster-admin-binding-$USER --clusterrole=cluster-admin --user=$(gcloud config get-value core/account)

Bootstrap Juju on GKE

Bootstrap new juju controller on fresh cluster, copying commands one-by-one:

> juju add-k8s gke-jun-9 --storage=standard --client
> juju bootstrap gke-jun-9
> juju add-model welcome-model

At this stage Juju is ready to use GKE, check the list of currently running K8s pods and juju status:

> kubectl get pods -n welcome-model
> juju status

Deploy Charms

> juju deploy mysql-k8s-bundle --channel 8.0/edge --trust
> juju deploy mysql-test-app
> juju relate mysql-test-app mysql-k8s:database
> juju status --watch 1s


To list GKE clusters and juju clouds, use:

> gcloud container clusters list

mykola-18187  europe-west1-c  1.25.9-gke.2300  n1-standard-4  1.25.9-gke.2300  3          RUNNING
taurus-7485   europe-west1-c  1.25.9-gke.2300  n1-standard-4  1.25.9-gke.2300  3          RUNNING

Juju can handle multiply clouds simultaneously. The list of clouds with registered credentials on Juju:

> juju clouds
Clouds available on the controller:
Cloud      Regions  Default       Type
gke-jun-9  1        europe-west1  k8s  

Clouds available on the client:
Cloud           Regions  Default       Type  Credentials  Source    Description
gke-jun-9       1        europe-west1  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


Note: always clean no-longer necessary GKE resources as they all could be costly!!!

To clean GKE clusters and juju clouds, use:

> juju destroy-controller gke-jun-9-europe-west1 --yes --destroy-all-models --destroy-storage --force
> juju remove-cloud gke-jun-9

> gcloud container clusters list
> gcloud container clusters delete <cluster_name> --zone europe-west1-c

Revoke the GCloud user credentials:

> gcloud auth revoke

Revoked credentials:

Help improve this document in the forum (guidelines). Last updated 10 months ago.