salt/kubernetes setup

274 views
Skip to first unread message

SW

unread,
Dec 20, 2021, 5:01:02 AM12/20/21
to Salt-users
Hey guys, I'm desperately trying to get a salt master to talk to kubernetes. Unfortunately the communication with the kubernetes does not work, the following error message appears:
```
'kubernetes.nodes' is not available.
```
The config looks like this:
```
cat /etc/salt/minion
kubernetes.kubeconfig: '/etc/rancher/k3s/k3s.yaml'
kubernetes.context: 'default'
```
I read through the docs, I just can't get it to work.
Can you help here?

Greetings
Sam

Phipps, Thomas

unread,
Dec 20, 2021, 10:22:20 AM12/20/21
to salt-...@googlegroups.com
That error means the kubernetes module is not able to pass it's virltual function so will not load. looking at the dependencies do you have the kubernetes python library installed in the python that runs salt on the minion?

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/9960de98-502a-45a7-82fb-8519b1a38284n%40googlegroups.com.

SW

unread,
Dec 21, 2021, 3:02:30 AM12/21/21
to Salt-users
Yes i installed the kubernes python module via pip

SW

unread,
Dec 21, 2021, 3:02:38 AM12/21/21
to Salt-users
Yes, i installed the python module (pip3 install kubernetes)

whyt...@phipps.ninja schrieb am Montag, 20. Dezember 2021 um 16:22:20 UTC+1:

SW

unread,
Jan 20, 2022, 10:56:22 AM1/20/22
to Salt-users
The behavior can be easily reproduced:

```
workstation:~$ docker run -it --rm python:3.9 bash

root@de0bb9e2760b:/# pip install salt kubernetes
...
# add kubeconfig to here /etc/salt/kubeconfig
# start masterless salt-call
root@de0bb9e2760b:/# salt-call --local kubernetes.nodes kubeconfig=/etc/salt/kubeconfig context=default
'kubernetes.nodes' is not available.
```
When i create a namespace with a state and set kubernetes config in minion file then salt dont find the kubernetes module
```
root@8f546d7c8af6:/# salt-call --local state.apply k8s -l debug
local:
----------
          ID: sam
    Function: kubernetes.namespace_present
      Result: False
     Comment: State 'kubernetes.namespace_present' was not found in SLS 'k8s'
              Reason: 'kubernetes' __virtual__ returned False: kubernetes module could not be loaded
     Changes:  
```
The kubernetes module is present:
```
root@8f546d7c8af6:/# python
Python 3.9.9 (main, Dec 21 2021, 10:03:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import kubernetes
>>>
```
Any idea?

Phipps, Thomas

unread,
Jan 21, 2022, 3:31:17 AM1/21/22
to salt-...@googlegroups.com
when you use salt-call use -l debug with it to see the output of the debug logging. This will include module loading.

as for the kubernetes module. There is a laundry list of python modules that need to load. not just the first one.


however for the state to load the module needs to load so if the module isn't working the state definitely will not. troubleshoot the module before even looking at the state. 



Reply all
Reply to author
Forward
0 new messages