forked from kshlm/gd2-k8s
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-gcs.yml
127 lines (108 loc) · 4 KB
/
deploy-gcs.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
- name: Deploy GCS
hosts: kube-master[0]
become: true
gather_facts: false
vars:
kubectl: /usr/local/bin/kubectl
pre_tasks:
- name: Create a temporary kube configs directory
tempfile:
state: directory
prefix: gcs-configs
register: tempdir
- set_fact:
cachable: true
configs_dir: "{{ tempdir.path }}"
- name: Copy GCS configs over
synchronize:
src: ./gcs-configs/
dest: "{{ configs_dir }}"
post_tasks:
- name: Delete temporary configs directory
file:
path: "{{ configs_dir }}"
state: absent
tasks:
- name: GCS | Namespace | Create GCS namespace
kube:
kubectl: "{{ kubectl }}"
file: "{{ configs_dir }}/gcs-namespace.yml"
- name: GCS | ETCD Operator | Deploy etcd-operator
kube:
kubectl: "{{ kubectl }}"
file: "{{ configs_dir }}/gcs-etcd-operator.yml"
- name: GCS | ETCD Operator | Wait for etcd-operator to be available
command: "{{ kubectl }} -ngcs -ojsonpath='{.status.availableReplicas}' get deployment etcd-operator"
register: result
until: result.stdout|int == 1
delay: 10
retries: 50
- name: GCS | ETCD Cluster | Deploy etcd-cluster
kube:
kubectl: "{{ kubectl }}"
file: "{{ configs_dir }}/gcs-etcd-cluster.yml"
register: result
until: not result.failed
delay: 5
retries: 5
- name: GCS | ETCD Cluster | Get etcd-client service
command: "{{ kubectl }} -ngcs -ojson get service etcd-client"
register: etcd_client_service
until: etcd_client_service.rc == 0
delay: 5
retries: 5
- name: GCS | ETCD Cluster | Set etcd_client_endpoint
set_fact:
etcd_client_endpoint: "http://{{ (etcd_client_service.stdout|from_json).spec.clusterIP }}:2379"
cacheable: true
- name: GCS | ETCD Cluster | Wait for etcd-cluster to become ready
uri:
url: "{{ etcd_client_endpoint }}/v2/members"
register: result
until: result.status is defined and (result.status == 200 and result.json.members|length == 3)
delay: 10
retries: 50
- name: GCS | GD2 Cluster | Deploy glusterd2-cluster
kube:
kubectl: "{{ kubectl }}"
file: "{{ configs_dir }}/gcs-gd2-cluster.yml"
- name: GCS | GD2 Cluster | Get glusterd2-client service
command: "{{ kubectl }} -ngcs -ojson get service glusterd2-client "
register: gd2_client_service
until: gd2_client_service.rc == 0
delay: 5
retries: 5
- name: GCS | GD2 Cluster | Set gd2_client_endpoint
set_fact:
gd2_client_endpoint: "http://{{ (gd2_client_service.stdout|from_json).spec.clusterIP}}:24007"
cacheable: true
- name: GCS | GD2 Cluster | Wait for glusterd2-cluster to become ready
uri:
url: "{{ gd2_client_endpoint }}/v1/peers"
register: result
until: result.status is defined and (result.status == 200 and result.json|length == groups['kube-node']|length)
delay: 10
retries: 50
- name: GCS | CSI Driver | Deploy csi driver
kube:
kubectl: "{{ kubectl }}"
file: "{{ configs_dir }}/gcs-csi.yml"
- name: GCS | CSI Driver | Wait for csi-provisioner to become available
command: "{{ kubectl }} -ngcs -ojsonpath={.status.readyReplicas} get statefulset csi-provisioner-glusterfsplugin"
register: result
until: result.stdout|int == 1
delay: 10
retries: 50
- name: GCS | CSI Driver | Wait for csi-attacher to become available
command: "{{ kubectl }} -ngcs -ojsonpath={.status.readyReplicas} get statefulset csi-attacher-glusterfsplugin"
register: result
until: result.stdout|int == 1
delay: 10
retries: 50
- name: GCS | CSI Driver | Wait for csi-nodeplugin to become available
command: "{{ kubectl }} -ngcs -ojsonpath={.status.numberAvailable} get daemonset csi-nodeplugin-glusterfsplugin"
register: result
until: result.stdout|int == 3
delay: 10
retries: 50