-
Notifications
You must be signed in to change notification settings - Fork 42
/
demo-cluster.yml
40 lines (34 loc) · 1.27 KB
/
demo-cluster.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env ansible-playbook
---
- name: Start up a kind cluster
hosts: localhost
vars:
cluster_name: demo
# This needs to be the cluster name with -control-plane added
container_name: demo-control-plane
cluster_config: demo.yml
tasks:
- name: Start a kind cluster
command: kind create cluster --name {{ cluster_name }} --config kubeadm_configs/{{ cluster_config }}
- name: Add the host
add_host: name={{ container_name }}
# This needs to be in place for every playbook using kind as we need Python
- name: install Python in the cluster
hosts: demo-control-plane
connection: docker
gather_facts: no
tasks:
- import_tasks: ./ansible_tasks/install_python.yml
- name: Setup Cluster
hosts: demo-control-plane
connection: docker
tasks:
- import_tasks: ./ansible_tasks/setup_kubeconfig.yml
- name: make the default service account cluster-admin
command: kubectl --kubeconfig=/etc/kubernetes/admin.conf create clusterrolebinding serviceaccounts-cluster-admin --clusterrole=cluster-admin --group=system:serviceaccounts
- name: Get the kubeconfig file for the client
fetch:
src: /etc/kubernetes/admin.conf
dest: /tmp/demo-kubernetes-admin.conf
flat: yes
- import_tasks: ./ansible_tasks/print_cluster_ip.yml