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.

156 lines
4.1 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. "Backend": {
  35. "Type": "{{ flannel_backend_type }}"{% if flannel_backend_type == "vxlan" %},
  36. "VNI": {{ flannel_vxlan_vni }},
  37. "Port": {{ flannel_vxlan_port }}
  38. {% endif %}
  39. }
  40. }
  41. {% for arch in ['amd64', 'arm64', 'arm', 'ppc64le', 's390x'] %}
  42. ---
  43. apiVersion: apps/v1
  44. kind: DaemonSet
  45. metadata:
  46. {% if arch == 'amd64' %}
  47. name: kube-flannel
  48. {% else %}
  49. name: kube-flannel-ds-{{ arch }}
  50. {% endif %}
  51. namespace: kube-system
  52. labels:
  53. tier: node
  54. app: flannel
  55. spec:
  56. selector:
  57. matchLabels:
  58. app: flannel
  59. template:
  60. metadata:
  61. labels:
  62. tier: node
  63. app: flannel
  64. spec:
  65. priorityClassName: system-node-critical
  66. serviceAccountName: flannel
  67. containers:
  68. - name: kube-flannel
  69. image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }}
  70. imagePullPolicy: {{ k8s_image_pull_policy }}
  71. resources:
  72. limits:
  73. cpu: {{ flannel_cpu_limit }}
  74. memory: {{ flannel_memory_limit }}
  75. requests:
  76. cpu: {{ flannel_cpu_requests }}
  77. memory: {{ flannel_memory_requests }}
  78. 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 %} ]
  79. securityContext:
  80. privileged: false
  81. capabilities:
  82. add: ["NET_ADMIN"]
  83. env:
  84. - name: POD_NAME
  85. valueFrom:
  86. fieldRef:
  87. fieldPath: metadata.name
  88. - name: POD_NAMESPACE
  89. valueFrom:
  90. fieldRef:
  91. fieldPath: metadata.namespace
  92. volumeMounts:
  93. - name: run
  94. mountPath: /run/flannel
  95. - name: flannel-cfg
  96. mountPath: /etc/kube-flannel/
  97. affinity:
  98. nodeAffinity:
  99. requiredDuringSchedulingIgnoredDuringExecution:
  100. nodeSelectorTerms:
  101. - matchExpressions:
  102. - key: kubernetes.io/os
  103. operator: In
  104. values:
  105. - linux
  106. - key: kubernetes.io/arch
  107. operator: In
  108. values:
  109. - {{ arch }}
  110. initContainers:
  111. - name: install-cni-plugin
  112. image: {{ flannel_init_image_repo }}:{{ flannel_init_image_tag }}
  113. command:
  114. - cp
  115. args:
  116. - -f
  117. - /flannel
  118. - /opt/cni/bin/flannel
  119. volumeMounts:
  120. - name: cni-plugin
  121. mountPath: /opt/cni/bin
  122. - name: install-cni
  123. image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }}
  124. command:
  125. - cp
  126. args:
  127. - -f
  128. - /etc/kube-flannel/cni-conf.json
  129. - /etc/cni/net.d/10-flannel.conflist
  130. volumeMounts:
  131. - name: cni
  132. mountPath: /etc/cni/net.d
  133. - name: flannel-cfg
  134. mountPath: /etc/kube-flannel/
  135. hostNetwork: true
  136. dnsPolicy: ClusterFirstWithHostNet
  137. tolerations:
  138. - operator: Exists
  139. volumes:
  140. - name: run
  141. hostPath:
  142. path: /run/flannel
  143. - name: cni
  144. hostPath:
  145. path: /etc/cni/net.d
  146. - name: flannel-cfg
  147. configMap:
  148. name: kube-flannel-cfg
  149. - name: cni-plugin
  150. hostPath:
  151. path: /opt/cni/bin
  152. updateStrategy:
  153. rollingUpdate:
  154. maxUnavailable: {{ serial | default('20%') }}
  155. type: RollingUpdate
  156. {% endfor %}