forked from wenhuizhang/confidential-cloud-native-primitives
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-ccnp.sh
executable file
·134 lines (106 loc) · 3.76 KB
/
deploy-ccnp.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
DOCKER_REPO=docker.io/library
NFD_NAME=node-feature-discovery
NFD_NS=node-feature-discovery
NFD_URL=https://kubernetes-sigs.github.io/node-feature-discovery/charts
WORK_DIR=$(cd "$(dirname "$0")" || exit; pwd)
tag=latest
delete_force=false
function usage {
cat << EOM
usage: $(basename "$0") [OPTION]...
-r <registry prefix> the prefix string for registry
-g <tag> container image tag
-d Delete existing CCNP and install new CCNP
EOM
exit 1
}
function process_args {
while getopts ":r:g:hd" option; do
case "${option}" in
r) registry=${OPTARG};;
g) tag=${OPTARG};;
d) delete_force=true;;
h) usage;;
*) echo "Invalid option: -${OPTARG}" >&2
usage
;;
esac
done
if [[ -z "$registry" ]]; then
echo "Error: Please specify your docker registry via -r <registry prefix>."
exit 1
fi
}
function check_env {
if ! command -v helm &> /dev/null
then
echo "Helm could not be found. Please install Helm."
exit
fi
if ! command -v kubectl &> /dev/null
then
echo "Kubectl could not be found. Please install K8S."
exit
fi
}
function delete_ccnp {
pushd "${WORK_DIR}/../.." || exit
echo "-----------Delete ccnp device plugin and NFD..."
helm uninstall $NFD_NAME --namespace $NFD_NS
helm uninstall ccnp-device-plugin
echo "-----------Delete ccnp eventlog server..."
kubectl delete -f deployment/manifests/eventlog-server-deployment.yaml
echo "-----------Delete ccnp measurement server..."
kubectl delete -f deployment/manifests/measurement-server-deployment.yaml
echo "-----------Delete ccnp quote server..."
kubectl delete -f deployment/manifests/quote-server-deployment.yaml
echo "-----------Delete ccnp namespace..."
kubectl delete -f deployment/manifests/namespace.yaml
popd || exit
}
function deploy_ccnp {
pushd "${WORK_DIR}/../.." || exit
# Generate temporary yaml files for deployment
mkdir -p temp_manifests
cp deployment/manifests/* temp_manifests/
#If private repo is used, modify the images' names in the yaml files
if [[ -n "$registry" ]]; then
sed -i "s#${DOCKER_REPO}#${registry}#g" temp_manifests/*
sed -i "s#${DOCKER_REPO}#${registry}#g" device-plugin/ccnp-device-plugin/deploy/helm/ccnp-device-plugin/values.yaml
fi
if [[ "$tag" != "latest" ]]; then
sed -i "s#latest#${tag}#g" temp_manifests/*
sed -i "s#latest#${tag}#g" device-plugin/ccnp-device-plugin/deploy/helm/ccnp-device-plugin/values.yaml
fi
#Deploy CCNP Dependencies
helm repo add nfd $NFD_URL
helm repo update
helm install $NFD_NAME nfd/node-feature-discovery --namespace $NFD_NS --create-namespace
kubectl apply -f device-plugin/ccnp-device-plugin/deploy/node-feature-rules.yaml
helm install ccnp-device-plugin device-plugin/ccnp-device-plugin/deploy/helm/ccnp-device-plugin
#Deploy CCNP services
echo "-----------Deploy ccnp namespace..."
kubectl create -f temp_manifests/namespace.yaml
echo "-----------Deploy ccnp eventlog server..."
kubectl create -f temp_manifests/eventlog-server-deployment.yaml
echo "-----------Deploy ccnp measurement server..."
kubectl create -f temp_manifests/measurement-server-deployment.yaml
echo "-----------Deploy ccnp quote server..."
kubectl create -f temp_manifests/quote-server-deployment.yaml
# rm -rf temp_manifests
popd || exit
}
check_env
process_args "$@"
echo ""
echo "-------------------------"
echo "tag: ${tag}"
echo "registry: ${registry}"
echo "delete_force: ${delete_force}"
echo "-------------------------"
echo ""
if [[ $delete_force == true ]]; then
delete_ccnp
fi
deploy_ccnp