community.kubernetes.k8s_info – Describe Kubernetes (K8s) objects¶
Note
This plugin is part of the community.kubernetes collection (version 1.1.1).
To install it use: ansible-galaxy collection install community.kubernetes
.
To use it in a playbook, specify: community.kubernetes.k8s_info
.
Synopsis¶
Use the OpenShift Python client to perform read operations on K8s objects.
Access to the full range of K8s APIs.
Authenticate using either a config file, certificates, password or token.
Supports check mode.
This module was called
k8s_facts
before Ansible 2.9. The usage did not change.
Note
This module has a corresponding action plugin.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.7
openshift >= 0.6
PyYAML >= 3.11
Parameters¶
Notes¶
Note
The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python
To avoid SSL certificate validation errors when
validate_certs
is True, the full certificate chain for the API server must be provided viaca_cert
or in the kubeconfig file.
Examples¶
- name: Get an existing Service object
community.kubernetes.k8s_info:
api_version: v1
kind: Service
name: web
namespace: testing
register: web_service
- name: Get a list of all service objects
community.kubernetes.k8s_info:
api_version: v1
kind: Service
namespace: testing
register: service_list
- name: Get a list of all pods from any namespace
community.kubernetes.k8s_info:
kind: Pod
register: pod_list
- name: Search for all Pods labelled app=web
community.kubernetes.k8s_info:
kind: Pod
label_selectors:
- app = web
- tier in (dev, test)
- name: Using vars while using label_selectors
community.kubernetes.k8s_info:
kind: Pod
label_selectors:
- "app = {{ app_label_web }}"
vars:
app_label_web: web
- name: Search for all running pods
community.kubernetes.k8s_info:
kind: Pod
field_selectors:
- status.phase=Running
- name: List custom objects created using CRD
community.kubernetes.k8s_info:
kind: MyCustomObject
api_version: "stable.example.com/v1"
- name: Wait till the Object is created
community.kubernetes.k8s_info:
kind: Pod
wait: yes
name: pod-not-yet-created
namespace: default
wait_sleep: 10
wait_timeout: 360
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Authors¶
Will Thames (@willthames)