-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_gitlab.sh
More file actions
executable file
·126 lines (100 loc) · 4.13 KB
/
install_gitlab.sh
File metadata and controls
executable file
·126 lines (100 loc) · 4.13 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
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
#!/bin/sh
#如果是host安装按照node的资源选择一个
#nodeip也是同样
REGISTRY=$(docker info |grep 60080 |tr -d ' ')
NODE_NAME=""
NODE_IP=""
potal_path="/root/alauda/gitlab/portal" ###potal的数据目录,一般不需要修改,若有规划,可修改为别的目录
database_path="/root/alauda/gitlab/database" ###database的目录,一般不需要修改,若有规划,可修改为别的目录
redis_path="/root/alauda/gitlab/redis" ###redis的目录,一般不需要修改,若有规划,可修改为别的目录
portal_pvc="portalpvc" ###默认pvc的名字为portalpvc,需要事先在default命名空间下准备好这个pvc,可更改,但也需要事先创建好对应的pvc。
database_pvc="databasepvc" ###默认pvc的名字为databasepvc,需要事先在default命名空间下准备好这个pvc,可更改,但也需要事先创建好对应的pvc。
redis_pvc="redispvc" ###默认pvc的名字为redispvc,需要事先在default命名空间下准备好这个pvc,可更改,但也需要事先创建好对应的pvc。
with_hostpath_values(){
values="""--set global.registry.address=${REGISTRY} \
--set portal.debug=true \
--set gitlabHost=${NODE_IP} \
--set gitlabRootPassword=Gitlab12345 \
--set service.type=NodePort \
--set service.ports.http.nodePort=${http_port} \
--set service.ports.ssh.nodePort=${ssh_port} \
--set service.ports.https.nodePort=${https_port} \
--set portal.persistence.enabled=false \
--set portal.persistence.host.nodeName=${NODE_NAME} \
--set portal.persistence.host.path="$potal_path" \
--set portal.persistence.host.nodeName="${NODE_NAME}" \
--set database.persistence.enabled=false \
--set database.persistence.host.nodeName=${NODE_NAME} \
--set database.persistence.host.path="$database_path" \
--set database.persistence.host.nodeName="${NODE_NAME}" \
--set redis.persistence.enabled=false \
--set redis.persistence.host.nodeName=${NODE_NAME} \
--set redis.persistence.host.path="$redis_path" \
--set redis.persistence.host.nodeName="${NODE_NAME}" \
${sets}
"""
}
with_pvc_values(){
./tools/create_pvc.sh $portal_pvc
./tools/create_pvc.sh $database_pvc
./tools/create_pvc.sh $redis_pvc
values="""--set global.registry.address=${REGISTRY} \
--set portal.debug=true \
--set gitlabHost=${NODE_IP} \
--set gitlabRootPassword=Gitlab12345 \
--set service.type=NodePort \
--set service.ports.http.nodePort=${http_port} \
--set service.ports.ssh.nodePort=${ssh_port} \
--set service.ports.https.nodePort=${https_port} \
--set portal.persistence.enabled=true \
--set portal.persistence.existingClaim=$portal_pvc \
--set database.persistence.enabled=true \
--set database.persistence.existingClaim=$database_pvc \
--set redis.persistence.enabled=true \
--set redis.persistence.existingClaim=$redis_pvc \
${sets}
"""
}
init_nodename(){
NODE_NAME=$(./tools/check_node_name.sh)
NODE_IP=$(./tools/get_nodeip.sh ${NODE_NAME})
echo "NODE_NAME is:$NODE_NAME"
echo "NODE_IP is:$NODE_IP"
}
#main
#input begin
REGISTRY=$(./tools/input_registry.sh $REGISTRY)
namespace=$(./tools/input_namespace.sh)
storage_type=$(./tools/input_storage_type.sh)
name=$(./tools/input_name.sh)
http_port=$(./tools/input_port.sh '请输入http node port[默认为31101]:' 31101)
ssh_port=$(./tools/input_port.sh '请输入ssh node port[默认为31102]:' 31102)
https_port=$(./tools/input_port.sh '请输入https node port[默认为31103]:' 31103)
chart_name=$(./tools/input_chart_name.sh)
chart_version=$(./tools/input_chart_version.sh)
sets=$(./tools/input_sets.sh)
#input end
init_nodename
case $storage_type in
0) with_pvc_values
;;
1) with_hostpath_values
;;
esac
command="""
helm install ${chart_name} ${chart_version}--name ${name} --namespace ${namespace} ${values}
"""
echo """生成的helm命令:$command"""
while [ -z $is_execute ]
do
read -p "是否立即执行['y' or 'n'默认是'y']" is_execute
case $is_execute in
""|"y") is_execute="y"
;;
"n") exit 1
;;
*) unset is_execute
;;
esac
done
$(echo $command)