-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathcustom.sh
More file actions
executable file
·46 lines (35 loc) · 1.03 KB
/
custom.sh
File metadata and controls
executable file
·46 lines (35 loc) · 1.03 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
#!/bin/bash
source setup-env.sh "$@"
CUSTOM_DIR=""
while [[ $# -gt 0 ]]; do
if [[ -z "$CUSTOM_DIR" ]]; then
CUSTOM_DIR="$1"
fi
shift
done
if [ -z "$CUSTOM_DIR" ]; then
echo "Error: CUSTOM_DIR is required."
exit 1
fi
NODE_NAME=""
get_all_nodes() {
kubectl --kubeconfig=$KUBECONFIG get nodes -o jsonpath='{.items[*].metadata.name}'
}
select_node() {
ALL_NODES=$(get_all_nodes)
echo "Select the node to deploy the custom resource to:"
IFS=' ' read -r -a NODE_ARRAY <<< "$ALL_NODES"
for i in "${!NODE_ARRAY[@]}"; do
echo "$((i+1)). ${NODE_ARRAY[$i]}"
done
read -p "Enter the number of the node: " NODE_INDEX
NODE_NAME=${NODE_ARRAY[$((NODE_INDEX-1))]}
echo "Selected node: $NODE_NAME"
}
add_node_selector() {
kubectl --kubeconfig=$KUBECONFIG label node $NODE_NAME 5stack-$CUSTOM_DIR=true
}
select_node
add_node_selector
./kustomize build ./custom/$CUSTOM_DIR | kubectl --kubeconfig=$KUBECONFIG apply -f - --kubeconfig=$KUBECONFIG
echo "Custom resource deployed successfully"