kubeasz/roles/flannel/templates/kube-flannel.yaml.j2

167 lines
3.5 KiB
Plaintext
Raw Normal View History

2017-12-30 20:19:50 +08:00
---
kind: ClusterRole
2019-02-15 14:47:43 +08:00
apiVersion: rbac.authorization.k8s.io/v1beta1
2017-12-30 20:19:50 +08:00
metadata:
name: flannel
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
---
kind: ClusterRoleBinding
2019-02-15 14:47:43 +08:00
apiVersion: rbac.authorization.k8s.io/v1beta1
2017-12-30 20:19:50 +08:00
metadata:
name: flannel
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: flannel
subjects:
- kind: ServiceAccount
name: flannel
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: flannel
namespace: kube-system
---
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: |
{
2018-01-02 22:12:51 +08:00
"Network": "{{ CLUSTER_CIDR }}",
2017-12-30 20:19:50 +08:00
"Backend": {
2018-01-04 22:50:09 +08:00
"Type": "{{ FLANNEL_BACKEND }}"
2017-12-30 20:19:50 +08:00
}
}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
2019-02-15 14:47:43 +08:00
name: kube-flannel-ds-amd64
2017-12-30 20:19:50 +08:00
namespace: kube-system
labels:
tier: node
app: flannel
spec:
template:
metadata:
labels:
tier: node
app: flannel
spec:
hostNetwork: true
nodeSelector:
beta.kubernetes.io/arch: amd64
tolerations:
2019-02-15 14:47:43 +08:00
- operator: Exists
2017-12-30 20:19:50 +08:00
effect: NoSchedule
serviceAccountName: flannel
initContainers:
- name: install-cni
2019-02-15 14:47:43 +08:00
image: {{ flanneld_image }}
2017-12-30 20:19:50 +08:00
command:
- cp
args:
- -f
- /etc/kube-flannel/cni-conf.json
- /etc/cni/net.d/10-flannel.conflist
volumeMounts:
- name: cni
mountPath: /etc/cni/net.d
- name: flannel-cfg
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: {{ flanneld_image }}
2017-12-30 20:19:50 +08:00
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
securityContext:
privileged: true
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
{% if NODE_WITH_MULTIPLE_NETWORKS == 'true' %}
# if hosts have multiple net interfaces, set following two ENVs
2018-04-17 21:02:44 +08:00
- name: KUBERNETES_SERVICE_HOST
2018-04-19 08:48:44 +08:00
value: "{{ MASTER_IP }}"
#value: "{{ KUBE_APISERVER.split(':')[1].lstrip('/') }}"
2018-04-17 21:02:44 +08:00
- name: KUBERNETES_SERVICE_PORT
2018-04-19 08:48:44 +08:00
value: "{{ KUBE_APISERVER.split(':')[2] }}"
{% endif %}
2017-12-30 20:19:50 +08:00
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