The MicroK8s cloud and Juju

List of supported clouds > MicroK8s

This document describes details specific to using your existing MicroK8s cloud with Juju.

See more: MicroK8s

When using the MicroK8s cloud with Juju, it is important to keep in mind that it is a (1) Kubernetes cloud and (2) not some other cloud.

See more: Cloud differences in Juju

As the differences related to (1) are already documented generically in our Tutorial, How-to guides, and Reference docs, here we record just those that follow from (2).

Juju points of variation Notes for the MicroK8s cloud
setup (chronological order):
CLOUD
supported versions: TBA
requirements: The dns and hostpath-storage must be enabled.
definition: Cf. kubeconfig file. :information_source: Juju automatically defines a local cloud of this type.
- name: microk8s or user-defined
- type: k8s
- authentication types: [oauth2, clientcertificate, userpass]
- regions: [TO BE ADDED]
- cloud-specific model configuration keys: operator-storage (string) Sets the storage class used to provision operator storage.

workload-storage (string) Sets the preferred storage class used to provision the workload storage.

CREDENTIAL
definition: Cf. kubeconfig file.

If you are an admin Juju user and your cloud is a local MicroK8s cloud: Juju retrieves your credential definition automatically. Run juju credentials to confirm. (Pre-defined credential name in Juju: microk8s.)

auth-type: [certificate, clientcertificate, oauth2, oauth2withcert, userpass].

CONTROLLER
notes on bootstrap: ā€“
other (alphabetical order:)
CONFIGURATION (model)
cloud-specific: TBA
CONSTRAINT Not applicable.
PLACEMENT DIRECTIVE
<machine> TBA
subnet=... :x:
system-id=... :x:
zone=... TBA
MACHINE
RESOURCE (cloud)

Consistent naming, tagging, and the ability to add user-controlled tags to created instances.

:x:

Thereā€™s an open bug which results in the microk8s installation failing. microk8s needs to be installed before juju and the user has to be in the microk8s group before installing juju or else the installation will fail.

See: Bug #1881769 ā€œSnap installation of microk8s fails when juju snap...ā€ : Bugs : juju

Thanks for mentioning this @sesopenko. Iā€™ve swapped the order around to make it clear that MicroK8s should be installed before Juju.

It also ran out of memory when trying to bootstrap it in a VM with only 4GB. Some minimum system requirements for microk8s with juju together would be helpful.

Nothing else refers to setting up such a storage pool (and indeed the charm deploys without having explicitly done so) - is this a holdover from a previous version somewhere?

Likely, yes. Iā€™ll look into it.

1 Like

This is quite unfortunate. 4GB RAM is the recommended minimum currently, I believe. Iā€™ve encountered issues at this size on another cluster before because Kubernetes was unable to deploy some background services alongside the Juju controllerā€¦ The controller pod was deemed ā€œunplaceableā€.

It seems the videos are not found now. I guess the videos are still there somewhere, itā€™s just the links are not working now.
So I just removed them for now but we can bring them back anytime when we fixed the links.

hi @pedroleaoc do you have any ideas of how to fix those links?

Cheers
Kelvin

How to use MicroK8s with Juju says:

Add your account to the microk8s group. This grants the account elevated privileges to the cluster, meaning that sudo will not be required to interact with microk8s:

sudo usermod -a -G microk8s $USER

This is not enough. You need to also run:

sudo chown -f -R $USER ~/.kube

This is stated in the microk8s installation instructions (MicroK8s - Get started) as well.

a suggestion for the next refresh: enabling the storage add-on brings now a warning that storage is deprecated and hostpath-storage should be used instead

It seems very odd that weā€™re not suggesting/recommending that people install the ingress add-on here. Without it you wonā€™t have any kind of ingress controller configured so many http workloads wonā€™t be reachable without hitting the pod IP and port directly (or service port and IP), which seems less than ideal.

Could we add that in?

Got this today while running this howto :

$ juju bootstrap microk8s micro                                                                                                 
Since Juju 3 is being run for the first time, it has downloaded the latest public cloud information.
ERROR "/var/snap/juju/21122/microk8s/credentials/client.config" does not exist: juju "3.0.0" can only work with strictly confined microk8s

$ snap list
Name        Version       Rev    Tracking       Publisher   Notes
[...]
juju        3.0.0         21122  latest/stable  canonicalāœ“  -
microk8s    v1.25.4       4221   1.25/stable    canonicalāœ“  classic

Refreshing the juju snap to 2.9/stable worked.

Microk8s no longer wants us to do that:

WARNING: Do not enable or disable multiple addons in one command.
         This form of chained operations on addons will be DEPRECATED in the future.
         Please, enable one addon at a time: 'microk8s enable <addon>'

results in

Warning: flag --classic ignored for strictly confined snap juju

Results in

ERROR "/var/snap/juju/23354/microk8s/credentials/client.config" does not exist: juju "3.1.5" can only work with strictly confined microk8s

I am facing the exact same issue. Any solution?

Edit: recent change in the doc solved the problem. It was a matter of version of microk8s.

You can work around this by manually adding the cluster to Juju:

$ sudo microk8s config | juju add-k8s my-k8s --client

k8s substrate "microk8s/localhost" added as cloud "my-k8s".
You can now bootstrap to this cloud by running 'juju bootstrap my-k8s'.

$ juju bootstrap my-k8s uk8sx
Creating Juju controller "uk8sx" on my-k8s/localhost
Bootstrap to Kubernetes cluster identified as microk8s/localhost
Creating k8s resources for controller "controller-uk8sx"
Downloading images
Starting controller pod
Bootstrap agent now started
Contacting Juju controller at 10.152.183.170 to verify accessibility...

Bootstrap complete, controller "uk8sx" is now available in namespace "controller-uk8sx"

Now you can run
        juju add-model <model-name>
to create a new model to deploy k8s workloads.

Iā€™m not really sure why it says that it doesnā€™t support it when it in reality does, just with a different command.