You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
4.5 KiB

  1. ---
  2. kind: ConfigMap
  3. apiVersion: v1
  4. metadata:
  5. name: kube-flannel-cfg
  6. namespace: kube-system
  7. labels:
  8. tier: node
  9. app: flannel
  10. data:
  11. cni-conf.json: |
  12. {
  13. "name": "cbr0",
  14. "cniVersion": "0.3.1",
  15. "plugins": [
  16. {
  17. "type": "flannel",
  18. "delegate": {
  19. "hairpinMode": true,
  20. "isDefaultGateway": true
  21. }
  22. },
  23. {
  24. "type": "portmap",
  25. "capabilities": {
  26. "portMappings": true
  27. }
  28. }
  29. ]
  30. }
  31. net-conf.json: |
  32. {
  33. "Network": "{{ kube_pods_subnet }}",
  34. "EnableIPv4": true,
  35. {% if enable_dual_stack_networks %}
  36. "EnableIPv6": true,
  37. "IPv6Network": "{{ kube_pods_subnet_ipv6 }}",
  38. {% endif %}
  39. "Backend": {
  40. "Type": "{{ flannel_backend_type }}"{% if flannel_backend_type == "vxlan" %},
  41. "VNI": {{ flannel_vxlan_vni }},
  42. "Port": {{ flannel_vxlan_port }},
  43. "DirectRouting": {{ flannel_vxlan_direct_routing | to_json }}
  44. {% endif %}
  45. }
  46. }
  47. {% for arch in ['amd64', 'arm64', 'arm', 'ppc64le', 's390x'] %}
  48. ---
  49. apiVersion: apps/v1
  50. kind: DaemonSet
  51. metadata:
  52. {% if arch == 'amd64' %}
  53. name: kube-flannel
  54. {% else %}
  55. name: kube-flannel-ds-{{ arch }}
  56. {% endif %}
  57. namespace: kube-system
  58. labels:
  59. tier: node
  60. app: flannel
  61. spec:
  62. selector:
  63. matchLabels:
  64. app: flannel
  65. template:
  66. metadata:
  67. labels:
  68. tier: node
  69. app: flannel
  70. spec:
  71. priorityClassName: system-node-critical
  72. serviceAccountName: flannel
  73. containers:
  74. - name: kube-flannel
  75. image: {{ flannel_image_repo }}:{{ flannel_image_tag }}
  76. imagePullPolicy: {{ k8s_image_pull_policy }}
  77. resources:
  78. limits:
  79. cpu: {{ flannel_cpu_limit }}
  80. memory: {{ flannel_memory_limit }}
  81. requests:
  82. cpu: {{ flannel_cpu_requests }}
  83. memory: {{ flannel_memory_requests }}
  84. 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 %} ]
  85. securityContext:
  86. privileged: false
  87. capabilities:
  88. add: ["NET_ADMIN", "NET_RAW"]
  89. env:
  90. - name: POD_NAME
  91. valueFrom:
  92. fieldRef:
  93. fieldPath: metadata.name
  94. - name: POD_NAMESPACE
  95. valueFrom:
  96. fieldRef:
  97. fieldPath: metadata.namespace
  98. - name: EVENT_QUEUE_DEPTH
  99. value: "5000"
  100. volumeMounts:
  101. - name: run
  102. mountPath: /run/flannel
  103. - name: flannel-cfg
  104. mountPath: /etc/kube-flannel/
  105. - name: xtables-lock
  106. mountPath: /run/xtables.lock
  107. affinity:
  108. nodeAffinity:
  109. requiredDuringSchedulingIgnoredDuringExecution:
  110. nodeSelectorTerms:
  111. - matchExpressions:
  112. - key: kubernetes.io/os
  113. operator: In
  114. values:
  115. - linux
  116. - key: kubernetes.io/arch
  117. operator: In
  118. values:
  119. - {{ arch }}
  120. initContainers:
  121. - name: install-cni-plugin
  122. image: {{ flannel_init_image_repo }}:{{ flannel_init_image_tag }}
  123. command:
  124. - cp
  125. args:
  126. - -f
  127. - /flannel
  128. - /opt/cni/bin/flannel
  129. volumeMounts:
  130. - name: cni-plugin
  131. mountPath: /opt/cni/bin
  132. - name: install-cni
  133. image: {{ flannel_image_repo }}:{{ flannel_image_tag }}
  134. command:
  135. - cp
  136. args:
  137. - -f
  138. - /etc/kube-flannel/cni-conf.json
  139. - /etc/cni/net.d/10-flannel.conflist
  140. volumeMounts:
  141. - name: cni
  142. mountPath: /etc/cni/net.d
  143. - name: flannel-cfg
  144. mountPath: /etc/kube-flannel/
  145. hostNetwork: true
  146. dnsPolicy: ClusterFirstWithHostNet
  147. tolerations:
  148. - operator: Exists
  149. volumes:
  150. - name: run
  151. hostPath:
  152. path: /run/flannel
  153. - name: cni
  154. hostPath:
  155. path: /etc/cni/net.d
  156. - name: flannel-cfg
  157. configMap:
  158. name: kube-flannel-cfg
  159. - name: xtables-lock
  160. hostPath:
  161. path: /run/xtables.lock
  162. type: FileOrCreate
  163. - name: cni-plugin
  164. hostPath:
  165. path: /opt/cni/bin
  166. updateStrategy:
  167. rollingUpdate:
  168. maxUnavailable: {{ serial | default('20%') }}
  169. type: RollingUpdate
  170. {% endfor %}