20 lines
610 B
Bash
20 lines
610 B
Bash
#!/bin/bash
|
|||
|
|
# Reusable namespace setup script
|
||
|
|
# Creates namespace and applies pod-security policy labels
|
||
|
|
# Usage: bash k8s/base/namespace-setup.sh <namespace> [<namespace2> ...]
|
||
|
|
set -euo pipefail
|
||
|
|
|
||
|
|
if [ $# -eq 0 ]; then
|
||
|
|
echo "Usage: $0 <namespace> [<namespace2> ...]" >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
for namespace in "$@"; do
|
||
|
|
kubectl create namespace "$namespace" --dry-run=client -o yaml | kubectl apply -f -
|
||
|
|
kubectl label namespace "$namespace" \
|
||
|
|
pod-security.kubernetes.io/enforce=privileged \
|
||
|
|
pod-security.kubernetes.io/enforce-version=latest \
|
||
|
|
--overwrite
|
||
|
|
echo "✓ Namespace '$namespace' ready"
|
||
|
|
done
|