forked from defenseunicorns/pepr
-
Notifications
You must be signed in to change notification settings - Fork 0
221 lines (190 loc) · 6.9 KB
/
soak.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
# name: Soak Test
# permissions: read-all
# on:
# workflow_dispatch:
# schedule:
# - cron: '0 4 * * *' # 12AM EST/9PM PST
# # push:
# # paths-ignore:
# # - "**.md"
# # - "**.jpg"
# # - "**.png"
# # - "**.gif"
# # - "**.svg"
# # - "adr/**"
# # - "__mocks__/**"
# # - ".npmignore"
# # - ".prettierignore"
# # - "scripts/**"
# # - "hack/**"
# # - "_images/**"
# # - "**.yaml"
# # - "**.toml"
# # - "**.json"
# # - "docs/**"
# # - "CODEOWNERS"
# # branches: ["main"]
# # pull_request:
# # branches: ["main"]
# # paths-ignore:
# # - "**.md"
# # - "**.jpg"
# # - "**.png"
# # - "**.gif"
# # - "**.svg"
# # - "adr/**"
# # - "__mocks__/**"
# # - ".npmignore"
# # - ".prettierignore"
# # - "scripts/**"
# # - "hack/**"
# # - "_images/**"
# # - "**.yaml"
# # - "**.toml"
# # - "docs/**"
# # - "**.json"
# # - "CODEOWNERS"
# # refs
# # https://frontside.com/blog/2022-12-12-dynamic-github-action-jobs/
# # https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
# jobs:
# pepr-build:
# name: controller image
# runs-on: ubuntu-latest
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
# with:
# egress-policy: audit
# - name: clone pepr
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# with:
# repository: defenseunicorns/pepr
# path: pepr
# - name: "set env: PEPR"
# run: echo "PEPR=${GITHUB_WORKSPACE}/pepr" >> "$GITHUB_ENV"
# - name: setup node
# uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
# with:
# node-version: 20
# cache: "npm"
# cache-dependency-path: pepr
# - name: install pepr deps
# run: |
# cd "$PEPR"
# npm ci
# - name: build pepr image
# run: |
# cd "$PEPR"
# npm run build:image
# - name: tar pepr image
# run: |
# PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
# echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
# docker image save --output "$PEPR_TAR" pepr:dev
# - name: upload image tar artifact
# uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
# with:
# name: pepr-img.tar
# path: pepr-img.tar
# retention-days: 1
# soak-test:
# name: soak-test
# runs-on: ubuntu-latest
# needs:
# - pepr-build
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1
# with:
# egress-policy: audit
# - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
# - name: "install k3d"
# run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
# shell: bash
# - name: dowload image tar artifact
# uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
# with:
# name: pepr-img.tar
# path: ${{ github.workspace }}
# - name: import pepr image from tar
# run: |
# PEPR_TAR="${GITHUB_WORKSPACE}/pepr-img.tar"
# echo "PEPR_TAR=${PEPR_TAR}" >> "$GITHUB_ENV"
# docker image load --input "$PEPR_TAR"
# - name: Create k3d Cluster
# run: "k3d cluster create"
# shell: bash
# - name: Import pepr image into k3d
# run: "k3d image import pepr:dev -c k3s-default"
# shell: bash
# - name: Install istioctl
# run: |
# curl -L https://istio.io/downloadIstio | sh -
# shell: bash
# - name: Install default profile
# run: |
# cd istio*/bin
# ./istioctl install --set profile=demo -y
# - name: Set up Kubernetes
# uses: azure/setup-kubectl@3e0aec4d80787158d308d7b364cb1b702e7feb7f # v4.0.0
# with:
# version: 'latest'
# - name: Create logs directory
# run: mkdir -p logs
# - name: Deploy applications
# run: |
# kubectl apply -f hack/auditor.ci.yaml
# kubectl apply -f hack/soak.ci.yaml
# - name: Wait for 15 minutes before starting pod checks
# run: |
# sleep 10s
# kubectl wait --for=condition=ready -n istio-system pod -l istio=pilot
# kubectl wait --for=condition=ready -n istio-system pod -l app=istio-ingressgateway
# kubectl wait --for=condition=ready -n watch-auditor pod -l app=watch-auditor
# kubectl wait --for=condition=ready -n pepr-system pod -l app=pepr-soak-ci-watcher
# - name: Run the soak test and collect metrics
# run: |
# # Initialize the map to store pod counts
# declare -A pod_map
# update_pod_map() {
# for pod in $(kubectl get pods -n pepr-demo -o jsonpath='{.items[*].metadata.name}'); do
# count=${pod_map[$pod]}
# if [ -z "$count" ]; then
# pod_map[$pod]=1
# else
# pod_map[$pod]=$((count + 1))
# fi
# done
# }
# touch logs/auditor-log.txt
# touch logs/informer-log.txt
# update_pod_map
# collect_metrics() {
# kubectl exec metrics-collector -n watch-auditor -- curl watch-auditor:8080/metrics | grep watch_controller_failures_total > logs/auditor-log.txt
# kubectl exec metrics-collector -n watch-auditor -- curl -k https://pepr-soak-ci-watcher.pepr-system.svc.cluster.local/metrics | egrep -E "pepr_cache_miss|pepr_resync_failure_count" > logs/informer-log.txt
# }
# # Start collecting metrics every 5 minutes and checking pod counts every 30 minutes
# for i in {1..27}; do # 27 iterations cover 135 minutes (2 hours and 15 minutes)
# collect_metrics
# cat logs/informer-log.txt
# cat logs/auditor-log.txt
# if [ $((i % 6)) -eq 0 ]; then # Every 30 minutes
# update_pod_map
# # Verify that no pod's count exceeds 1
# for pod in "${!pod_map[@]}"; do
# if [ "${pod_map[$pod]}" -gt 1 ]; then
# echo "Test failed: Pod $pod has count ${pod_map[$pod]}"
# exit 1
# fi
# done
# fi
# sleep 300s # Sleep for 5 minutes before the next iteration
# done
# echo "Soak test passed successfully!"
# shell: bash
# - name: Upload logs
# uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6
# with:
# name: soak-test-logs
# path: logs