Configuring Ansible for Kubernetes
Ansible can communicate with Kubernetes clusters using the Kubernetes Python libraries or directly via the Kubernetes API, as shown in Figure 11.3:
Figure 11.3 – Communication between Ansible and Kubernetes
Ansible modules and plugins for managing Kubernetes are available in the kubernetes.core
Ansible collection. (The Ansible Kubernetes collection was released as community.kubernetes
prior to the release of kubernetes.core
1.1.) We will install, configure, and use the kubernetes.core
collection in the following sections.
Python requirements
To communicate with the Kubernetes or OpenShift API, use the Python client for the OpenShift API (https://github.com/openshift/openshift-restclient-python) Python library. Before using any of the Kubernetes modules, you need to install the required Python libraries, as follows:
$ pip install openshift $ pip install PyYAML
If you are using Ansible inside a Python virtual...