-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcompact_kubevirt.yaml
209 lines (188 loc) · 7.34 KB
/
compact_kubevirt.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
- hosts: localhost
gather_facts: false
become: false
vars_files:
- vars/config.yaml
vars_prompt:
- name: cluster_name
prompt: Specify cluster name
private: false
tasks:
- name: Destroy Compact cluster
when: action == "delete" or action == "destroy"
block:
- name: Delete the service (type LoadBalancer) for Compact
kubernetes.core.k8s:
state: absent
api_version: v1
kind: Service
namespace: "{{ ocp_namespace }}"
name: "{{ ocp_vmname_master_prefix }}-svc"
- name: Delete A dns record
amazon.aws.route53:
state: absent
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
loop:
- "api"
- "*.apps"
- name: Delete a Compact VM
kubevirt.core.kubevirt_vm:
name: "{{ ocp_vmname_master_prefix }}-{{ _index }}"
namespace: "{{ namespace }}"
state: absent
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Remove Assisted Installer Cluster
agonzalezrh.install_openshift.delete_cluster:
cluster_id: "{{ cluster_id }}"
offline_token: "{{ offline_token }}"
- name: Create Compact cluster
when: action == "create"
block:
- name: Add the service (type LoadBalancer) for Compact
kubernetes.core.k8s:
definition: "{{ lookup('ansible.builtin.template', 'templates/compact_svc.yaml') }}"
wait: true
wait_timeout: 300
vars:
svcname: "{{ ocp_vmname_master_prefix }}-svc"
namespace: "{{ ocp_namespace }}"
- name: Wait for the LoadBalancer value
register: compact_svc
kubernetes.core.k8s_info:
api_version: v1
kind: Service
name: "{{ ocp_vmname_master_prefix }}-svc"
namespace: "{{ ocp_namespace }}"
until: compact_svc.resources[0].status.loadBalancer.ingress[0].ip | default('') != ''
retries: 10
delay: 2
- name: Add A dns record
amazon.aws.route53:
state: present
zone: "{{ dns_zone }}"
record: "{{ item }}.{{ cluster_name}}.{{ cluster_domain }}"
type: A
value: "{{ compact_svc.resources[0].status.loadBalancer.ingress[0].ip }}"
ttl: 30
overwrite: true
loop:
- "api"
- "*.apps"
- name: Create OVN secondary network
kubernetes.core.k8s:
definition: "{{ lookup('ansible.builtin.template', 'templates/net-attach-def.yaml') }}"
wait: true
wait_timeout: 300
vars:
network_name: "{{ cluster_name }}-openshift"
namespace: "{{ ocp_namespace }}"
- name: Create Assisted Installer Cluster
agonzalezrh.install_openshift.create_cluster:
name: "{{ cluster_name }}"
openshift_version: "{{ cluster_version }}"
base_dns_domain: "{{ cluster_domain }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
high_availability_mode: "Full"
schedulable_masters: true
service_networks:
- cidr: "172.31.0.0/16"
machine_networks:
- cidr: "10.10.10.0/24"
api_vip: 10.10.10.100
api_vips:
- ip: 10.10.10.100
ingress_vip: 10.10.10.101
ingress_vips:
- ip: 10.10.10.101
register: newcluster
- name: Include vars
include_vars:
file: vars/static_network_config_compact.yaml
- name: Create Infrastructure environment
agonzalezrh.install_openshift.create_infra_env:
name: "{{ cluster_name }}-infra-env"
image_type: "{{ cluster_iso_type }}"
cluster_id: "{{ newcluster.result.id }}"
ssh_authorized_key: "{{ ssh_authorized_key }}"
offline_token: "{{ offline_token }}"
pull_secret: "{{ pull_secret }}"
static_network_config: "{{ static_network_config }}"
register: newinfraenv
- name: Create a three master VMs for Compact cluster
include_tasks: tasks/kubevirt/create_masters.yaml
vars:
image_url: "{{ newinfraenv.result.download_url }}"
vmname: "{{ ocp_vmname_master_prefix }}-{{ _index }}"
namespace: "{{ ocp_namespace }}"
storageclass: "{{ storage_class }}"
network: "{{ cluster_name}}-openshift"
network_name: "{{ cluster_name }}-openshift"
pod_network: "192.168.{{ _index }}.0/24"
loop: "{{ query('sequence', 'start=1 end=3') }}"
loop_control:
loop_var: _index
- name: Wait for the hosts to be ready
agonzalezrh.install_openshift.wait_for_hosts:
cluster_id: "{{ newcluster.result.id }}"
infra_env_id: "{{ newinfraenv.result.id }}"
offline_token: "{{ offline_token }}"
expected_hosts: 3
configure_hosts:
- hostname: master-{{ cluster_name }}-1
role: master
installation_disk: /dev/vda
- hostname: master-{{ cluster_name }}-2
role: master
installation_disk: /dev/vda
- hostname: master-{{ cluster_name }}-3
role: master
installation_disk: /dev/vda
wait_timeout: 600
- name: Start cluster installation
agonzalezrh.install_openshift.install_cluster:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
wait_timeout: 1200
- name: Obtain OpenShift cluster credentials
register: credentials
agonzalezrh.install_openshift.get_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
- name: Display credentials
debug:
var: credentials.result
- name: Create directory for downloaded credential files
ansible.builtin.file:
state: directory
path: "{{ output_dir }}/{{ cluster_name }}"
recurse: true
- name: Downloads OpenShift cluster credentials
agonzalezrh.install_openshift.download_credentials:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- kubeadmin-password
- kubeconfig
- kubeconfig-noingress
- name: Downloads OpenShift cluster files
agonzalezrh.install_openshift.download_files:
cluster_id: "{{ newcluster.result.id }}"
offline_token: "{{ offline_token }}"
file_name: "{{ item }}"
dest: "{{ output_dir }}/{{ cluster_name }}/{{ item }}"
loop:
- bootstrap.ign
- master.ign
- metadata.json
- worker.ign
- install-config.yaml
- custom_manifests.json
- custom_manifests.yaml