Juju+microk8s: very weird behaviour
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Expired
|
Undecided
|
Unassigned |
Bug Description
Yesterday I installed microk8s to work with Juju following this tutorial:
https:/
and it all worked fine.
Today I noticed some very strange behaviour from Juju. When I called `juju status`, it would hang for a few minutes, before finally returning
```
ERROR cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
```
`juju controllers` worked fine, showing
```
Controller ...
localhost-localhost ...
microk8s-localhost* ...
```
however I could not `juju switch` to localhost, as I got the same error:
```
ERROR refreshing models cache: cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
```
I tried to do as the error suggested, but ironically, I could not run `juju clouds` to get the cloud name, because it gave the same error. So did trying to remove the k8s cloud.
I tried to run `juju update-k8s --client <k8s cloud name>` with several different cloud names, but kept getting errors. (I'm positive one of them was the actual cloud name).
The only command that gave me a useful error message was `juju bootstrap`:
```
ERROR Insufficient permissions to access MicroK8s.
You can either try again with sudo or add the user jordan to the 'microk8s' group:
sudo usermod -a -G microk8s jordan
sudo chown -f -R jordan ~/.kube
After this, reload the user groups either via a reboot or by running 'newgrp microk8s'.
```
`newgrp microk8s` didn't help, but opening another terminal window did. I tried to bootstrap a new LXD controller, but it hung on the `Running machine configuration script` step, and I had to kill it after 20 mins. Not sure if that is connected.
Anyway, I still have no idea what happened, and whether this is a bug with Juju, with microk8s, or something else. At the very least, the error messages could be improved, as it seems this was a problem with system permissions, and only `juju bootstrap` told me that, while the other commands gave misleading errors.
I can attest, I too have started using microk8s and juju for first time.. Setup `kubeflow` and it still runs fine.. but the juju client is giving these same errors reported by OP
```
$ juju models
cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
ERROR cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
$ juju controllers
Use --refresh option with this command to see the latest information.
Controller Model User Access Cloud/Region Models Nodes HA Version
localhost-localhost stonks-beta admin superuser localhost/localhost 4 9 none 2.9.22
microk8s-localhost* kubeflow admin superuser microk8s/localhost 2 1 - 2.9.22
$ juju update-k8s --client microk8s-localhost
ERROR cloud microk8s-localhost not found
$ juju models
cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
ERROR cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
$ juju status
ERROR cannot connect to k8s api server; try running 'juju update-k8s --client <k8s cloud name>'
```