-
Notifications
You must be signed in to change notification settings - Fork 2
283 lines (251 loc) · 10.8 KB
/
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
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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
golang-tests:
name: Go unit tests
timeout-minutes: 30
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v3
with:
go-version: '1.21'
check-latest: true
- name: Install tools
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
env:
KUBECTL_VERSION: 1.25.1
- name: Run tests
run:
make test
env:
PXC_OPERATOR_VERSION: 1.13.0
PSMDB_OPERATOR_VERSION: 1.15.0
PG_OPERATOR_VERSION: 2.2.0
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
eks-e2e-tests:
name: E2E tests (EKS)
timeout-minutes: 80
concurrency: eks-e2e-tests
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v3
with:
go-version: '1.21'
check-latest: true
- name: Build operator
run:
make build
- name: Install tools
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
# Kubectl
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
# Kuttl
curl -Lo ./kubectl-kuttl https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64
chmod +x ./kubectl-kuttl
mv ./kubectl-kuttl "$TOOLS_PATH"
# kubectl
curl -LO https://dl.k8s.io/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/v$KUBECTL_VERSION/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
chmod +x kubectl
cp kubectl "$TOOLS_PATH"
rm kubectl
# Install EKSCTL
ARCH=amd64
PLATFORM=$(uname -s)_$ARCH
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
tar -xzf eksctl_$PLATFORM.tar.gz -C "$TOOLS_PATH"
chmod +x "$TOOLS_PATH"/eksctl
# Configure CLI access
mkdir "$HOME"/.aws
echo "[default]" >> "$HOME"/.aws/credentials
echo "aws_access_key_id="$EKSUID"" >> "${HOME}"/.aws/credentials
echo "aws_secret_access_key="$EKSKEY"" >> "${HOME}"/.aws/credentials
echo "[default]" >> "${HOME}"/.aws/config
echo "region = "$EKSREG"" >> "${HOME}"/.aws/config
env:
KUBECTL_VERSION: 1.25.1
EKSUID: ${{ secrets.EKSU }}
EKSKEY: ${{ secrets.EKSSAK }}
EKSREG: ${{ secrets.EKSREG }}
- name: Scale up cluster
run: |
eksctl scale nodegroup --cluster="$CLUSTER_NAME" --nodes=5 "$NODEPOOL_NAME" --wait
env:
CLUSTER_NAME: "dbaas-ci-20221005"
NODEPOOL_NAME: "terraform-node-dbaas-ci-20221005"
- name: Run upgrade tests
run: |
echo $TOOLS_PATH >> $GITHUB_PATH
export KUBECONFIG="${HOME}/.kube/config"
mkdir -p "${KUBECONFIG%/*}"
echo "$BASE64_KUBECONFIG_DBAAS"|base64 -d > "${KUBECONFIG}"
kubectl kuttl test --config ./e2e-tests/kuttl-eks-upgrade.yml
env:
PXC_OPERATOR_VERSION: 1.13.0
PSMDB_OPERATOR_VERSION: 1.15.0
PG_OPERATOR_VERSION: 2.2.0
PREVIOUS_PG_OPERATOR_VERSION: 2.2.0 # TODO: Revisit it after 2.3 release
PREVIOUS_PXC_OPERATOR_VERSION: 1.12.0
PREVIOUS_PSMDB_OPERATOR_VERSION: 1.14.0
BASE64_KUBECONFIG_DBAAS: ${{ secrets.BASE64_KUBECONFIG_DBAAS }}
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Clean up custom resources
if: always()
run: |
namespaces=$(kubectl get pxc -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pxc -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pxc -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
kubectl delete db --all-namespaces --all
kubectl delete pvc --all-namespaces --all
kubectl get ns -o name | grep kuttl | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete ns
- name: Run core tests
if: always()
run: |
echo $TOOLS_PATH >> $GITHUB_PATH
export KUBECONFIG="${HOME}/.kube/config"
mkdir -p "${KUBECONFIG%/*}"
echo "$BASE64_KUBECONFIG_DBAAS"|base64 -d > "${KUBECONFIG}"
kubectl kuttl test --config ./e2e-tests/kuttl-eks-core.yml
env:
PXC_OPERATOR_VERSION: 1.13.0
PSMDB_OPERATOR_VERSION: 1.15.0
PG_OPERATOR_VERSION: 2.2.0
BASE64_KUBECONFIG_DBAAS: ${{ secrets.BASE64_KUBECONFIG_DBAAS }}
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Run features tests
if: always()
run: |
echo $TOOLS_PATH >> $GITHUB_PATH
export KUBECONFIG="${HOME}/.kube/config"
mkdir -p "${KUBECONFIG%/*}"
echo "$BASE64_KUBECONFIG_DBAAS"|base64 -d > "${KUBECONFIG}"
kubectl kuttl test --config ./e2e-tests/kuttl-eks-features.yml
env:
PXC_OPERATOR_VERSION: 1.13.0
PSMDB_OPERATOR_VERSION: 1.15.0
PG_OPERATOR_VERSION: 2.2.0
BASE64_KUBECONFIG_DBAAS: ${{ secrets.BASE64_KUBECONFIG_DBAAS }}
PERCONA_VERSION_SERVICE_URL: https://check-dev.percona.com/versions/v1
- name: Clean up custom resources
if: always()
run: |
namespaces=$(kubectl get pxc -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get pxc -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch pxc -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
namespaces=$(kubectl get psmdb -A -o jsonpath='{.items[*].metadata.namespace}')
for namespace in ${namespaces[@]}
do
kubectl -n $namespace get psmdb -o name | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl patch psmdb -n $namespace -p '{"metadata":{"finalizers":null}}' --type merge
done
kubectl delete db --all-namespaces --all
kubectl delete pvc --all-namespaces --all
kubectl get ns -o name | grep kuttl | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete ns
- name: Scale down cluster
if: always()
run: |
eksctl scale nodegroup --cluster="$CLUSTER_NAME" --nodes=0 "$NODEPOOL_NAME"
env:
CLUSTER_NAME: "dbaas-ci-20221005"
NODEPOOL_NAME: "terraform-node-dbaas-ci-20221005"
- name: Clean up resources and CRDs
if: always()
run: |
export KUBECONFIG="${HOME}/.kube/config"
mkdir -p "${KUBECONFIG%/*}"
echo "$BASE64_KUBECONFIG_DBAAS"|base64 -d > "${KUBECONFIG}"
kubectl get crd -o name | grep .percona.com$ | awk -F '/' {'print $2'} | xargs --no-run-if-empty kubectl delete crd
kubectl delete crd postgresclusters.postgres-operator.crunchydata.com
env:
BASE64_KUBECONFIG_DBAAS: ${{ secrets.BASE64_KUBECONFIG_DBAAS }}
- name: Clean up credentials
run: |
rm -f "$HOME"/.aws/config
rm -f "$HOME"/.aws/credentials
make-bundle:
name: Make Bundle
strategy:
fail-fast: true
runs-on: ubuntu-latest
env:
TOOLS_PATH: "/opt/tools/bin"
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go release
uses: actions/setup-go@v3
with:
go-version: '1.21'
check-latest: true
- name: Install operator-sdk
run: |
mkdir -p $TOOLS_PATH
echo $TOOLS_PATH >> $GITHUB_PATH
export ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)
export OS=$(uname | awk '{print tolower($0)}')
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.26.0
curl -LO ${OPERATOR_SDK_DL_URL}/operator-sdk_${OS}_${ARCH}
gpg --keyserver keyserver.ubuntu.com --recv-keys 052996E2A20B5C7E
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt
curl -LO ${OPERATOR_SDK_DL_URL}/checksums.txt.asc
gpg -u "Operator SDK (release) <cncf-operator-sdk@cncf.io>" --verify checksums.txt.asc
grep operator-sdk_${OS}_${ARCH} checksums.txt | sha256sum -c -
chmod +x operator-sdk_${OS}_${ARCH}
mv operator-sdk_${OS}_${ARCH} $TOOLS_PATH/operator-sdk
- name: Make bundle and build bundle image
run: |
make bundle bundle-build