Kubernetes (“K8s”) provides a flexible architecture for cloud-native applications at scale. We believe that Juju is the simplest way to manage a multi-container workloads on K8s. This guide takes you through the registration steps necessary to connect the two systems.
What is Juju?: Juju is the simplest DevOps tool for managing digital services built with inter-related applications. If you are unfamiliar with Juju, then we recommend following our Getting Started with Juju tutorial.
Need a Kubernetes cluster for experimentation?: Install MicroK8s to create a local Kubernetes cluster with zero effort.
Running Kubernetes workloads
To run workloads on Kubernetes with Juju, a small number of registration steps are required:
- Obtain a Kubernetes cluster
- Register the cluster with Juju
- Create a Juju controller
- Register storage resources
You’re now ready to deploy cloud-native workloads with charms:
- Add a model
- Deploy workloads
Obtain a Kubernetes cluster
There are many ways to obtain a Kubernetes cluster. If you are unsure which option to choose, then you should install MicroK8s.
|Use Case||Recommended Action(s)|
|Local development, testing and experimentation||Install MicroK8s|
|Multi-node testing/production on own a private cloud||Install Charmed Kubernetes|
|Multi-node testing/production on the public cloud||Install Charmed Kubernetes with the relevant integrator charm|
|Use a hosted Kubernetes distribution||Enable the service via the provider|
Register the Kubernetes cluster with Juju
Registering the cluster with Juju is known as “adding a cloud” in Juju’s terminology. A cloud is a deployment target. The exact process to register the cluster depends on how your system is configured.
When running MicroK8s
The cluster is already registered. Feel free to move to the next section.
When you’re already able to interact with your cluster via
The registration process is a single command:
When you have used Juju to deploy Charmed Kubernetes
We can use Juju to extract its configuration file to save it locally with these commands:
mkdir ~/.kube juju scp kubernetes-master/0:/home/ubuntu/config ~/.kube/config juju add-k8s
Copy the cluster’s configuration file from the master node to your local machine and save it as
$HOME/.kube/config, then run
Create a Juju controller
The Juju controller is a central software agent that oversees applications managed with Juju. It is created via the
juju bootstrap command.
juju bootstrap <cloud-name> <controller-name>
Register storage resources
Registering storage is easy, but the exact process depends on where your Kubernetes is hosted. In most cases, no action is necessary.
When an application that you wish to deploy–your “workload” in Juju terms–makes uses of persistent storage, you may need to ensure that it has been added to your Kubernetes cluster.
Charmed Kubernetes users can use Juju to provide it with storage based on Ceph or NFS.
The model also has a default storage pool called “kubernetes”.
Add a model
Before deploying applications with charms, Juju users create a “model”. The model is a workspace for inter-related applications. It is an abstraction over applications, machines hosting them and other components such as persistent storage.
To add a model, use the
juju add-model command:
juju add-model <k8s-cloud-name>
Inside the cluster, adding a Juju model creates a Kubernetes namespace with the same name. The namespace hosts all of the pods and other resources, except global resources.
Deploy a Kubernetes charm
A Kubernetes-specific charm is deployed in standard fashion, with the
deploy command. If the charm has storage requirements you will need to specify them, as you do with a normal charm.
Juju charms can interact with the underlying cloud directly with the
juju trust command. This command delegates the security credentials used by the controller to the charms themselves.
- integrator charm
juju deploy aws-integrator juju trust aws-integrator
The below table lists configuration keys supported by Kubernetes charms that are set at deploy time. The corresponding Kubernetes meaning can be obtained from the Kubernetes documentation for Services and Ingress.
juju deploy mariadb-k8s --config kubernetes-service-loadbalancer-ip=10.1.1.1
There are two other keys that are not Kubernetes-specific:
Keys ‘juju-external-hostname’ and ‘juju-application-path’ control how the application is exposed externally using a Kubernetes Ingress Resource in conjunction with the configured ingress controller (default: nginx).
Tutorials and in-depth guides
The following practical guides are available:
- Tutorial Setting up static Kubernetes storage shows how to set up statically provisioned persistent volumes with Juju by way of the ‘kubernetes-core’ charm.
- Tutorial Multi-cloud controller with GKE and auto-configured storage provides steps on how to add an existing GKE-based Kubernetes cluster to an existing controller. It also covers storage auto-configuration.
- Tutorial Installing Kubernetes with CDK and using auto-configured storage shows how to install Kubernetes with the CDK bundle and illustrates storage class and storage pool auto-configuration.
- Tutorial Using Juju with MicroK8s provides steps for getting started with Juju and MicroK8s.
- Tutorial Using Juju on Charmed Kubernetes on VMWare provides the steps for getting started with Juju on a Kubernetes cluster on VMWare.
- Tutorial Using the aws-integrator charm demonstrates deploying Kubernetes with Juju on AWS with an integrator charm.