juju k8s-core 部署:等待 CNI 插件可用

juju k8s-core 部署:等待 CNI 插件可用

我正在努力安装 juju kubernetes-core charm

我已经设置了三个环境:

  • juju 控制器
  • juju add-cloud 手册
  • 增加了两个 Ubuntu 4 CPU 4GB RAM

然后我跑了:

juju deploy --dry-run cs:bundle/kubernetes-core-1340 --map-machines=existing,0=0,1=1

发现我卡在了“juju 状态”

Model    Controller  Cloud/Region      Version  SLA          Timestamp
default  k8s         k8scloud/default  2.9.10   unsupported  13:08:03+02:00

App                Version         Status   Scale  Charm              Store       Channel   Rev  OS      Message
containerd         go1.13.8        active       2  containerd         charmstore  edge      147  ubuntu  Container runtime available
easyrsa            3.0.1           active       1  easyrsa            charmstore  edge      396  ubuntu  Certificate Authority connected.
etcd               3.4.5           active       1  etcd               charmstore  edge      608  ubuntu  Healthy with 1 known peer
flannel                            error        2  flannel            charmstore  edge      572  ubuntu  hook failed: "install"
kubernetes-master  1.22.0-alpha.2  waiting      1  kubernetes-master  charmstore  edge     1035  ubuntu  Waiting for CNI plugins to become available
kubernetes-worker  1.22.0-alpha.2  waiting      1  kubernetes-worker  charmstore  edge      789  ubuntu  Waiting for cluster credentials.

Unit                  Workload  Agent  Machine  Public address  Ports     Message
easyrsa/0*            active    idle   0/lxd/0  10.156.136.137            Certificate Authority connected.
etcd/0*               active    idle   0        172.16.51.212   2379/tcp  Healthy with 1 known peer
kubernetes-master/0*  waiting   idle   0        172.16.51.212             **Waiting for CNI plugins to become available**
  containerd/1        active    idle            172.16.51.212             Container runtime available
  flannel/1           error     idle            172.16.51.212             hook failed: "install"
kubernetes-worker/0*  waiting   idle   1        172.16.51.213             Waiting for cluster credentials.
  containerd/0*       active    idle            172.16.51.213             Container runtime available
  flannel/0*          error     idle            172.16.51.213             hook failed: "install"

Machine  State    DNS             Inst id               Series  AZ  Message
0        started  172.16.51.212   manual:172.16.51.212  focal       Manually provisioned machine
0/lxd/0  started  10.156.136.137  juju-c9d9ed-0-lxd-0   focal       Container started
1        started  172.16.51.213   manual:172.16.51.213  focal       Manually provisioned machine

当我打开法兰绒日志时,我看到:

2021-08-06 10:29:20 ERROR unit.flannel/0.juju-log server.go:314 Hook error:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/__init__.py", line 71, in main
    bus.discover()
  File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 426, in discover
    _register_handlers_from_file(search_path, filepath)
  File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 466, in _register_handlers_from_file
    _load_module(root, filepath)
  File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 444, in _load_module
    return importlib.import_module(package + module)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
...skipping...
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/lib/juju/agents/unit-flannel-0/charm/hooks/relations/kubernetes-cni/provides.py", line 5, in <module>
    from charms.layer.kubernetes_common import kubeclientconfig_path
**ModuleNotFoundError: No module named 'charms.layer.kubernetes_common'**

2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60 Traceback (most recent call last):
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/charm/hooks/install", line 22, in <module>
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     main()
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/__init__.py", line 71, in main
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     bus.discover()
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 426, in discover
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     _register_handlers_from_file(search_path, filepath)
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 466, in _register_handlers_from_file   
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     _load_module(root, filepath)
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/.venv/lib/python3.8/site-packages/charms/reactive/bus.py", line 444, in _load_module
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     return importlib.import_module(package + module)
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     return _bootstrap._gcd_import(name[level:], package, level)
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap_external>", line 848, in exec_module
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60   File "/var/lib/juju/agents/unit-flannel-0/charm/hooks/relations/kubernetes-cni/provides.py", line 5, in <module>
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60     from charms.layer.kubernetes_common import kubeclientconfig_path
2021-08-06 10:54:52 WARNING unit.flannel/0.install logger.go:60 ModuleNotFoundError: No module named 'charms.layer.kubernetes_common'
2021-08-06 10:54:52 ERROR juju.worker.uniter.operation runhook.go:139 hook "install" (via explicit, bespoke hook script) failed: exit status 1
2021-08-06 10:54:52 INFO juju.worker.uniter resolver.go:144 awaiting error resolution for "install" hook
2021-08-06 10:59:52 INFO juju.worker.uniter resolver.go:144 awaiting error resolution for "install" hook
2021-08-06 10:59:52 INFO unit.flannel/0.juju-log server.go:314 Reactive main running for hook install
2021-08-06 10:59:52 ERROR unit.flannel/0.juju-log server.go:314 Hook error:

我不确定为什么该模块无法安装或者丢失。

答案1

我不是 k8s 专家,但似乎是在以下位置报告的一个错误:https://bugs.launchpad.net/charm-flannel/+bug/1938943

看来您正在使用Flannel charm并且它缺少该kubernetes_common层。

正如他们所说,如果您不需要特别解决方法,Launchpad 中Calicokubernetes_common您可以切换到的层吗?Calico charmFlannel

详细资料:https://ubuntu.com/kubernetes/docs/charm-calico

编辑:或者您可以添加layer:kubernetes-common层.yaml并建立魅力:)

相关内容