From the course: Ansible: From Basics to Guru by Pearson

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Writing a playbook to create a Kubernetes cluster

Writing a playbook to create a Kubernetes cluster - Ansible Tutorial

From the course: Ansible: From Basics to Guru by Pearson

Writing a playbook to create a Kubernetes cluster

Let me outline some of the highlights that we are going to see. First, we are setting up the Ansible controller as the client. And also, Ansible controller is the Ansible controller, and the Ansible controller needs to know about Kubernetes. So we need to tell Python how to manage Kubernetes, and in order to do so, with the name kubectl setup.yaml. This playbook is working with an environment variable, kube-host equals kube-hostname. That is to make it flexible. Feel free to override the environment variable by hard-coding it in the playbook if you want to. But if you don't, well, there's a flexibility layer. Obviously, the playbook is my creation, and there are so many ways in which you can write your own playbook to do the setup. What I've done in the playbook, I basically looked at the installation procedure, including the installation scripts, and converted all of that, basically from Bash to Ansible, put some conditionals in there, and I hope you're going to like the result…

Contents