Ansible with k8s-module example

Hi All,

Ansible k8s module ( https://docs.ansible.com/ansible/latest/modules/k8s_module.html#k8s-module ) have many environments like :

api_key ---- K8S_AUTH_API_KEY environment variable.
cert_file — K8S_AUTH_CERT_FILE environment variable.
context — K8S_AUTH_CONTEXT environment variable.
host — K8S_AUTH_HOST environment variable.
key_file — K8S_AUTH_HOST environment variable.
kubeconfig — K8S_AUTH_KUBECONFIG environment variable.
password — K8S_AUTH_PASSWORD environment variable.
ssl_ca_cert — K8S_AUTH_SSL_CA_CERT environment variable.
username ---- K8S_AUTH_USERNAME environment variable.
verify_ssl ---- K8S_AUTH_VERIFY_SSL environment variable.

Do any body use these environmental variables in the playbook ? Do have any example or sample playbook with one or many environment variable. I’m looking very specially for kubeconfig — K8S_AUTH_KUBECONFIG environment variable to use it in ansible playbooks ( and also in Ansible AWX )

Please help.

  • module authors for some sights and help :slight_smile:

Yes, I've used K8S_AUTH_KUBECONFIG and K8S_AUTH_CONTEXT

K8S_AUTH_KUBECONFIG=~/.kube/another_kube_config ansible-playbook kubernetes.yml
K8S_AUTH_CONTEXT=minikube ansible-playbook do_something_with_minikube.yml

There was an issue with early 2.7 Ansible that you needed to set both variables but that was fixed with https://github.com/ansible/ansible/pull/47496 which seems to be in 2.7.1 according to git tag --contains

Will

Thanks Will. Appreciate your help on this.

Thanks.

Regards,
kylix3511

Email : kylix3511@gmail.com