Getting Started


How to write a statefuleset container with kuernetes charm. Can you help me to giving some documents or examples.


Juju automatically creates a k8s stateful set if your charm requires storage; otherwise a deployment controller is used to managed to pods. The stateful set allows the storage pv’s to be correctly re-attached to new pods which are spun up to replace existing pods. The creation of a stateful set or deployment controller is done automatically by Juju; it’s not something the charm author needs to worry about.

So, based on the above, the mariadb charm is an example of a charm which uses a stateful set; the gitlab charm will use a deployment controller.

There’s also this post on writing k8s charms in general.


If i want deploy pod on some kubernetes-worker with specific tag. How can i do it.


This post explains how you can do what you want:


I used a whole kubernetes built by kubespray. Can I create storage by “storage-class=microk8s-hostpath”. specially:

  1. how to create a hostpath type storage for high disk-IO requirements.
  2. how to create a storage on a distribute storage system(maybe ceph).


“hostpath” is a class of storage setup specifically by microk8s.
To create storage for any given k8s cluster, you need to use what’s supported by the underlying cloud or cluster itself as the storage class provisioner. Juju just uses what it’s told to - knowledge of the underlying k8s cluster is necessary to know how to set things up.

Jenkins-K8S Charm Summary/Feedback

The doc is broken where it describes bringing up CDK on AWS with the integrator charm, because there are no relations between worker, master or aws-integrator.


To add on, I believe the best practice is to use a bundle overlay when using an integrator charm. It is supposed to be a more robust way of doing it. There is a tutorial on using the AWS integrator charm in this way.


I corrected the original post. This is my final juju status --relations output if it helps anyone.



The post says optionally setup storage, but then the mariadb k8s charm requires storage. Doesn’t seem particularly options.

Also, I’m probably just looking in the wrong place but how do you provision storage that it can use on microk8s?


The doc was updated to match 2.5.1 which improves behaviour on microk8s by automatically using the out of the box hostpath storage built into microk8s. Unfortunately this was premature as 2.5.1 is not quite released. It’s close - we hope to have it out by the end of the week. It’s currently in the 2.5/candidate channel.

When microk8s is installed, the storage provisioner is not enabled by default. You run microk8s.enable storage dns to set things up to work with Juju. Also, microk8s.status shows the optional services which you may want to enable when using microk8s.


Alright so I did a snap switch and snap refresh and restarted microk8s.

It also has storage enabled. Same error. Do i need to rebootstrap or something?


Hmmm even tried removing microk8s and reinstalling and it’s not picking it up. Am I just missing a provisioning step or something, I went and reread that part of the doc.


@magicaltrout can you post the commands you ran and the error?


Here’s a recording:


@magicaltrout Juju 2.5.0 requires that the user set up a storage pool so that Juju knows how to provision storage for charm state (operator-storage). So in 2.5.0, after adding a model, you need to do this:

juju create-storage-pool operator-storage kubernetes storage-class=microk8s-hostpath

If you want to deploy a charm which requires storage for the workload, you’ll need a storage pool for that also, eg

juju create-storage-pool mariadb-storage kubernetes storage-class=microk8s-hostpath

When you deploy mariadb-k8s, you then use the storage pool:

juju deploy cs:~juju/mariadb-k8s --storage database=10M,mariadb-storage

Now, in Juju 2.5.1, it works better with microk8s by using the hostpath storage provisioner automatically. No need for the steps to create the storage pools (unless you want to customise things).

Refresh you Juju to use the 2.5/candidate snap and bootstrap again.

juju bootstrap lxd
microk8s.config | juju add-k8s k8stest
juju add-model test k8stest
juju deploy cs:~juju/mariadb-k8s


Channel candidate for juju is closed; temporarily forwarding to stable. < what does that mean?


You ran this command?
snap refresh juju --channel 2.5/candidate


Okay I give up trying to understand… I thought a clean removal and install would be better so I just threw it away and got my error, then refreshed and it works… FML :exploding_head:



Literally copied your command block verbatim…

Same error.