-
Notifications
You must be signed in to change notification settings - Fork 331
/
template.go
267 lines (262 loc) · 6.5 KB
/
template.go
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/*
* Tencent is pleased to support the open source community by making TKEStack
* available.
*
* Copyright (C) 2012-2019 Tencent. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of the
* License at
*
* https://opensource.org/licenses/Apache-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package galaxy
const (
//GalaxyDaemonsetTemplate decoded as galaxy daemonset
GalaxyDaemonsetTemplate = `
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: galaxy
name: galaxy
namespace: kube-system
spec:
selector:
matchLabels:
app: galaxy
template:
metadata:
labels:
app: galaxy
spec:
serviceAccountName: galaxy
hostNetwork: true
hostPID: true
containers:
- image: galaxy:1.0.0-alpha
command: ["/bin/sh"]
args: ["-c", "cp -p /etc/galaxy/cni/00-galaxy.conf /etc/cni/net.d/; cp -p /opt/cni/galaxy/bin/galaxy-sdn /opt/cni/galaxy/bin/loopback /opt/cni/bin/; /usr/bin/galaxy --logtostderr=true --v=3"]
name: galaxy
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: DOCKER_HOST
value: unix:///host/run/docker.sock
resources:
requests:
cpu: 100m
memory: 200Mi
securityContext:
privileged: true
volumeMounts:
- name: galaxy-run
mountPath: /var/run/galaxy/
- name: containerd-run
mountPropagation: Bidirectional
mountPath: /var/run/netns/
- name: flannel-run
mountPath: /run/flannel
- name: galaxy-log
mountPath: /data/galaxy/logs
- name: galaxy-etc
mountPath: /etc/galaxy
- name: cni-config
mountPath: /etc/cni/net.d/
- name: cni-bin
mountPath: /opt/cni/bin
- name: cni-etc
mountPath: /etc/galaxy/cni
- name: cni-state
mountPath: /var/lib/cni
- name: docker-sock
mountPath: /host/run/
tolerations:
- effect: NoSchedule
operator: Exists
terminationGracePeriodSeconds: 30
volumes:
- name: galaxy-run
hostPath:
path: /var/run/galaxy
- name: flannel-run
hostPath:
path: /run/flannel
- name: containerd-run
hostPath:
path: /var/run/netns
- name: cni-bin-dir
hostPath:
path: /opt/cni/bin
- name: galaxy-log
emptyDir: {}
- configMap:
defaultMode: 420
name: galaxy-etc
name: galaxy-etc
- name: cni-config
hostPath:
path: /etc/cni/net.d/
- name: cni-bin
hostPath:
path: /opt/cni/bin
- name: cni-state
hostPath:
path: /var/lib/cni
- configMap:
defaultMode: 420
name: cni-etc
name: cni-etc
- name: docker-sock
hostPath:
path: /run/
`
//GalaxyCM decoded as galaxy & cni configMap
GalaxyCM = `
apiVersion: v1
kind: ConfigMap
metadata:
name: galaxy-etc
namespace: kube-system
data:
galaxy.json: |
{
"NetworkConf":[
{"name":"tke-route-eni","type":"tke-route-eni","eni":"eth1","routeTable":1},
{"name":"galaxy-flannel","type":"galaxy-flannel", "delegate":{"type":"galaxy-veth"},"subnetFile":"/run/flannel/subnet.env"},
{"name":"galaxy-k8s-vlan","type":"galaxy-k8s-vlan", "device":"{{ .DeviceName }}", "default_bridge_name": "br0"},
{"name":"galaxy-k8s-sriov","type": "galaxy-k8s-sriov", "device": "{{ .DeviceName }}", "vf_num": 10}
],
"DefaultNetworks": ["galaxy-flannel"]
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: cni-etc
namespace: kube-system
data:
00-galaxy.conf: |
{
"name": "galaxy-sdn",
"type": "galaxy-sdn",
"capabilities": {"portMappings": true},
"cniVersion": "0.2.0"
}
`
//FlannelDaemonset decoded as flannel daemonset
FlannelDaemonset = `
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: kube-flannel-ds
namespace: kube-system
labels:
k8s-app: flannel
spec:
selector:
matchLabels:
k8s-app: flannel
template:
metadata:
labels:
k8s-app: flannel
spec:
hostNetwork: true
tolerations:
- operator: Exists
effect: NoSchedule
serviceAccountName: flannel
containers:
- name: kube-flannel
image: {{ .Image }}
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
- --iface={{ .IFace }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "256Mi"
securityContext:
privileged: true
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
volumeMounts:
- name: run
mountPath: /run
- name: flannel-cfg
mountPath: /etc/kube-flannel/
volumes:
- name: run
hostPath:
path: /run
- name: cni
hostPath:
path: /etc/cni/net.d
- name: flannel-cfg
configMap:
name: kube-flannel-cfg
`
//FlannelCM decoded as flannel configMap
FlannelCM = `
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-flannel-cfg
namespace: kube-system
labels:
tier: node
app: flannel
data:
cni-conf.json: |
{
"name": "cbr0",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
net-conf.json: |
{
"Network": "{{ .Network }}",
"Backend": {
"Type": "{{ .Type }}"
}
}
`
)