Skip to content

Commit 8dbdc3e

Browse files
authored
Merge pull request #160 from mintel/create-all-ns
Create local namespaces from rendered manifests
2 parents 1d0f4b0 + 4684e28 commit 8dbdc3e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modules/k8s/local/create-ns.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
K3D_CLUSTER_NAME=${K3D_CLUSTER_NAME:-"local"}
44

5-
if [ "$(k3d cluster list | grep -o -E "^${K3D_CLUSTER_NAME}")" ]; then
5+
if k3d cluster list | grep -q -o -E "^${K3D_CLUSTER_NAME}"; then
66
set +e
7-
namespaces=$(tk env list --json | jq -r '.[].spec.namespace' | sort | uniq)
7+
namespaces="$(find rendered -type f -path '*/manifests/*.yaml' -print0 | xargs -0 -P1 yq eval-all --output-format csv '[.metadata.namespace] | map(select(. != null))' | tr ',' '\n' | sort -u)"
88
while IFS= read -r namespace; do
99
echo "Creating namespace $namespace ....."
10-
out=$(kubectl --context k3d-${K3D_CLUSTER_NAME} create namespace $namespace 2>&1)
10+
out=$(kubectl --context "k3d-${K3D_CLUSTER_NAME}" create namespace "$namespace" 2>&1)
1111
if [[ "$out" == *"AlreadyExists"* ]]; then
1212
echo "Namespace $namespace already exists, skipping"
1313
else

0 commit comments

Comments
 (0)