Skip to content

Commit 45c9aa3

Browse files
committed
add additional label and annotation check to minimal RBAC install test
1 parent 790e9a3 commit 45c9aa3

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/build-test.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ jobs:
691691
--shared-password password \
692692
--kotsadm-registry ttl.sh \
693693
--kotsadm-namespace automated-${{ github.run_id }} \
694+
--additional-labels testlabel1=testvalue1
695+
--additional-labels test.label/two=test.value/two
696+
--additional-annotations testannotation1=testannotationvalue1
697+
--additional-annotations test.annotation/two=testannotation.value/two
694698
--kotsadm-tag 24h | tee output.txt
695699
696700
if ! grep -q "The Kubernetes RBAC policy that the Admin Console is running with does not have access to complete the Preflight Checks. It's recommended that you run these manually before proceeding." output.txt; then
@@ -731,6 +735,74 @@ jobs:
731735
kubectl get clusterrolebinding
732736
exit 1
733737
fi
738+
739+
# check that the kotsadm, minio and rqlite pods have the correct labels and annotations
740+
echo "Checking additional pod labels and annotations"
741+
# label one
742+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.labels.testlabel1}' | grep -q testvalue1; then
743+
echo "kotsadm pod does not have the correct testlabel1 label"
744+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.labels}'
745+
exit 1
746+
fi
747+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.labels.testlabel1}' | grep -q testvalue1; then
748+
echo "kotsadm-minio pod does not have the correct testlabel1 label"
749+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.labels}'
750+
exit 1
751+
fi
752+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.labels.testlabel1}' | grep -q testvalue1; then
753+
echo "kotsadm-rqlite pod does not have the correct testlabel1 label"
754+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.labels}'
755+
exit 1
756+
fi
757+
# annotation one
758+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.annotations.testannotation1}' | grep -q testannotationvalue1; then
759+
echo "kotsadm pod does not have the correct testannotation1 annotation"
760+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.annotations}'
761+
exit 1
762+
fi
763+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.annotations.testannotation1}' | grep -q testannotationvalue1; then
764+
echo "kotsadm-minio pod does not have the correct testannotation1 annotation"
765+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.annotations}'
766+
exit 1
767+
fi
768+
if ! kubectl get pods -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.annotations.testannotation1}' | grep -q testannotationvalue1; then
769+
echo "kotsadm-rqlite pod does not have the correct testannotation1 annotation"
770+
kubectl get pods -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.annotations}'
771+
exit 1
772+
fi
773+
# label two
774+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.labels.test\.label/two}' | grep -q 'test.value/two'; then
775+
echo "kotsadm pod does not have the correct test.label/two label"
776+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.labels}'
777+
exit 1
778+
fi
779+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.labels.test\.label/two}' | grep -q 'test.value/two'; then
780+
echo "kotsadm-minio pod does not have the correct test.label/two label"
781+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.labels}'
782+
exit 1
783+
fi
784+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.labels.test\.label/two}' | grep -q 'test.value/two'; then
785+
echo "kotsadm-rqlite pod does not have the correct test.label/two label"
786+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.labels}'
787+
exit 1
788+
fi
789+
# annotation two
790+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.annotations.test\.annotation/two}' | grep -q 'testannotation.value/two'; then
791+
echo "kotsadm pod does not have the correct test.annotation/two annotation"
792+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm -o jsonpath='{.items[0].metadata.annotations}'
793+
exit 1
794+
fi
795+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.annotations.test\.annotation/two}' | grep -q 'testannotation.value/two'; then
796+
echo "kotsadm-minio pod does not have the correct test.annotation/two annotation"
797+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm-minio -o jsonpath='{.items[0].metadata.annotations}'
798+
exit 1
799+
fi
800+
if ! kubectl get pod -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.annotations.test\.annotation/two}' | grep -q 'testannotation.value/two'; then
801+
echo "kotsadm-rqlite pod does not have the correct test.annotation/two annotation"
802+
kubectl get pod -n "$APP_SLUG" -l app=kotsadm-rqlite -o jsonpath='{.items[0].metadata.annotations}'
803+
exit 1
804+
fi
805+
echo "additional pod labels and annotations are present"
734806
735807
- name: Generate support bundle on failure
736808
if: failure()

0 commit comments

Comments
 (0)