microk8s: command not found after install

sudo snap install microk8s --classic --channel=1.18/stable microk8s (1.18/stable) v1.18.0 from Canonical✓ installed

sudo microk8s status --wait-ready Traceback (most recent call last): File “/snap/microk8s/1319/scripts/wrappers/status.py”, line 149, in <module> available_addons = get_available_addons(get_current_arch()) File “/snap/microk8s/1319/scripts/wrappers/common/utils.py”, line 113, in get_available_addons addons = yaml.load(file, Loader=yaml.FullLoader) AttributeError: module ‘yaml’ has no attribute ‘FullLoader’

lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic

uname -r 4.15.0-91-generic

microk8s
zsh: command not found: microk8s

snap services show services are running, snap logs for each of them, I not do see errors except flannelId, pasted below

snap services
Service Startup Current Notes microk8s.daemon-apiserver enabled active - microk8s.daemon-apiserver-kicker enabled active - microk8s.daemon-cluster-agent enabled active - microk8s.daemon-containerd enabled active - microk8s.daemon-controller-manager enabled active - microk8s.daemon-etcd enabled active - microk8s.daemon-flanneld enabled active - microk8s.daemon-kubelet enabled active - microk8s.daemon-proxy enabled active - microk8s.daemon-scheduler enabled active -

sudo snap logs microk8s.daemon-flanneld          
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.342266   16703 main.go:386] Found network config - Backend type: vxlan
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.342416   16703 vxlan.go:120] VXLAN config: VNI=1 Port=0 GBP=false DirectRouting=false
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.389635   16703 local_manager.go:234] Picking subnet in range 10.1.1.0 ... 10.1.255.0
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.393006   16703 local_manager.go:220] Allocated lease (10.1.43.0/24) to current node (192.168.1.124)
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.405622   16703 main.go:317] Wrote subnet file to /var/snap/microk8s/common/run/flannel/subnet.env
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.406204   16703 main.go:321] Running backend.
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.406456   16703 vxlan_network.go:60] watching for new subnet leases
2020-04-04T12:05:01Z microk8s.daemon-flanneld[16703]: I0404 20:05:01.409745   16703 main.go:429] Waiting for 22h59m59.981316306s to renew lease
2020-04-04T12:05:10Z microk8s.daemon-flanneld[16703]: E0404 20:05:10.901030   16703 **watch.go:43] Watch subnets: client: etcd cluster is unavailable or misconfigured; error #0: unexpected EOF
2020-04-04T12:05:10Z microk8s.daemon-flanneld[16703]: E0404 20:05:10.901030   16703 watch.go:171] Subnet watch failed: client: etcd cluster is unavailable or misconfigured; error #0: unexpected EOF**

journalctl logs grep flannel and etcd

Apr 04 20:05:22    microk8s.daemon-apiserver[18786]: + exec /snap/microk8s/1319/kube-apiserver --cert-dir=/var/snap/microk8s/1319/certs --service-cluster-ip-range=10.152.183.0/24 --authorization-mode=AlwaysAllow --basic-auth-file=/var/snap/microk8s/1319/credentials/basic_auth.csv --service-account-key-file=/var/snap/microk8s/1319/certs/serviceaccount.key --client-ca-file=/var/snap/microk8s/1319/certs/ca.crt --tls-cert-file=/var/snap/microk8s/1319/certs/server.crt --tls-private-key-file=/var/snap/microk8s/1319/certs/server.key --kubelet-client-certificate=/var/snap/microk8s/1319/certs/server.crt --kubelet-client-key=/var/snap/microk8s/1319/certs/server.key --secure-port=16443 --token-auth-file=/var/snap/microk8s/1319/credentials/known_tokens.csv --token-auth-file=/var/snap/microk8s/1319/credentials/known_tokens.csv --etcd-servers=https://127.0.0.1:12379 --etcd-cafile=/var/snap/microk8s/1319/certs/ca.crt --etcd-certfile=/var/snap/microk8s/1319/certs/server.crt --etcd-keyfile=/var/snap/microk8s/1319/certs/server.key --insecure-port=0 --requestheader-client-ca-file=/var/snap/microk8s/1319/certs/front-proxy-ca.crt --requestheader-allowed-names=front-proxy-client --requestheader-extra-headers-prefix=X-Remote-Extra- --requestheader-group-headers=X-Remote-Group --requestheader-username-headers=X-Remote-User --proxy-client-cert-file=/var/snap/microk8s/1319/certs/front-proxy-client.crt --proxy-client-key-file=/var/snap/microk8s/1319/certs/front-proxy-client.key
Apr 04 20:15:25    etcd[18380]: store.index: compact 768
Apr 04 20:15:25    etcd[18380]: finished scheduled compaction at 768 (took 2.587079ms)
Apr 04 20:17:35    microk8s.daemon-apiserver[18786]: W0404 20:17:35.938620   18786 watcher.go:199] watch chan error: etcdserver: mvcc: required revision has been compacted
Apr 04 20:20:25    etcd[18380]: store.index: compact 1424
Apr 04 20:20:25    etcd[18380]: finished scheduled compaction at 1424 (took 2.938123ms)



Apr 04 20:05:22    microk8s.daemon-kubelet[18841]: ++ jq .Network /var/snap/microk8s/1319/args/flannel-network-mgr-config

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 23 (8 by maintainers)

Most upvoted comments

Hey @sweetpotatoz

