-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-init.yaml
56 lines (56 loc) · 2.22 KB
/
cluster-init.yaml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
- name: Reinitialize if asked
hosts: workers master
tasks:
- name: Kubeadm reset
ansible.builtin.shell: |
kubeadm reset -f
when: reinit
- name: Master node cluster init
hosts: master
tasks:
- name: Initialize K8S cluster
changed_when: false
ansible.builtin.shell: kubeadm init --pod-network-cidr={{docker_subnet}} --apiserver-advertise-address=192.168.200.210 --ignore-preflight-errors=all
- name: Create .kube directory
ansible.builtin.file:
path: $HOME/.kube
state: directory
mode: '0755'
- name: Copy k8s config
ansible.builtin.copy:
remote_src: true
src: /etc/kubernetes/admin.conf
dest: $HOME/.kube/config
owner: root
group: root
- name: Install Pod network
become: true
ansible.builtin.shell: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/tigera-operator.yaml >> pod_network_setup.txt
args:
chdir: $HOME
creates: pod_network_setup.txt
- name: Get join command
ansible.builtin.shell: kubeadm token create --print-join-command
register: join_command
- name: Copy join command to local file
local_action: copy content="{{ join_command.stdout_lines[0] }}" dest="./join-command"
- name: Helm Install
ansible.builtin.shell: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
bash get_helm.sh
- name: Helm add repo
ansible.builtin.shell: |
helm repo add kubernetes-dashboard https://kubernetes.github.io/dashboard/
- name: Helm Install dashboard
ansible.builtin.shell: |
helm upgrade --install kubernetes-dashboard kubernetes-dashboard/kubernetes-dashboard --create-namespace --namespace kubernetes-dashboard
- name: Helm configure dashboard
ansible.builtin.shell: |
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8443:443
- name: Make workers join cluster
hosts: workers
tasks:
- name: Copy the join command to server location
copy: src=join-command dest=/tmp/join-command.sh mode=0777
- name: Join the node to cluster
command: sh /tmp/join-command.sh