Skip to content

feat: create NS only if needed #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions scripts/src/functions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,23 @@ ping_kube() {
}

prepare-namespace() {
if [ -z "${KUBE_NAMESPACE}" ]; then
if [[ -z "${KUBE_NAMESPACE}" ]]; then
echo "KUBE_NAMESPACE is missing."
exit 1
fi
echo "Current KUBE_NAMESPACE=${KUBE_NAMESPACE}"
kubectl create ns "$KUBE_NAMESPACE" || true
if ! kubectl get ns "$KUBE_NAMESPACE" >/dev/null 2>&1; then
if ! kubectl auth can-i get namespace >/dev/null 2>&1; then
echo "Failed to check namespace: cluster connection or permissions issue"
exit 1
fi
if ! kubectl create ns "$KUBE_NAMESPACE"; then
echo "Failed to create namespace \"${KUBE_NAMESPACE}\""
exit 1
fi
else
echo "Namespace \"$KUBE_NAMESPACE\" already exists."
fi
}

create-ns-and-developer-role-bindings() {
Expand Down
Loading