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.

145 lines
3.8 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 }}-{{ 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
  112. image: {{ flannel_image_repo }}:{{ flannel_image_tag }}-{{ arch }}
  113. command:
  114. - cp
  115. args:
  116. - -f
  117. - /etc/kube-flannel/cni-conf.json
  118. - /etc/cni/net.d/10-flannel.conflist
  119. volumeMounts:
  120. - name: cni
  121. mountPath: /etc/cni/net.d
  122. - name: flannel-cfg
  123. mountPath: /etc/kube-flannel/
  124. hostNetwork: true
  125. dnsPolicy: ClusterFirstWithHostNet
  126. tolerations:
  127. - operator: Exists
  128. volumes:
  129. - name: run
  130. hostPath:
  131. path: /run/flannel
  132. - name: cni
  133. hostPath:
  134. path: /etc/cni/net.d
  135. - name: flannel-cfg
  136. configMap:
  137. name: kube-flannel-cfg
  138. - name: host-cni-bin
  139. hostPath:
  140. path: /opt/cni/bin
  141. updateStrategy:
  142. rollingUpdate:
  143. maxUnavailable: {{ serial | default('20%') }}
  144. type: RollingUpdate
  145. {% endfor %}