-
Notifications
You must be signed in to change notification settings - Fork 14
340 lines (339 loc) · 12.4 KB
/
unit-func-e2e-test.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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
name: unit-func-e2e-test
on:
push:
branches:
- 'main'
paths:
- "**.go"
- "**.yaml"
- "!capm.yaml"
- "!osc-secret.yaml"
- "!example/**.yaml"
- "!testclean/**"
- "!helm/**"
- "Makefile"
- "hack/*.sh"
- "!docs/src/**"
- "!hack/json-format/*.sh"
- "!hack/json-format/src/*.rs"
- "!hack/json-format/Makefile"
- "!hack/json-format/Cargo.*"
- "!hack/json-format/tests/*.rs"
pull_request:
branches: [ main ]
paths:
- "**.go"
- "**.yaml"
- "!capm.yaml"
- "!osc-secret.yaml"
- "!example/**.yaml"
- "!testclean/**"
- "!helm/**"
- "Makefile"
- "hack/*.sh"
- "!docs/src/**"
- "!hack/json-format/*.sh"
- "!hack/json-format/src/*.rs"
- "!hack/json-format/Makefile"
- "!hack/json-format/Cargo.*"
- "!hack/json-format/tests/*.rs"
jobs:
testenv:
runs-on: [self-hosted, linux]
needs: [unit_test]
steps:
- name: Checkout cluster-api-outscale
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Checkout osc-k8s-rke-cluster
uses: actions/checkout@v3
with:
repository: 'outscale-dev/osc-k8s-rke-cluster'
path: "rke-cluster-for-cluster-api"
ref: master
- name: Install kubectl
uses: azure/[email protected]
with:
version: v1.22.7
id: install
- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '>=1.17.8'
- name: Install kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: v4.5.7
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- name: Deploy Cluster
uses: ./rke-cluster-for-cluster-api/github_actions/deploy_cluster/
with:
repository_folder: "rke-cluster-for-cluster-api"
osc_access_key: ${{ secrets.OSC_ACCESS_KEY }}
osc_secret_key: ${{ secrets.OSC_SECRET_KEY }}
osc_region: ${{ secrets.OSC_REGION }}
image_id: ${{ secrets.OMI_ID }}
control_plane_vm_type: ${{ secrets.CP_VMTYPE }}
bastion_vm_type: ${{ secrets.BASTION_VMTYPE }}
worker_vm_type: ${{ secrets.WORKER_VMTYPE }}
rke_version: ${{ secrets.RKE_VERSION }}
kubernetes_version: ${{ secrets.KUBERNETES_VERSION }}
- name: Wait Kubernetes control plane is up and running
uses: nick-invision/retry@v2
with:
timeout_seconds: 30
max_attempts: 20
retry_wait_seconds: 30
command: kubectl get --raw='/readyz?verbose'
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Wait all infrastructure app are really up and running
uses: jupyterhub/action-k8s-await-workloads@v1
with:
workloads: ""
namespace: ""
timeout: 600
max-restarts: -1
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Deploy Docker-registry into cluster
run: |
ansible-playbook addons/docker-registry/playbook.yaml
./addons/docker-registry/start_port_forwarding.sh &
env:
KUBECONFIG: rke/kube_config_cluster.yml
ANSIBLE_CONFIG: ansible.cfg
working-directory: rke-cluster-for-cluster-api
- name: Wait registry up
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '2m'
- name: Build and Push Docker image
run: |
sudo apt-get update
sudo apt install -y docker-buildx-plugin
make docker-buildx
make docker-push
docker image prune -a -f
env:
IMG: 127.0.0.1:4242/cluster-api-outscale-controller:${{ github.sha }}
DOCKER_BUILDKIT: 1
- name: Retrieve NodePort Ip and NodePort
run: |
echo nodeport_port=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services docker-registry) >> $GITHUB_ENV
echo nodeport_ip=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}") >> $GITHUB_ENV
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Create ns and set credential
run: make credential
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}}
OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}}
OSC_REGION: ${{ secrets.OSC_REGION }}
- name: Deploy cluster-api
run: make deploy-clusterapi
id: deploy-capi
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Deploy cluster-api-outscale
run: make deploy
shell: bash
id: deploy-capo
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
IMG: ${nodeport_ip}:${nodeport_port}/cluster-api-outscale-controller:${{ github.sha }}
- name: Launch functional test
run: make testenv
shell: bash
id: func-test
env:
KUBECONFIG: ${{ github.workspace }}/rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}}
OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}}
OSC_REGION: ${{ secrets.OSC_REGION }}
OSC_SUBREGION_NAME: ${{ secrets.OSC_SUBREGION_NAME }}
IMG_UPGRADE_FROM: ${{ secrets.IMG_UPGRADE_FROM }}
- name: Get log capo master
run: make logs-capo
if: ${{ failure() && steps.func-test.conclusion == 'failure' }}
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
CAPO_NAMESPACE: cluster-api-provider-outscale-system
- name: Get log capi
run: make logs-capi
if: ${{ failure() && steps.func-test.conclusion == 'failure' }}
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
CAPO_NAMESPACE: cluster-api-provider-outscale-system
- name: Destroy cluster
uses: ./rke-cluster-for-cluster-api/github_actions/destroy_cluster/
if: ${{ always() }}
with:
repository_folder: "./rke-cluster-for-cluster-api"
osc_access_key: ${{ secrets.OSC_ACCESS_KEY }}
osc_secret_key: ${{ secrets.OSC_SECRET_KEY }}
osc_region: ${{ secrets.OSC_REGION }}
unit_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/setup-go@v3
with:
go-version: '1.19.8'
- name: unit-test
run: |
make unit-test
cat covers.txt
shell: bash
e2etest:
runs-on: [self-hosted, linux]
needs: [unit_test, testenv]
steps:
- name: Checkout cluster-api-outscales
uses: actions/checkout@v3
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Checkout osc-k8s-rke-cluster
uses: actions/checkout@v3
with:
repository: 'outscale-dev/osc-k8s-rke-cluster'
path: "rke-cluster-for-cluster-api"
ref: master
- name: Install kubectl
uses: azure/[email protected]
with:
version: v1.22.7
id: install
- name: Install golang
uses: actions/setup-go@v3
with:
go-version: '>=1.17.8'
- name: Install kustomize
uses: imranismail/setup-kustomize@v1
with:
kustomize-version: v4.5.7
- uses: outscale-dev/frieza-github-actions/frieza-clean@master
with:
access_key: ${{ secrets.OSC_ACCESS_KEY }}
secret_key: ${{ secrets.OSC_SECRET_KEY }}
region: ${{ secrets.OSC_REGION }}
- name: Deploy Cluster
uses: ./rke-cluster-for-cluster-api/github_actions/deploy_cluster/
with:
repository_folder: "rke-cluster-for-cluster-api"
osc_access_key: ${{ secrets.OSC_ACCESS_KEY }}
osc_secret_key: ${{ secrets.OSC_SECRET_KEY }}
osc_region: ${{ secrets.OSC_REGION }}
image_id: ${{ secrets.OMI_ID }}
control_plane_vm_type: ${{ secrets.CP_VMTYPE }}
bastion_vm_type: ${{ secrets.BASTION_VMTYPE }}
worker_vm_type: ${{ secrets.WORKER_VMTYPE }}
rke_version: ${{ secrets.RKE_VERSION }}
kubernetes_version: ${{ secrets.KUBERNETES_VERSION }}
- name: Wait Kubernetes control plane is up and running
uses: nick-invision/retry@v2
with:
timeout_seconds: 30
max_attempts: 20
retry_wait_seconds: 30
command: kubectl get --raw='/readyz?verbose'
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Wait all infrastructure app are really up and running
uses: jupyterhub/action-k8s-await-workloads@v1
with:
workloads: ""
namespace: ""
timeout: 600
max-restarts: -1
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Deploy Docker-registry into cluster
run: |
ansible-playbook addons/docker-registry/playbook.yaml
./addons/docker-registry/start_port_forwarding.sh &
env:
KUBECONFIG: rke/kube_config_cluster.yml
ANSIBLE_CONFIG: ansible.cfg
working-directory: rke-cluster-for-cluster-api
- name: Wait registry up
uses: GuillaumeFalourd/wait-sleep-action@v1
with:
time: '2m'
- name: Build and Push Docker image
run: |
sudo apt-get update
sudo apt install -y docker-buildx-plugin
make docker-buildx
make docker-push
docker image prune -a -f
env:
IMG: 127.0.0.1:4242/cluster-api-outscale-controller:${{ github.sha }}
DOCKER_BUILDKIT: 1
- name: Retrieve NodePort Ip and NodePort
run: |
echo 'NODEPORT_PORT<<EOF' >> $GITHUB_ENV
echo "$(kubectl get --namespace default -o jsonpath='{.spec.ports[0].nodePort}' services docker-registry)" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo 'NODEPORT_IP<<EOF' >> $GITHUB_ENV
echo "$(kubectl get nodes --namespace default -o jsonpath='{.items[0].status.addresses[0].address}')" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
- name: Create ns and set credential
run: make credential
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}}
OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}}
OSC_REGION: ${{ secrets.OSC_REGION }}
- name: Launch e2etest
run: KUBECONFIG=$GITHUB_WORKSPACE/rke-cluster-for-cluster-api/rke/kube_config_cluster.yml make e2etestexistingcluster
shell: bash
id: e2etest
env:
IMG: ${{ env.NODEPORT_IP }}:${{ env.NODEPORT_PORT }}/cluster-api-outscale-controller:${{ github.sha }}
OSC_ACCESS_KEY: ${{secrets.OSC_ACCESS_KEY}}
OSC_SECRET_KEY: ${{secrets.OSC_SECRET_KEY}}
OSC_REGION: ${{ secrets.OSC_REGION }}
OSC_SUBREGION_NAME: ${{ secrets.OSC_SUBREGION_NAME }}
IMG_UPGRADE_FROM: ${{ secrets.IMG_UPGRADE_FROM }}
IMG_UPGRADE_TO: ${{ secrets.IMG_UPGRADE_TO }}
- name: Get cluster api outscale logs
run: make logs-capo
if: ${{ failure() && steps.e2etest.conclusion == 'failure' }}
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
CAPO_NAMESPACE: cluster-api-provider-outscale-system
- name: Get cluster api logs
run: make logs-capi
if: ${{ failure() && steps.e2etest.conclusion == 'failure' }}
shell: bash
env:
KUBECONFIG: rke-cluster-for-cluster-api/rke/kube_config_cluster.yml
CAPI_NAMESPACE: capi-kubeadm-bootstrap-system
- name: Destroy cluster
uses: ./rke-cluster-for-cluster-api/github_actions/destroy_cluster/
if: ${{ always() }}
with:
repository_folder: "./rke-cluster-for-cluster-api"
osc_access_key: ${{ secrets.OSC_ACCESS_KEY }}
osc_secret_key: ${{ secrets.OSC_SECRET_KEY }}
osc_region: ${{ secrets.OSC_REGION }}