2017-08-25 15:07:50 +08:00
---
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-flannel-cfg
2020-04-15 14:48:02 +08:00
namespace: kube-system
2017-08-25 15:07:50 +08:00
labels:
tier: node
app: flannel
data:
cni-conf.json: |
{
2020-04-15 14:48:02 +08:00
"name": "cbr0",
"cniVersion": "0.3.1",
"plugins": [
2017-08-25 15:07:50 +08:00
{
2020-04-15 14:48:02 +08:00
"type": "flannel",
"delegate": {
2017-11-21 18:42:53 +08:00
"hairpinMode": true,
2020-04-15 14:48:02 +08:00
"isDefaultGateway": true
2017-08-25 15:07:50 +08:00
}
},
{
2020-04-15 14:48:02 +08:00
"type": "portmap",
"capabilities": {
"portMappings": true
2017-08-25 15:07:50 +08:00
}
}
]
}
net-conf.json: |
{
"Network": "{{ kube_pods_subnet }}",
"Backend": {
2020-04-15 18:14:02 +08:00
"Type": "{{ flannel_backend_type }}"{% if flannel_backend_type == "vxlan" %},
"VNI": {{ flannel_vxlan_vni }},
"Port": {{ flannel_vxlan_port }}
{% endif %}
2017-08-25 15:07:50 +08:00
}
}
2020-09-22 15:44:47 +08:00
{% for arch in ['amd64', 'arm64', 'arm', 'ppc64le', 's390x'] %}
2017-08-25 15:07:50 +08:00
---
2019-09-11 03:06:55 +08:00
apiVersion: apps/v1
2017-08-25 15:07:50 +08:00
kind: DaemonSet
metadata:
2020-09-22 15:44:47 +08:00
{% if arch == 'amd64' %}
2017-08-25 15:07:50 +08:00
name: kube-flannel
2020-09-22 15:44:47 +08:00
{% else %}
name: kube-flannel-ds-{{ arch }}
{% endif %}
2020-04-15 14:48:02 +08:00
namespace: kube-system
2017-08-25 15:07:50 +08:00
labels:
tier: node
2020-04-15 14:48:02 +08:00
app: flannel
2017-08-25 15:07:50 +08:00
spec:
2019-09-11 03:06:55 +08:00
selector:
matchLabels:
2020-04-15 14:48:02 +08:00
app: flannel
2017-08-25 15:07:50 +08:00
template:
metadata:
labels:
tier: node
2020-04-15 14:48:02 +08:00
app: flannel
2017-08-25 15:07:50 +08:00
spec:
2018-09-25 22:50:22 +08:00
priorityClassName: system-node-critical
2017-08-25 15:07:50 +08:00
serviceAccountName: flannel
containers:
- name: kube-flannel
2021-04-30 08:51:57 +08:00
image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }}
2017-08-25 15:07:50 +08:00
imagePullPolicy: {{ k8s_image_pull_policy }}
resources:
limits:
cpu: {{ flannel_cpu_limit }}
memory: {{ flannel_memory_limit }}
requests:
cpu: {{ flannel_cpu_requests }}
memory: {{ flannel_memory_requests }}
2018-03-17 02:44:36 +08:00
command: [ "/opt/bin/flanneld", "--ip-masq", "--kube-subnet-mgr"{% if flannel_interface is defined %}, "--iface={{ flannel_interface }}"{% endif %}{% if flannel_interface_regexp is defined %}, "--iface-regex={{ flannel_interface_regexp }}"{% endif %} ]
2017-08-25 15:07:50 +08:00
securityContext:
2020-04-15 14:48:02 +08:00
privileged: false
capabilities:
2022-10-14 15:16:47 +08:00
add: ["NET_ADMIN", "NET_RAW"]
2017-08-25 15:07:50 +08:00
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
2022-10-14 15:16:47 +08:00
- name: EVENT_QUEUE_DEPTH
value: "5000"
2017-08-25 15:07:50 +08:00
volumeMounts:
- name: run
2020-04-15 14:48:02 +08:00
mountPath: /run/flannel
2017-08-25 15:07:50 +08:00
- name: flannel-cfg
mountPath: /etc/kube-flannel/
2022-10-14 15:16:47 +08:00
- name: xtables-lock
mountPath: /run/xtables.lock
2020-04-15 14:48:02 +08:00
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
2020-04-17 20:51:06 +08:00
- key: kubernetes.io/os
2020-04-15 14:48:02 +08:00
operator: In
values:
- linux
2020-04-17 20:51:06 +08:00
- key: kubernetes.io/arch
2020-04-15 14:48:02 +08:00
operator: In
values:
2020-09-22 15:44:47 +08:00
- {{ arch }}
2020-04-15 14:48:02 +08:00
initContainers:
2022-04-19 00:44:41 +08:00
- name: install-cni-plugin
image: {{ flannel_init_image_repo }}:{{ flannel_init_image_tag }}
command:
- cp
args:
- -f
- /flannel
- /opt/cni/bin/flannel
volumeMounts:
- name: cni-plugin
mountPath: /opt/cni/bin
2017-08-25 15:07:50 +08:00
- name: install-cni
2021-04-30 08:51:57 +08:00
image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }}
2020-04-15 14:48:02 +08:00
command:
- cp
args:
- -f
- /etc/kube-flannel/cni-conf.json
- /etc/cni/net.d/10-flannel.conflist
2017-08-25 15:07:50 +08:00
volumeMounts:
- name: cni
2020-04-15 14:48:02 +08:00
mountPath: /etc/cni/net.d
- name: flannel-cfg
mountPath: /etc/kube-flannel/
2017-08-25 15:07:50 +08:00
hostNetwork: true
2019-06-05 18:17:56 +08:00
dnsPolicy: ClusterFirstWithHostNet
2017-08-25 15:07:50 +08:00
tolerations:
2020-04-15 14:48:02 +08:00
- operator: Exists
2017-08-25 15:07:50 +08:00
volumes:
- name: run
hostPath:
2020-04-15 14:48:02 +08:00
path: /run/flannel
2017-08-25 15:07:50 +08:00
- name: cni
hostPath:
path: /etc/cni/net.d
- name: flannel-cfg
configMap:
name: kube-flannel-cfg
2022-10-14 15:16:47 +08:00
- name: xtables-lock
hostPath:
path: /run/xtables.lock
type: FileOrCreate
2022-04-19 00:44:41 +08:00
- name: cni-plugin
2017-08-25 15:07:50 +08:00
hostPath:
path: /opt/cni/bin
updateStrategy:
rollingUpdate:
2017-09-15 20:19:37 +08:00
maxUnavailable: {{ serial | default('20%') }}
type: RollingUpdate
2020-09-22 15:44:47 +08:00
{% endfor %}