-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.gitlab-ci.yml
250 lines (239 loc) · 9.53 KB
/
.gitlab-ci.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
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
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-md-files.yml"
Run linter:
image:
name: "registry.hpc.ut.ee/mirror/alpine/helm:3.12.3"
entrypoint: [""]
stage: test
interruptible: true
rules:
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
- if: $CI_COMMIT_TAG
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
before_script:
- apk update
- apk add jq python3
- apk add -X http://dl-cdn.alpinelinux.org/alpine/edge/community -u alpine-keys
- apk add yq --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
script:
- helm dependency update waldur/
- helm lint waldur/
- helm lint waldur/ -f waldur/test/values.yaml
# lint for correctness of known configuration
- mkdir rendered-templates && helm template waldur -f waldur/test/values.yaml --output-dir rendered-templates/ --debug
- yq e '.data."features.json"' rendered-templates/waldur/templates/config-features-json.yml | jq
- yq e '.data."override.conf.py"' rendered-templates/waldur/templates/config-override.yaml > rendered-templates/waldur/templates/override.conf.py
- python3 -m py_compile rendered-templates/waldur/templates/override.conf.py
artifacts:
expire_in: 1 week
when: always
paths:
- rendered-templates
.Test template:
image: $HELM_TEST_IMAGE
stage: test
interruptible: true
before_script:
- export KUBECONFIG=${K8S_CONFIG_WALDUR_HELM_TEST}
- apk update
- apk add curl git
- kubectl config view
- kubectl config current-context
- helm repo add stable https://charts.helm.sh/stable
- helm repo add bitnami https://charts.bitnami.com/bitnami
- helm repo update
- helm dependency update waldur/
.Cleanup template:
image: $HELM_TEST_IMAGE
script:
- export KUBECONFIG=${K8S_CONFIG_WALDUR_HELM_TEST}
- helm uninstall waldur || true
- kubectl delete job waldur-mastermind-init-whitelabeling-job || true
Validate release installation (dry-run):
extends: .Test template
rules:
- if: '$SKIP_TESTS == "true"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == "master"'
- if: $CI_COMMIT_TAG
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- helm install waldur waldur/ -f waldur/test/values.yaml --dry-run --debug
Test release installation and readiness:
extends: .Test template
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- waldur/**/*
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule"'
changes:
- waldur/**/*
- if: $TRIGGER_PROJECT_NAME
changes:
- waldur/**/*
script:
- set -xv
- helm dep update waldur/
- helm install waldur waldur/ --wait -f waldur/test/values.yaml --timeout 20m0s
after_script:
- set -xv
- export KUBECONFIG=${K8S_CONFIG_WALDUR_HELM_TEST}
- helm list
- kubectl apply -f waldur/test/k8s/networkpolicy-override.yaml
- kubectl delete networkpolicy namespace-isolation --ignore-not-found
- kubectl get pods
- |
for NAME in $(kubectl get pods -l app.kubernetes.io/instance=waldur --field-selector status.phase!=Running -o name); do
echo "Pod name: $NAME"
echo "Status: $(kubectl get pod $NAME -o jsonpath={.status.phase})"
kubectl logs $NAME --tail 100 --all-containers
echo ----
done
.Test ArgoCD template:
image: registry.hpc.ut.ee/iljatest/docker:24.0.6
variables:
APPLICATION_NAME: waldur-helm-$CI_MERGE_REQUEST_IID
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- waldur/**/*
before_script:
- echo 'PasswordAuthentication no' >> /etc/ssh/ssh_config
- cat /etc/ssh/ssh_config
- SSH_COMMAND="ssh -i .ssh/id_waldur_dev_ssh_pkey -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [email protected]"
- SCP_COMMAND="scp -i .ssh/id_waldur_dev_ssh_pkey -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
- mkdir -p .ssh
- cp -vf $WALDUR_DEV_SSH_PKEY .ssh/id_waldur_dev_ssh_pkey
- cp -vf $WALDUR_DEV_SSH_PUBKEY .ssh/id_waldur_dev_ssh_pkey.pub
- chmod 600 .ssh/id_waldur_dev_ssh_pkey
after_script:
- rm -fv .ssh/id_waldur_dev_ssh_pkey .ssh/id_waldur_dev_ssh_pkey.pub
Test ArgoCD sync:
extends: .Test ArgoCD template
stage: test
script:
- echo ${APPLICATION_NAME}
- $SSH_COMMAND "argocd login 10.43.40.117:80 --username $ARGOCD_USERNAME --password $ARGOCD_PASSWORD --name default --insecure"
- $SSH_COMMAND "argocd account get-user-info"
- $SSH_COMMAND "argocd app list"
- $SSH_COMMAND "argocd repo add https://code.opennodecloud.com/waldur/waldur-helm.git --username gitlab-ci-token --password $CI_JOB_TOKEN --upsert"
- $SSH_COMMAND "argocd app sync $APPLICATION_NAME --timeout 2400"
- $SSH_COMMAND "argocd app wait $APPLICATION_NAME"
- $SSH_COMMAND "argocd repo rm https://code.opennodecloud.com/waldur/waldur-helm.git"
Cleanup previous test deployment:
extends: .Cleanup template
stage: .pre
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule"'
Upload docs:
image:
name: registry.hpc.ut.ee/mirror/alpine/git:v2.30.2
entrypoint: [""]
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE == "schedule"'
script:
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs/
- cp -v $CI_PROJECT_DIR/README.md docs/admin-guide/deployment/helm/index.md
- cp -rv $CI_PROJECT_DIR/docs/ docs/admin-guide/deployment/helm/
- git add docs/admin-guide/deployment/helm/
- git commit -m 'Update Waldur Helm docs' || exit 0
- git branch new-configuration-guide
- git push --set-upstream origin new-configuration-guide:master
Publish new chart version and update docs on github:
image:
name: registry.hpc.ut.ee/mirror/alpine/helm:3.11.2
entrypoint: [""]
stage: release
rules:
- if: $CI_COMMIT_TAG
script:
# Configure git
- git remote -v
- git remote remove github-origin || true # Cleanup previous session
- git remote add github-origin https://opennode-jenkins:[email protected]/waldur/waldur-helm.git
- git remote -v
- git config user.name "Opennode Jenkins"
- git config user.email [email protected]
- git fetch github-origin
# Add version-specific docs
- cp README.md waldur/
- cp -r docs/ waldur/
# Add correct version to Chart.yaml
- |
sed -i -E -e "s/^version: ('.*'|.*)$/version: $CI_COMMIT_TAG/" waldur/Chart.yaml
- |
sed -i -E -e "s/^appVersion: ('.*'|.*)$/appVersion: \"$CI_COMMIT_TAG\"/" waldur/Chart.yaml
- |
sed -i -E -e "s/^ imageTag: \"latest\"$/ imageTag: \"$CI_COMMIT_TAG\"/" waldur/values.yaml
# Package Waldur chart with a new version
- helm dependency update waldur/
- helm package waldur/
- ls waldur-*.tgz
- git status
- git stash
# Checkout to gh-pages branch
- git checkout gh-pages
- git pull github-origin gh-pages
# Update docs
- git checkout $CI_COMMIT_TAG -- README.md
- git checkout $CI_COMMIT_TAG -- docs/
- git add README.md
- git add docs/
# Move archive to directory and update index
- mkdir charts/ || true
- mv waldur-$CI_COMMIT_TAG.tgz charts/
- helm repo index .
- git add charts/
- git add index.yaml
# Push changes
- git status
- git commit -m "Release $CI_COMMIT_TAG"
- git push github-origin gh-pages
Check for deprecated Kubernetes resources:
stage: test
image:
name: "registry.hpc.ut.ee/mirror/alpine/helm:3.14.2"
entrypoint: [""]
rules:
- if: '$SKIP_TESTS == "true"'
when: never
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: $CI_COMMIT_TAG
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- wget https://github.com/FairwindsOps/pluto/releases/download/v5.19.0/pluto_5.19.0_linux_amd64.tar.gz
- tar -xf pluto_5.19.0_linux_amd64.tar.gz
- mv pluto /usr/bin/
- helm dependency update waldur/
- helm template waldur | pluto detect --target-versions k8s=v1.18.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.19.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.20.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.21.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.22.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.23.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.24.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.25.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.26.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.27.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.28.0 -v 5 -
- helm template waldur | pluto detect --target-versions k8s=v1.29.0 -v 5 -