2727 # are tested (https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html#available-versions)
2828 - databases : pgsql
2929 brokers : redis
30- k8s : ' v1.33.4 '
30+ k8s : ' v1.34.0 '
3131 os : debian
3232 steps :
3333 - name : Checkout
3636 - name : Setup Minikube
3737 uses : manusa/actions-setup-minikube@b589f2d61bf96695c546929c72b38563e856059d # v2.14.0
3838 with :
39- minikube version : ' v1.33.1 '
39+ minikube version : ' v1.37.0 '
4040 kubernetes version : ${{ matrix.k8s }}
4141 driver : docker
4242 start args : ' --addons=ingress --cni calico'
6565
6666 - name : Configure HELM repos
6767 run : |-
68- helm repo add bitnami https://charts.bitnami.com/bitnami
6968 helm dependency list ./helm/defectdojo
7069 helm dependency update ./helm/defectdojo
7170
@@ -109,43 +108,46 @@ jobs:
109108 echo "INFO: status:"
110109 kubectl get pods
111110 echo "INFO: logs:"
112- kubectl logs --selector=$3 --all-containers=true
111+ kubectl logs --selector=$3 --all-containers=true
113112 exit 1
114113 fi
115114 return ${?}
116115 }
117116 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"
119118 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"
121120 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"
123122 echo "Pods up and ready to rumbole"
124123 kubectl get pods
124+
125+ - name : Test login page
126+ timeout-minutes : 10
127+ run : |-
125128 RETRY=0
126129 while :
127130 do
128131 DJANGO_IP=$(kubectl get svc defectdojo-django -o jsonpath='{.spec.clusterIP}')
129132 OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
130- --overrides='{ "apiVersion": "v1" }' \
131133 --restart=Never -i --rm -- \
132134 --silent \
133135 --max-time 20 \
134136 --head \
135137 --header "Host: $DD_HOSTNAME" \
136- http://$DJANGO_IP/login?next=/)
138+ " http://${ DJANGO_IP} /login?next=/" )
137139 echo $OUT
138- CR=` echo $OUT | egrep "^HTTP" | cut -d' ' -f2`
140+ CR=$( echo $OUT | egrep "^HTTP" | cut -d' ' -f2)
139141 echo $CR
140142 if [[ $CR -ne 200 ]]; then
141143 echo $RETRY
142144 if [[ $RETRY -gt 2 ]]; then
143145 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)
145147 echo "ERROR: cannot display login screen; got HTTP code $CR"
146148 exit 1
147149 else
148- ((RETRY++ ))
150+ RETRY=$ ((RETRY+1 ))
149151 echo "Attempt $RETRY to get login page"
150152 sleep 5
151153 fi
@@ -154,29 +156,51 @@ jobs:
154156 break
155157 fi
156158 done
159+
160+ - name : Test API auth call
161+ timeout-minutes : 10
162+ run : |-
157163 ADMIN_PASS=$(kubectl get secret/defectdojo -o jsonpath='{.data.DD_ADMIN_PASSWORD}' | base64 -d)
158164 echo "Simple API check"
159165 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 : |-
177201 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
180204 echo "Few pods with errors"
181205 for line in $errors; do
182206 echo "Dumping log from $line"
@@ -186,3 +210,11 @@ jobs:
186210 else
187211 echo "DD K8S successfully deployed"
188212 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