1_depend.yml
09-29-2019
Ansible playbooks for building Kubernetes cluster.
Make sure Docker is install and configured.
Add your Master and Worker nodes to the hosts file:
###################################
[master]
master ansible_host=10.1.140.11
[workers]
worker1 ansible_host=10.1.140.12
worker2 ansible_host=10.1.140.13
###################################
Run each playbook in order:
1_depend.yml
2_prepare.yml
3_join.yml
Specify the username for your servers.
Example command:
sudo ansible-playbook /etc/ansible/kube_cluster/1_depend.yml --user MyUser --ask-pass --ask-become-pass
Language or Platform: Python
Code:
# Install Kubernetes Dependencies
- hosts: master:workers
become: yes
tasks:
- name: install APT Transport HTTPS
apt:
name: apt-transport-https
state: present
- name: add Kubernetes apt-key
apt_key:
url: https://packages.cloud.google.com/apt/doc/apt-key.gpg
state: present
- name: add Kubernetes' APT repository
apt_repository:
repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
state: present
filename: 'kubernetes'
- name: Install Kubelet and Kubeadm
become: true
apt:
pkg:
- kubelet
- kubeadm
state: present
- hosts: master
become: yes
tasks:
- name: Install Kubectl on Master
become: true
apt:
pkg:
- kubectl
state: present
Back