I have the same problem (probably), Parrot OS (Debian based) here. Maybe little bit different. I haven’t added /snap/bin to the PATH. But when I added my output not it’s showing this. So when I do export in new session:

export PATH=$PATH:/snap/bin

I can work with microk8s. $ microk8s (…)

My question is: Do you have in new sessions /snap/bin in your PATH? If not this is the problem.

I’ve faced the same error and figured out that python uses user defined site-packages:

$ /snap/microk8s/current/usr/bin/python3 -m site
sys.path = [
    '/home/user',
    '/snap/microk8s/current/usr/lib/python35.zip',
    '/snap/microk8s/current/usr/lib/python3.5',
    '/snap/microk8s/current/usr/lib/python3.5/plat-x86_64-linux-gnu',
    '/snap/microk8s/current/usr/lib/python3.5/lib-dynload',
    '/home/user/.local/lib/python3.5/site-packages',
    '/snap/microk8s/current/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.5/site-packages' (exists)
ENABLE_USER_SITE: True

In my case PyYAML package in /home/user/.local/lib/python3.5/site-packages has version 3.11 and an output of python says the same:

$ /snap/microk8s/current/usr/bin/python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.11'

After deleting a directory /home/user/.local/lib/python3.5/site-packages (I have no python 3.5 anymore) I have next site-packages:

$ /snap/microk8s/current/usr/bin/python3 -m site
sys.path = [
    '/home/user',
    '/snap/microk8s/current/usr/lib/python35.zip',
    '/snap/microk8s/current/usr/lib/python3.5',
    '/snap/microk8s/current/usr/lib/python3.5/plat-x86_64-linux-gnu',
    '/snap/microk8s/current/usr/lib/python3.5/lib-dynload',
    '/snap/microk8s/current/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.5/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

After that microk8s starts to work:

$ microk8s status
microk8s is running
addons:
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
helm3: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metallb: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled

Is it possible to disable ENABLE_USER_SITE for snap microk8s (environment variable PYTHONNOUSERSITE=false)?

thanks @realmfoo snap has its own python 😕 i went in here /home/user/.local/lib/python3.5/site-packages and delete rm -rf yaml and the yaml error has gone.

I’ve faced the same error and figured out that python uses user defined site-packages:

$ /snap/microk8s/current/usr/bin/python3 -m site
sys.path = [
    '/home/user',
    '/snap/microk8s/current/usr/lib/python35.zip',
    '/snap/microk8s/current/usr/lib/python3.5',
    '/snap/microk8s/current/usr/lib/python3.5/plat-x86_64-linux-gnu',
    '/snap/microk8s/current/usr/lib/python3.5/lib-dynload',
    '/home/user/.local/lib/python3.5/site-packages',
    '/snap/microk8s/current/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.5/site-packages' (exists)
ENABLE_USER_SITE: True

In my case PyYAML package in /home/user/.local/lib/python3.5/site-packages has version 3.11 and an output of python says the same:

$ /snap/microk8s/current/usr/bin/python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> yaml.__version__
'3.11'

After deleting a directory /home/user/.local/lib/python3.5/site-packages (I have no python 3.5 anymore) I have next site-packages:

$ /snap/microk8s/current/usr/bin/python3 -m site
sys.path = [
    '/home/user',
    '/snap/microk8s/current/usr/lib/python35.zip',
    '/snap/microk8s/current/usr/lib/python3.5',
    '/snap/microk8s/current/usr/lib/python3.5/plat-x86_64-linux-gnu',
    '/snap/microk8s/current/usr/lib/python3.5/lib-dynload',
    '/snap/microk8s/current/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.5/site-packages' (doesn't exist)
ENABLE_USER_SITE: True

After that microk8s starts to work:

$ microk8s status
microk8s is running
addons:
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
helm3: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metallb: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled

Is it possible to disable ENABLE_USER_SITE for snap microk8s (environment variable PYTHONNOUSERSITE=false)?

Hey @sweetpotatoz

I have the same problem (probably), Parrot OS (Debian based) here. Maybe little bit different. I haven’t added /snap/bin to the PATH. But when I added my output not it’s showing this. So when I do export in new session:

export PATH=$PATH:/snap/bin

I can work with microk8s. $ microk8s (…)

My question is: Do you have in new sessions /snap/bin in your PATH? If not this is the problem.

yeah it has been added to .zshrc (also added some fix in zprofile, apparently there is some issue with zsh and snap) and shown up in the $PATH now, i no longer have command not found issue except the yaml error.

Try the kubectl coming with MicroK8s, sudo microk8s.kubect version.

sudo microk8s.kubectl version

Client Version: version.Info{Major:“1”, Minor:“18”, GitVersion:“v1.18.0”, GitCommit:“9e991415386e4cf155a24b1da15becaa390438d8”, GitTreeState:“clean”, BuildDate:“2020-03-25T14:58:59Z”, GoVersion:“go1.13.8”, Compiler:“gc”, Platform:“linux/amd64”} Server Version: version.Info{Major:“1”, Minor:“18”, GitVersion:“v1.18.0”, GitCommit:“9e991415386e4cf155a24b1da15becaa390438d8”, GitTreeState:“clean”, BuildDate:“2020-03-25T14:50:46Z”, GoVersion:“go1.13.8”, Compiler:“gc”, Platform:“linux/amd64”}

But I still need sudo, even after I added my user to microk8s group?

sudo usermod -a -G microk8s <myuserid>