Skip to content

Commit 79f37d4

Browse files
chore(ci): improve generate kubeconfig for nested cluster (#2397)
Description Update gen-kubeconfig.sh to search for the kubernetes-api ingress in kube-system as a fallback after d8-user-authn. -------------- Signed-off-by: Nikita Korolev <nikita.korolev@flant.com>
1 parent 8453008 commit 79f37d4

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

test/dvp-static-cluster/scripts/gen-kubeconfig.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,19 @@ log_success "SA, Secrets and ClusterAuthorizationRule applied"
161161

162162
kubeconfig_cert_cluster_section() {
163163
log_info "Set cluster config"
164+
165+
local api_host
166+
if api_host=$(kubectl -n d8-user-authn get ing kubernetes-api -ojson 2>/dev/null | jq -r '.spec.rules[].host' | head -1) && [ -n "$api_host" ]; then
167+
log_info "Found kubernetes-api ingress in d8-user-authn"
168+
elif api_host=$(kubectl -n kube-system get ing kubernetes-api -ojson 2>/dev/null | jq -r '.spec.rules[].host' | head -1) && [ -n "$api_host" ]; then
169+
log_info "Found kubernetes-api ingress in kube-system"
170+
else
171+
exit_with_error "kubernetes-api ingress not found in d8-user-authn or kube-system"
172+
fi
173+
164174
kubectl config set-cluster "${CLUSTER_NAME}" \
165175
--insecure-skip-tls-verify=true \
166-
--server=https://"$(kubectl -n d8-user-authn get ing kubernetes-api -ojson | jq '.spec.rules[].host' -r)" \
176+
--server=https://"${api_host}" \
167177
--kubeconfig="${FILE_NAME}"
168178
}
169179

0 commit comments

Comments
 (0)