June 2020
Intermediate to advanced
410 pages
9h 52m
English
A Kubernetes cluster has multiple namespaces internally, and you can usually find the ones a cluster has with kubectl get namespaces. You can do the same with Ansible by creating a file called k8s-ns-show.yaml with the following content:
---- hosts: localhost tasks: - name: Get information from K8s k8s_info: api_version: v1 kind: Namespace register: ns - name: Print info debug: var: ns
We can now execute this, as follows:
$ ansible-playbook k8s-ns-show.yaml
You will now see information regarding the namespaces in the output.
Notice that in the seventh line of the code (kind: Namespace), we are specifying the type of resources we are interested in. You can specify other Kubernetes object types to ...