-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathdeploy.sh
executable file
·115 lines (96 loc) · 2.6 KB
/
deploy.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
#!/bin/bash
set -e
usage=$'Run "./deploy install" to install Project Narrows. Please set --build-source if needs build from scratch.'
source deployments/common.sh
set +o noglob
with_portal=true
build_source=$false
install=$false
uninstall=$false
if [ $# -eq 0 ]; then
error "$usage"
fi
DIR="$(cd "$(dirname "$0")" && pwd)"
source $DIR/deployments/common.sh
function install_redis() {
note "Installing redis"
check_helm
helm install cnsi-scanner --set auth.enabled=false --set tls.authClients=false oci://registry-1.docker.io/bitnamicharts/redis -n cnsi-system --create-namespace
success "Redis installed"
}
function uninstall_redis() {
note "Uninstalling redis"
check_helm
helm uninstall cnsi-scanner -n cnsi-system || :
success "Redis uninstalled"
}
function install_opensearch() {
note "Installing opensearch"
check_helm
helm repo add opensearch https://opensearch-project.github.io/helm-charts/
helm repo update
helm install opensearch-deployment-for-narrows opensearch/opensearch -n opensearch --version 2.8.0 --create-namespace --set persistence.enabled=false
success "OpenSearch installed"
}
function uninstall_opensearch() {
note "Uninstalling opensearch"
check_helm
helm repo add opensearch https://opensearch-project.github.io/helm-charts/
helm uninstall opensearch-deployment-for-narrows -n opensearch || :
success "OpenSearch uninstalled"
}
while [ $# -gt 0 ]; do
case $1 in
--help)
note "$usage"
exit 0;;
install)
install=true;;
--build-source)
check_golang
build_source=true;;
uninstall)
uninstall=true;;
*)
note "$usage"
exit 1;;
esac
shift || true
done
if [ $install ] && [ $with_portal ]
then
check_kubectl
install_opensearch
install_redis
note "Installing Project Narrows"
make install
success "Project Narrows installed"
fi
if [ $install ] && [ $with_portal != "true" ]
then
check_kubectl
install_opensearch
install_redis
note "Installing Project Narrows"
make install
success "Project Narrows installed"
fi
if [ $install ] && [ $build_source ]
then
check_kubectl
check_docker
note "Docker build images"
make docker-build-all
note "Deploying ..."
make deploy
success "Project Narrows installed"
fi
if [ $uninstall ]
then
check_kubectl
uninstall_opensearch
uninstall_redis
note "Uninstalling Project Narrows..."
make uninstall
success "Project Narrows uninstalled"
fi