-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdeploy-namespaces.sh
More file actions
executable file
·48 lines (44 loc) · 1.07 KB
/
Copy pathdeploy-namespaces.sh
File metadata and controls
executable file
·48 lines (44 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
set -euo pipefail
trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
if [[ -z "${NAMESPACES}" ]]; then
echo >&2 "Error: NAMESPACES environment variable is required"
exit 1
fi
echo "Setting up namespaces: ${NAMESPACES}"
# Create namespaces with appropriate mesh configuration
for ns in ${NAMESPACES}; do
if [[ "${CILIUM_CLUSTER_MESH_ENABLED}" == "yes" ]]; then
# Cilium ClusterMesh doesn't require mesh labels/annotations
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: $ns
EOF
elif [[ "${ISTIO_ENABLED}" == "yes" ]]; then
# Istio uses labels
MESH_LABEL="istio-injection: enabled"
if [[ "$ISTIO_PROFILE" == "ambient" ]]; then
MESH_LABEL="istio.io/dataplane-mode: ambient"
fi
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: $ns
labels:
$MESH_LABEL
EOF
else
# Linkerd uses annotations
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: $ns
annotations:
linkerd.io/inject: enabled
EOF
fi
done