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.1 '
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'
@@ -108,43 +108,46 @@ jobs:
108108 echo "INFO: status:"
109109 kubectl get pods
110110 echo "INFO: logs:"
111- kubectl logs --selector=$3 --all-containers=true
111+ kubectl logs --selector=$3 --all-containers=true
112112 exit 1
113113 fi
114114 return ${?}
115115 }
116116 echo "Waiting for init job..."
117- to_complete "condition=Complete" job "defectdojo.org/component=initializer"
117+ to_complete "condition=Complete" job "defectdojo.org/component=initializer"
118118 echo "Waiting for celery pods..."
119- to_complete "condition=ready" pod "defectdojo.org/component=celery"
119+ to_complete "condition=ready" pod "defectdojo.org/component=celery"
120120 echo "Waiting for django pod..."
121- to_complete "condition=ready" pod "defectdojo.org/component=django"
121+ to_complete "condition=ready" pod "defectdojo.org/component=django"
122122 echo "Pods up and ready to rumbole"
123123 kubectl get pods
124+
125+ - name : Test login page
126+ timeout-minutes : 10
127+ run : |-
124128 RETRY=0
125129 while :
126130 do
127131 DJANGO_IP=$(kubectl get svc defectdojo-django -o jsonpath='{.spec.clusterIP}')
128132 OUT=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
129- --overrides='{ "apiVersion": "v1" }' \
130133 --restart=Never -i --rm -- \
131134 --silent \
132135 --max-time 20 \
133136 --head \
134137 --header "Host: $DD_HOSTNAME" \
135- http://$DJANGO_IP/login?next=/)
138+ " http://${ DJANGO_IP} /login?next=/" )
136139 echo $OUT
137- CR=` echo $OUT | egrep "^HTTP" | cut -d' ' -f2`
140+ CR=$( echo $OUT | egrep "^HTTP" | cut -d' ' -f2)
138141 echo $CR
139142 if [[ $CR -ne 200 ]]; then
140143 echo $RETRY
141144 if [[ $RETRY -gt 2 ]]; then
142145 kubectl get pods
143- 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)
144147 echo "ERROR: cannot display login screen; got HTTP code $CR"
145148 exit 1
146149 else
147- ((RETRY++ ))
150+ RETRY=$ ((RETRY+1 ))
148151 echo "Attempt $RETRY to get login page"
149152 sleep 5
150153 fi
@@ -153,29 +156,51 @@ jobs:
153156 break
154157 fi
155158 done
159+
160+ - name : Test API auth call
161+ timeout-minutes : 10
162+ run : |-
156163 ADMIN_PASS=$(kubectl get secret/defectdojo -o jsonpath='{.data.DD_ADMIN_PASSWORD}' | base64 -d)
157164 echo "Simple API check"
158165 DJANGO_IP=$(kubectl get svc defectdojo-django -o jsonpath='{.spec.clusterIP}')
159- CR=$(kubectl run curl --quiet=true --image=curlimages/curl:8.15.0 \
160- --overrides='{ "apiVersion": "v1" }' \
161- --restart=Never -i --rm -- \
162- --silent \
163- --max-time 20 \
164- --header "Host: $DD_HOSTNAME" \
165- --data-raw "username=admin&password=$ADMIN_PASS" \
166- --output /dev/null \
167- --write-out "%{http_code}\n" \
168- http://$DJANGO_IP/api/v2/api-token-auth/)
169- echo $CR
170- if [[ $CR -ne 200 ]]; then
171- echo "ERROR: login is not possible; got HTTP code $CR"
172- exit 1
173- else
174- echo "Result received"
175- 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 : |-
176201 echo "Final Check of components"
177- errors=` kubectl get pods | grep Error | awk '{print $1}'`
178- if [[ ! -z $errors ]]; then
202+ errors=$( kubectl get pods | grep Error | awk '{print $1}')
203+ if [[ ! -z $errors ]]; then
179204 echo "Few pods with errors"
180205 for line in $errors; do
181206 echo "Dumping log from $line"
@@ -185,3 +210,11 @@ jobs:
185210 else
186211 echo "DD K8S successfully deployed"
187212 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