27
27
# are tested (https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html#available-versions)
28
28
- databases : pgsql
29
29
brokers : redis
30
- k8s : ' v1.33.4 '
30
+ k8s : ' v1.34.0 '
31
31
os : debian
32
32
steps :
33
33
- name : Checkout
36
36
- name : Setup Minikube
37
37
uses : manusa/actions-setup-minikube@b589f2d61bf96695c546929c72b38563e856059d # v2.14.0
38
38
with :
39
- minikube version : ' v1.33.1 '
39
+ minikube version : ' v1.37.0 '
40
40
kubernetes version : ${{ matrix.k8s }}
41
41
driver : docker
42
42
start args : ' --addons=ingress --cni calico'
65
65
66
66
- name : Configure HELM repos
67
67
run : |-
68
- helm repo add bitnami https://charts.bitnami.com/bitnami
69
68
helm dependency list ./helm/defectdojo
70
69
helm dependency update ./helm/defectdojo
71
70
@@ -109,43 +108,46 @@ jobs:
109
108
echo "INFO: status:"
110
109
kubectl get pods
111
110
echo "INFO: logs:"
112
- kubectl logs --selector=$3 --all-containers=true
111
+ kubectl logs --selector=$3 --all-containers=true
113
112
exit 1
114
113
fi
115
114
return ${?}
116
115
}
117
116
echo "Waiting for init job..."
118
- to_complete "condition=Complete" job "defectdojo.org/component=initializer"
117
+ to_complete "condition=Complete" job "defectdojo.org/component=initializer"
119
118
echo "Waiting for celery pods..."
120
- to_complete "condition=ready" pod "defectdojo.org/component=celery"
119
+ to_complete "condition=ready" pod "defectdojo.org/component=celery"
121
120
echo "Waiting for django pod..."
122
- to_complete "condition=ready" pod "defectdojo.org/component=django"
121
+ to_complete "condition=ready" pod "defectdojo.org/component=django"
123
122
echo "Pods up and ready to rumbole"
124
123
kubectl get pods
124
+
125
+ - name : Test login page
126
+ timeout-minutes : 10
127
+ run : |-
125
128
RETRY=0
126
129
while :
127
130
do
128
131
DJANGO_IP=$(kubectl get svc defectdojo-django -o jsonpath='{.spec.clusterIP}')
129
132
OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
130
- --overrides='{ "apiVersion": "v1" }' \
131
133
--restart=Never -i --rm -- \
132
134
--silent \
133
135
--max-time 20 \
134
136
--head \
135
137
--header "Host: $DD_HOSTNAME" \
136
- http://$DJANGO_IP/login?next=/)
138
+ " http://${ DJANGO_IP} /login?next=/" )
137
139
echo $OUT
138
- CR=` echo $OUT | egrep "^HTTP" | cut -d' ' -f2`
140
+ CR=$( echo $OUT | egrep "^HTTP" | cut -d' ' -f2)
139
141
echo $CR
140
142
if [[ $CR -ne 200 ]]; then
141
143
echo $RETRY
142
144
if [[ $RETRY -gt 2 ]]; then
143
145
kubectl get pods
144
- echo ` kubectl logs --tail=30 -l defectdojo.org/component=django -c uwsgi`
146
+ echo $( kubectl logs --tail=30 -l defectdojo.org/component=django -c uwsgi)
145
147
echo "ERROR: cannot display login screen; got HTTP code $CR"
146
148
exit 1
147
149
else
148
- ((RETRY++ ))
150
+ RETRY=$ ((RETRY+1 ))
149
151
echo "Attempt $RETRY to get login page"
150
152
sleep 5
151
153
fi
@@ -154,29 +156,51 @@ jobs:
154
156
break
155
157
fi
156
158
done
159
+
160
+ - name : Test API auth call
161
+ timeout-minutes : 10
162
+ run : |-
157
163
ADMIN_PASS=$(kubectl get secret/defectdojo -o jsonpath='{.data.DD_ADMIN_PASSWORD}' | base64 -d)
158
164
echo "Simple API check"
159
165
DJANGO_IP=$(kubectl get svc defectdojo-django -o jsonpath='{.spec.clusterIP}')
160
- CR=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
161
- --overrides='{ "apiVersion": "v1" }' \
162
- --restart=Never -i --rm -- \
163
- --silent \
164
- --max-time 20 \
165
- --header "Host: $DD_HOSTNAME" \
166
- --data-raw "username=admin&password=$ADMIN_PASS" \
167
- --output /dev/null \
168
- --write-out "%{http_code}\n" \
169
- http://$DJANGO_IP/api/v2/api-token-auth/)
170
- echo $CR
171
- if [[ $CR -ne 200 ]]; then
172
- echo "ERROR: login is not possible; got HTTP code $CR"
173
- exit 1
174
- else
175
- echo "Result received"
176
- fi
166
+ RETRY=0
167
+ while :
168
+ do
169
+ OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
170
+ --restart=Never -i --rm -- \
171
+ --dump-header - \
172
+ --no-progress-meter \
173
+ --max-time 20 \
174
+ --header "Host: $DD_HOSTNAME" \
175
+ --data-raw "username=admin&password=$ADMIN_PASS" \
176
+ "http://${DJANGO_IP}/api/v2/api-token-auth/")
177
+ CR=$(echo $OUT | egrep "^HTTP" | cut -d' ' -f2)
178
+ echo "Return code $CR"
179
+ if [[ $CR -ne 200 ]]; then
180
+ echo "Retry: $RETRY"
181
+ if [[ $RETRY -gt 2 ]]; then
182
+ kubectl get pods
183
+ echo $(kubectl logs --tail=30 -l defectdojo.org/component=django -c uwsgi)
184
+ echo "ERROR: cannot perform API login; got HTTP code $CR; Full response:"
185
+ echo $OUT
186
+ exit 1
187
+ else
188
+ RETRY=$((RETRY+1))
189
+ echo "Attempt $RETRY to perform API login"
190
+ sleep 5
191
+ fi
192
+ else
193
+ echo "Result received"
194
+ break
195
+ fi
196
+ done
197
+
198
+ - name : Check of logs
199
+ timeout-minutes : 10
200
+ run : |-
177
201
echo "Final Check of components"
178
- errors=` kubectl get pods | grep Error | awk '{print $1}'`
179
- if [[ ! -z $errors ]]; then
202
+ errors=$( kubectl get pods | grep Error | awk '{print $1}')
203
+ if [[ ! -z $errors ]]; then
180
204
echo "Few pods with errors"
181
205
for line in $errors; do
182
206
echo "Dumping log from $line"
@@ -186,3 +210,11 @@ jobs:
186
210
else
187
211
echo "DD K8S successfully deployed"
188
212
fi
213
+
214
+ - name : Failed Logs
215
+ if : failure()
216
+ run : |-
217
+ echo "ERROR: Here are logs from deployment/defectdojo-django containers:"
218
+ kubectl logs deployment/defectdojo-django --all-pods=true --all-containers=true --tail=100
219
+ echo "And all pod status one more time"
220
+ kubectl get pods
0 commit comments