Skip to content

Commit 5ebed95

Browse files
authored
fix: Kes deployment test (#1135)
1 parent d5c19fb commit 5ebed95

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

.github/workflows/kubernetes-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ jobs:
389389
with:
390390
go-version: ${{ matrix.go-version }}
391391

392-
- name: Prometheus test on Kind
392+
- name: Tenant KES
393393
run: |
394394
"${GITHUB_WORKSPACE}/testing/console-tenant+kes.sh"
395395

testing/common.sh

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ sudo chmod +x /usr/local/bin/kubectl
2424
sudo curl -#L "https://dl.min.io/client/mc/release/linux-amd64/mc" -o /usr/local/bin/mc
2525
sudo chmod +x /usr/local/bin/mc
2626

27+
## Install yq
28+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
29+
sudo chmod a+x /usr/local/bin/yq
30+
2731
yell() { echo "$0: $*" >&2; }
2832

2933
die() {

testing/console-tenant+kes.sh

+21-4
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,39 @@ function test_kes_tenant() {
9090
echo "Port Forwarding console"
9191
kubectl -n minio-operator port-forward svc/console 9090 &
9292

93-
SA_TOKEN=$(kubectl -n minio-operator get secret $(kubectl -n minio-operator get serviceaccount console-sa -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}" | base64 --decode)
93+
# Beginning Kubernetes 1.24 ----> Service Account Token Secrets are not
94+
# automatically generated, to generate them manually, users must manually
95+
# create the secret, for our examples where we lead people to get the JWT
96+
# from the console-sa service account, they additionally need to manually
97+
# generate the secret via
98+
# Don't apply the entire file: kubectl apply -f "${SCRIPT_DIR}/../resources/base/console-ui.yaml"
99+
# Because you will get 500 due to:
100+
# CREDENTIALS: {"code":500,"detailedMessage":"secrets is forbidden: User \"system:serviceaccount:minio-operator:console-sa\"
101+
# cannot create resource \"secrets\" in API group \"\" in the namespace \"default\"","message":"an errors occurred, please try again"}
102+
RESOURCE=$(yq e 'select(.kind == "Secret")' "${SCRIPT_DIR}/../resources/base/console-ui.yaml")
103+
echo $RESOURCE | kubectl apply -f -
104+
SA_TOKEN=$(kubectl -n minio-operator get secret console-sa-secret -o jsonpath="{.data.token}" | base64 --decode)
105+
echo "SA_TOKEN: ${SA_TOKEN}"
106+
if [ -z "$SA_TOKEN" ]
107+
then
108+
echo "\$SA_TOKEN is empty and it cannot be empty!"
109+
return 1
110+
fi
94111

95112
COOKIE=$(curl 'http://localhost:9090/api/v1/login/operator' -X POST \
96113
-H 'Content-Type: application/json' \
97114
--data-raw '{"jwt":"'$SA_TOKEN'"}' -i | grep "Set-Cookie: token=" | sed -e "s/Set-Cookie: token=//g" | awk -F ';' '{print $1}')
115+
echo "COOKIE: ${COOKIE}"
98116

99117
echo "Creating Tenant"
100118
CREDENTIALS=$(curl 'http://localhost:9090/api/v1/tenants' \
101119
-X POST \
102120
-H 'Content-Type: application/json' \
103121
-H 'Cookie: token='$COOKIE'' \
104122
--data-raw '{"name":"kes-tenant","namespace":"default","access_key":"","secret_key":"","access_keys":[],"secret_keys":[],"enable_tls":true,"enable_console":true,"enable_prometheus":true,"service_name":"","image":"","expose_minio":true,"expose_console":true,"pools":[{"name":"pool-0","servers":4,"volumes_per_server":1,"volume_configuration":{"size":26843545600,"storage_class_name":"standard"},"securityContext":null,"affinity":{"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"labelSelector":{"matchExpressions":[{"key":"v1.min.io/tenant","operator":"In","values":["kes-tenant"]},{"key":"v1.min.io/pool","operator":"In","values":["pool-0"]}]},"topologyKey":"kubernetes.io/hostname"}]}}}],"erasureCodingParity":2,"logSearchConfiguration":{"image":"minio/operator:dev","postgres_image":"","postgres_init_image":""},"prometheusConfiguration":{"image":"","sidecar_image":"","init_image":""},"tls":{"minio":[],"ca_certificates":[],"console_ca_certificates":[]},"encryption":{"replicas":"1","securityContext":{"runAsUser":"1000","runAsGroup":"1000","fsGroup":"1000","runAsNonRoot":true},"image":"","vault":{"endpoint":"http://vault.default.svc.cluster.local:8200","engine":"","namespace":"","prefix":"my-minio","approle":{"engine":"","id":"'$ROLE_ID'","secret":"'$SECRET_ID'","retry":0},"tls":{},"status":{"ping":0}}},"idp":{"keys":[{"access_key":"console","secret_key":"console123"}]}}')
123+
echo "CREDENTIALS: ${CREDENTIALS}"
105124
106-
107-
echo $CREDENTIALS
108-
125+
echo "Check Tenant Status in default name space for kes-tenant:"
109126
check_tenant_status default kes-tenant
110127
111128
echo "Port Forwarding tenant"

0 commit comments

Comments
 (0)