How to deploy on AKS¶
Azure Kubernetes Service (AKS) allows you to quickly deploy a production ready Kubernetes cluster in Azure.
AKS web interface: https://portal.azure.com/
Prerequisites¶
A physical or virtual machine running Ubuntu 24.04+
Juju 3.6+ installed via snap
Install AKS CLI tooling¶
Install the Azure CLI for Linux by following the official Azure documentation .
Install the kubectl CLI tools via snap:
user@host:~$ To check they are correctly installed, run
user@host:~$ azure-cli 2.65.0
core 2.65.0
telemetry 1.1.0
Dependencies:
msal 1.31.0
azure-mgmt-resource 23.1.1
...
Your CLI is up-to-date.
user@host:~$ Client Version: v1.28.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Authenticate¶
Login to your Azure account:
user@host:~$ Create a new AKS cluster¶
Export the deployment name for later use:
user@host:~$ Create a new Azure Resource Group in the region that best suits you:
user@host:~$ Create a new Kubernetes cluster on AKS with the following command (increase node count and size if necessary):
user@host:~$ {
"aadProfile": null,
"addonProfiles": null,
"agentPoolProfiles": [
{
"availabilityZones": null,
"capacityReservationGroupId": null,
"count": 1,
"creationData": null,
"currentOrchestratorVersion": "1.28.9",
"enableAutoScaling": false,
"enableEncryptionAtHost": false,
"enableFips": false,
"enableNodePublicIp": false,
...
Dump the new AKS credentials:
user@host:~$ ...
Merged "aks" as current context in ~/.kube/config
Bootstrap Juju on AKS¶
Bootstrap a Juju controller:
user@host:~$ Creating Juju controller "aks" on aks/<region-name>
Bootstrap to Kubernetes cluster identified as azure/<region-name>
Creating k8s resources for controller "controller-aks"
Downloading images
Starting controller pod
Bootstrap agent now started
Contacting Juju controller at 20.231.233.33 to verify accessibility...
Bootstrap complete, controller "aks" is now available in namespace "controller-aks"
Now you can run
juju add-model <model-name>
to create a new model to deploy k8s workloads.
See also: Juju | Microsoft Azure options
Deploy Charmed PostgreSQL on AKS¶
Create a Juju model:
user@host:~$ The following command deploys 3 nodes of PostgreSQL on Kubernetes:
user@host:~$ Deployed "postgresql-k8s" from charm-hub charm "postgresql-k8s", revision <number> in channel 16/stable on ubuntu@24.04/edge
Display deployment information¶
Display information about the current deployments with kubectl and az:
user@host:~$ Kubernetes control plane is running at https://aks-user-aks-aaaaa-bbbbb.hcp.<region-name>.azmk8s.io:443
CoreDNS is running at https://aks-user-aks-aaaaa-bbbbb.hcp.<region-name>.azmk8s.io:443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Metrics-server is running at https://aks-user-aks-aaaaa-bbbbb.hcp.<region-name>.azmk8s.io:443/api/v1/namespaces/kube-system/services/https:metrics-server:/proxy
user@host:~$ ...
"count": 1,
"currentOrchestratorVersion": "1.28.9",
"enableAutoScaling": false,
...
user@host:~$ NAME STATUS ROLES AGE VERSION
aks-nodepool1-31246187-vmss000000 Ready agent 11m v1.28.9
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:~$ List all services and then delete those that have an associated EXTERNAL-IP value (e.g. load balancers):
user@host:~$ (...)
user@host:~$ Next, delete the AKS resources:
user@host:~$ See also: Azure documentation | Delete all Azure resources
Finally, log out from AKS to clean the local credentials (to avoid forgetting and leaking):
user@host:~$