-
Notifications
You must be signed in to change notification settings - Fork 232
/
install.sh
executable file
·253 lines (250 loc) · 5.04 KB
/
install.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/bash
uuid=`uuidgen`
echo ""
read -p "请设置登录后羿运维平台的admin密码:" passwd
if [ -z $passwd ]; then
passwd="tensuns"
echo -e "\n未输入,使用默认密码:\033[31;1mtensuns\033[0m\n"
fi
cat <<EOF > 1.consul-deploy.yaml
apiVersion: v1
kind: Namespace
metadata:
name: tensuns
---
apiVersion: v1
kind: ConfigMap
metadata:
name: consul-config
namespace: tensuns
labels:
app: consul
data:
consul.hcl: |+
log_level = "error"
data_dir = "/consul/data"
client_addr = "0.0.0.0"
ui_config {
enabled = true
}
ports = {
grpc = -1
https = -1
dns = -1
grpc_tls = -1
serf_wan = -1
}
peering {
enabled = false
}
connect {
enabled = false
}
acl = {
enabled = true
default_policy = "deny"
enable_token_persistence = true
tokens {
initial_management = "$uuid"
agent = "$uuid"
}
}
server = true
bootstrap_expect = 1
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: consul
namespace: tensuns
labels:
app: consul
spec:
replicas: 1
selector:
matchLabels:
app: consul
template:
metadata:
labels:
app: consul
spec:
volumes:
- name: consul-config
configMap:
name: consul-config
containers:
- name: consul
image: 'swr.cn-south-1.myhuaweicloud.com/starsl.cn/consul:latest'
args:
- agent
ports:
- name: http
containerPort: 8500
protocol: TCP
env:
- name: TZ
value: Asia/Shanghai
volumeMounts:
- name: consul-data
mountPath: /consul/data
- name: consul-config
mountPath: /consul/config/consul.hcl
subPath: consul.hcl
imagePullPolicy: IfNotPresent
restartPolicy: Always
volumeClaimTemplates:
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: consul-data
namespace: tensuns
annotations:
everest.io/disk-volume-type: SAS
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: csi-disk
volumeMode: Filesystem
serviceName: consul
---
apiVersion: v1
kind: Service
metadata:
name: consul
namespace: tensuns
labels:
app: consul
spec:
ports:
- name: http
protocol: TCP
port: 8500
targetPort: 8500
selector:
app: consul
type: ClusterIP
EOF
cat <<EOF > 2.tensuns-deploy.yaml
apiVersion: v1
kind: Namespace
metadata:
name: tensuns
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: flask-consul
namespace: tensuns
labels:
app: flask-consul
spec:
replicas: 1
selector:
matchLabels:
app: flask-consul
template:
metadata:
labels:
app: flask-consul
spec:
initContainers:
- name: wait-for-consul
image: busybox
command:
- sh
- '-c'
- >-
for i in \$(seq 1 60); do nc -z -w3 consul 8500 && exit 0 ||
sleep 5; done; exit 1
imagePullPolicy: IfNotPresent
containers:
- name: flask-consul
image: 'swr.cn-south-1.myhuaweicloud.com/starsl.cn/flask-consul:latest'
ports:
- name: http-2026
containerPort: 2026
protocol: TCP
env:
- name: admin_passwd
value: '$passwd'
- name: consul_token
value: '$uuid'
- name: consul_url
value: 'http://consul:8500/v1'
- name: log_level
value: INFO
- name: TZ
value: Asia/Shanghai
imagePullPolicy: Always
restartPolicy: Always
---
kind: Service
apiVersion: v1
metadata:
name: flask-consul
namespace: tensuns
labels:
app: flask-consul
spec:
ports:
- name: http-2026
protocol: TCP
port: 2026
targetPort: 2026
selector:
app: flask-consul
type: ClusterIP
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: nginx-consul
namespace: tensuns
labels:
app: nginx-consul
spec:
replicas: 1
selector:
matchLabels:
app: nginx-consul
template:
metadata:
labels:
app: nginx-consul
spec:
containers:
- name: nginx-consul
image: 'swr.cn-south-1.myhuaweicloud.com/starsl.cn/nginx-consul:latest'
ports:
- name: http-1026
containerPort: 1026
protocol: TCP
env:
- name: TZ
value: Asia/Shanghai
imagePullPolicy: Always
restartPolicy: Always
---
kind: Service
apiVersion: v1
metadata:
name: tensuns
namespace: tensuns
labels:
app: tensuns
spec:
ports:
- name: nginx-consul
protocol: TCP
port: 1026
targetPort: 1026
nodePort: 31026
selector:
app: nginx-consul
type: NodePort
externalTrafficPolicy: Cluster
EOF