-
Notifications
You must be signed in to change notification settings - Fork 2
/
create-plugin-ds.sh
30 lines (24 loc) · 1.05 KB
/
create-plugin-ds.sh
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
#!/bin/bash
namespace="gpu-resources"
daemonset="nvidia-device-plugin-daemonset"
# Check if the namespace exists in the cluster
result=$(kubectl get ns -o jsonpath="{.items[?(@.metadata.name=='$namespace')].metadata.name}")
if [[ -n $result ]]; then
echo "$namespace namespace already exists in the cluster"
else
echo "$namespace namespace does not exist in the cluster"
echo "creating $namespace namespace in the cluster..."
kubectl create namespace $namespace
fi
# Check if the daemonset exists
result=$(kubectl get ds -n $namespace -o jsonpath="{.items[?(@.metadata.name=='$daemonset')].metadata.name}")
if [[ -n $result ]]; then
echo "$daemonset daemonset already exists in the $namespace namespace"
echo "deleting $daemonset daemonset from the $namespace namespace..."
kubectl delete ds $daemonset -n $namespace
else
echo "$daemonset daemonset does not exist in the $namespace namespace"
fi
# Create the daemonset
echo "creating $daemonset daemonset in the $namespace namespace..."
kubectl apply -f nvidia-device-plugin-ds.yaml