When the Kubernetes client is not installed, the import of
salt.modules.kubernetes will still succeed, but HAS_LIBS will be set to
False (since the library import will be covered by a try-except clause).
Therefore expect the salt.modules.kubernetes to always succeed and check
kubernetes.HAS_LIBS instead for the presence of the kubernetes library.
Signed-off-by: Benjamin Drung <benjamin.drung@profitbricks.com>
* Add 100% test coverage for the kubernetes.secret_present state
* Add 100% test coverage for the kubernetes.configmap_absent state
* Add 100% test coverage for the kubernetes.configmap_present state
* Make some fields optional to kubernetes.create_secret and add examples
* Make some fields optional to kubernetes.replace_secret and add examples
* Make some fields optional to kubernetes.create_configmap and add examples
* Make some fields optional to kubernetes.replace_configmap and add examples
* Add 'comment' when a kubernetes configmap or secret is going to be replaced
* Update 'source', 'template', and 'saltenv' kwargs to defaults from the rest of the codebase
* Allow passing empty 'data' to the kubernetes.configmap_present state to remove the existing contents
This allows commands such as `kubectl rollout history deploy/$FOO` to
automatically show the deployment changed as a result of the salt run
and follows exactly how kubectl works when passed the `--record` flag.
When the `client_key_file` attribute was defined and the `client_key`
attribute was not, the conditional for `client_key` would wrongly zero
`kubernetes.client.configuration.key_file`.
This was a bit annoying to figure out, but the kubernetes module now can
authenticate with minikube with a configuration such as this (where jeff
is $USER):
kubernetes.api_url: 'https://192.168.99.100:8443'
kubernetes.certificate-authority-file: '/home/jeff/.minikube/ca.crt'
kubernetes.client-certificate-file: '/home/jeff/.minikube/client.crt'
kubernetes.client-key-file: '/home/jeff/.minikube/client.key'
The various options can be gotten from ~/.kube/config after running `minikube start`.
This is a follow up of this PR: https://github.com/saltstack/salt/pull/43235
With the fix in PR 43235, we are polling the status of the deletion via
show_deployment. This is now also reflected in the tests with this change.