2017-12-16 03:37:45 +00:00
|
|
|
package templates
|
2017-11-18 12:51:28 +00:00
|
|
|
|
2017-12-16 03:37:45 +00:00
|
|
|
const FlannelTemplate = `
|
|
|
|
{{- if eq .RBACConfig "rbac"}}
|
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
|
|
|
name: flannel
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: ClusterRole
|
|
|
|
name: flannel
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: flannel
|
|
|
|
namespace: kube-system
|
|
|
|
---
|
|
|
|
kind: ClusterRole
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
metadata:
|
|
|
|
name: flannel
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- pods
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- nodes
|
|
|
|
verbs:
|
|
|
|
- list
|
|
|
|
- watch
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- nodes/status
|
|
|
|
verbs:
|
|
|
|
- patch
|
|
|
|
{{- end}}
|
2017-11-18 12:51:28 +00:00
|
|
|
---
|
|
|
|
kind: ConfigMap
|
|
|
|
apiVersion: v1
|
|
|
|
metadata:
|
|
|
|
name: kube-flannel-cfg
|
|
|
|
namespace: "kube-system"
|
|
|
|
labels:
|
|
|
|
tier: node
|
|
|
|
app: flannel
|
|
|
|
data:
|
|
|
|
cni-conf.json: |
|
|
|
|
{
|
|
|
|
"name":"cbr0",
|
|
|
|
"cniVersion":"0.3.1",
|
|
|
|
"plugins":[
|
|
|
|
{
|
|
|
|
"type":"flannel",
|
|
|
|
"delegate":{
|
|
|
|
"forceAddress":true,
|
|
|
|
"isDefaultGateway":true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type":"portmap",
|
|
|
|
"capabilities":{
|
|
|
|
"portMappings":true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
net-conf.json: |
|
|
|
|
{
|
2017-12-16 03:37:45 +00:00
|
|
|
"Network": "{{.ClusterCIDR}}",
|
2017-11-18 12:51:28 +00:00
|
|
|
"Backend": {
|
|
|
|
"Type": "vxlan"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
---
|
|
|
|
apiVersion: extensions/v1beta1
|
|
|
|
kind: DaemonSet
|
|
|
|
metadata:
|
|
|
|
name: kube-flannel
|
|
|
|
namespace: "kube-system"
|
|
|
|
labels:
|
|
|
|
tier: node
|
|
|
|
k8s-app: flannel
|
|
|
|
spec:
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
tier: node
|
|
|
|
k8s-app: flannel
|
|
|
|
spec:
|
2017-12-14 21:56:19 +00:00
|
|
|
serviceAccountName: flannel
|
2017-11-18 12:51:28 +00:00
|
|
|
containers:
|
|
|
|
- name: kube-flannel
|
2017-12-16 03:37:45 +00:00
|
|
|
image: {{.Image}}
|
2017-11-18 12:51:28 +00:00
|
|
|
imagePullPolicy: IfNotPresent
|
|
|
|
resources:
|
|
|
|
limits:
|
|
|
|
cpu: 300m
|
|
|
|
memory: 500M
|
|
|
|
requests:
|
|
|
|
cpu: 150m
|
|
|
|
memory: 64M
|
2017-12-16 03:37:45 +00:00
|
|
|
{{- if .FlannelInterface}}
|
|
|
|
command: ["/opt/bin/flanneld","--ip-masq","--kube-subnet-mgr","--iface={{.FlannelInterface}}"]
|
|
|
|
{{- else}}
|
|
|
|
command: ["/opt/bin/flanneld","--ip-masq","--kube-subnet-mgr"]
|
|
|
|
{{- end}}
|
2017-11-18 12:51:28 +00:00
|
|
|
securityContext:
|
|
|
|
privileged: true
|
|
|
|
env:
|
|
|
|
- name: POD_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: metadata.name
|
|
|
|
- name: POD_NAMESPACE
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
volumeMounts:
|
|
|
|
- name: run
|
|
|
|
mountPath: /run
|
|
|
|
- name: cni
|
|
|
|
mountPath: /etc/cni/net.d
|
|
|
|
- name: flannel-cfg
|
|
|
|
mountPath: /etc/kube-flannel/
|
|
|
|
- name: install-cni
|
2017-12-16 03:37:45 +00:00
|
|
|
image: {{.CNIImage}}
|
2017-11-18 12:51:28 +00:00
|
|
|
command: ["/install-cni.sh"]
|
|
|
|
env:
|
|
|
|
# The CNI network config to install on each node.
|
|
|
|
- name: CNI_NETWORK_CONFIG
|
|
|
|
valueFrom:
|
|
|
|
configMapKeyRef:
|
|
|
|
name: kube-flannel-cfg
|
|
|
|
key: cni-conf.json
|
|
|
|
- name: CNI_CONF_NAME
|
|
|
|
value: "10-flannel.conflist"
|
|
|
|
volumeMounts:
|
|
|
|
- name: cni
|
|
|
|
mountPath: /host/etc/cni/net.d
|
|
|
|
- name: host-cni-bin
|
|
|
|
mountPath: /host/opt/cni/bin/
|
|
|
|
hostNetwork: true
|
|
|
|
tolerations:
|
2018-05-31 21:06:59 +00:00
|
|
|
- key: node-role.kubernetes.io/controlplane
|
2017-11-18 12:51:28 +00:00
|
|
|
operator: Exists
|
2018-06-22 04:04:07 +00:00
|
|
|
effect: NoSchedule
|
2018-01-20 21:45:32 +00:00
|
|
|
- key: node-role.kubernetes.io/etcd
|
|
|
|
operator: Exists
|
2018-02-01 21:28:31 +00:00
|
|
|
effect: NoExecute
|
2017-11-18 12:51:28 +00:00
|
|
|
volumes:
|
|
|
|
- name: run
|
|
|
|
hostPath:
|
|
|
|
path: /run
|
|
|
|
- name: cni
|
|
|
|
hostPath:
|
|
|
|
path: /etc/cni/net.d
|
|
|
|
- name: flannel-cfg
|
|
|
|
configMap:
|
|
|
|
name: kube-flannel-cfg
|
|
|
|
- name: host-cni-bin
|
|
|
|
hostPath:
|
|
|
|
path: /opt/cni/bin
|
|
|
|
updateStrategy:
|
|
|
|
rollingUpdate:
|
|
|
|
maxUnavailable: 20%
|
2017-12-14 21:56:19 +00:00
|
|
|
type: RollingUpdate
|
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: ServiceAccount
|
|
|
|
metadata:
|
|
|
|
name: flannel
|
|
|
|
namespace: kube-system`
|