Kubernetes and OpenShift Guide¶
Modules for interacting with the Kubernetes (K8s) and OpenShift API are under development, and can be used in preview mode. To use them, review the requirements, and then follow the installation and use instructions.
To use the modules, you’ll need the following:
Installation and use¶
The Kubernetes modules are part of the Ansible Kubernetes collection.
To install the collection, run the following:
$ ansible-galaxy collection install community.kubernetes
Next, include it in a playbook, as follows:
--- - hosts: localhost tasks: - name: Create a pod community.kubernetes.k8s: state: present definition: apiVersion: v1 kind: Pod metadata: name: "utilitypod-1" namespace: default labels: app: galaxy spec: containers: - name: utilitypod image: busybox
Authenticating with the API¶
By default the OpenShift Rest Client will look for
~/.kube/config, and if found, connect using the active context. You can override the location of the file using the``kubeconfig`` parameter, and the context, using the
Basic authentication is also supported using the
password options. You can override the URL using the
host parameter. Certificate authentication works through the
key_file parameters, and for token authentication, use the
To disable SSL certificate verification, set
verify_ssl to false.