feat: inject default namespaces during bootstrap
This commit is contained in:
parent
4048625b60
commit
2c79888a1c
@ -33,7 +33,7 @@ function wait_for() {
|
|||||||
|
|
||||||
function chart_location() {
|
function chart_location() {
|
||||||
if [ -z "$LOCATION" ]; then
|
if [ -z "$LOCATION" ]; then
|
||||||
echo "$1 --repo https://zero-down-time.github.io/kubezero"
|
echo "$1 --repo https://cdn.zero-downtime.net/charts"
|
||||||
else
|
else
|
||||||
echo "$LOCATION/$1"
|
echo "$LOCATION/$1"
|
||||||
fi
|
fi
|
||||||
@ -72,15 +72,20 @@ function _crds() {
|
|||||||
# helm template | kubectl apply -f -
|
# helm template | kubectl apply -f -
|
||||||
# confine to one namespace if possible
|
# confine to one namespace if possible
|
||||||
function apply(){
|
function apply(){
|
||||||
helm template $(chart_location $chart) -n $namespace --name-template $module $targetRevision --skip-crds -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION $@ > $TMPDIR/helm.yaml
|
helm template $(chart_location $chart) -n $namespace --name-template $module $targetRevision --skip-crds -f $TMPDIR/values.yaml $API_VERSIONS $KUBE_VERSION $@ \
|
||||||
|
| python3 -c '
|
||||||
|
#!/usr/bin/python3
|
||||||
|
import yaml
|
||||||
|
import sys
|
||||||
|
|
||||||
# If resources are in more than ONE $namespace, apply without restrictions
|
for manifest in yaml.safe_load_all(sys.stdin):
|
||||||
nr_ns=$(grep -e '^ namespace:' $TMPDIR/helm.yaml | sed "s/\"//g" | sort | uniq | wc -l)
|
if manifest:
|
||||||
if [ $nr_ns -gt 1 ]; then
|
if "metadata" in manifest and "namespace" not in manifest["metadata"]:
|
||||||
kubectl $action -f $TMPDIR/helm.yaml && rc=$? || rc=$?
|
manifest["metadata"]["namespace"] = sys.argv[1]
|
||||||
else
|
print("---")
|
||||||
kubectl $action --namespace $namespace -f $TMPDIR/helm.yaml && rc=$? || rc=$?
|
print(yaml.dump(manifest))' $namespace > $TMPDIR/helm.yaml
|
||||||
fi
|
|
||||||
|
kubectl $action -f $TMPDIR/helm.yaml && rc=$? || rc=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user