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.

194 lines
4.8 KiB

  1. apiVersion: apps/v1
  2. kind: DaemonSet
  3. metadata:
  4. labels:
  5. k8s-app: kube-router
  6. tier: node
  7. name: kube-router
  8. namespace: kube-system
  9. spec:
  10. minReadySeconds: 3
  11. updateStrategy:
  12. rollingUpdate:
  13. maxUnavailable: 1
  14. type: RollingUpdate
  15. selector:
  16. matchLabels:
  17. k8s-app: kube-router
  18. tier: node
  19. template:
  20. metadata:
  21. labels:
  22. k8s-app: kube-router
  23. tier: node
  24. annotations:
  25. {% if kube_router_enable_metrics %}
  26. prometheus.io/path: {{ kube_router_metrics_path }}
  27. prometheus.io/port: "{{ kube_router_metrics_port }}"
  28. prometheus.io/scrape: "true"
  29. {% endif %}
  30. spec:
  31. priorityClassName: system-node-critical
  32. serviceAccountName: kube-router
  33. containers:
  34. - name: kube-router
  35. image: {{ kube_router_image_repo }}:{{ kube_router_image_tag }}
  36. imagePullPolicy: {{ k8s_image_pull_policy }}
  37. args:
  38. - --run-router={{ kube_router_run_router | bool }}
  39. - --run-firewall={{ kube_router_run_firewall | bool }}
  40. - --run-service-proxy={{ kube_router_run_service_proxy | bool }}
  41. - --kubeconfig=/var/lib/kube-router/kubeconfig
  42. - --bgp-graceful-restart=true
  43. {% if kube_router_advertise_cluster_ip %}
  44. - --advertise-cluster-ip
  45. {% endif %}
  46. {% if kube_router_advertise_external_ip %}
  47. - --advertise-external-ip
  48. {% endif %}
  49. {% if kube_router_advertise_loadbalancer_ip %}
  50. - --advertise-loadbalancer-ip
  51. {% endif %}
  52. {% if kube_router_peer_router_asns %}
  53. - --peer-router-asns={{ kube_router_peer_router_asns }}
  54. {% endif %}
  55. {% if kube_router_peer_router_ips %}
  56. - --peer-router-ips={{ kube_router_peer_router_ips }}
  57. {% endif %}
  58. {% if kube_router_peer_router_ports %}
  59. - --peer-router-ports={{ kube_router_peer_router_ports }}
  60. {% endif %}
  61. {% if kube_router_enable_metrics %}
  62. - --metrics-path={{ kube_router_metrics_path }}
  63. - --metrics-port={{ kube_router_metrics_port }}
  64. {% endif %}
  65. {% for arg in kube_router_extra_args %}
  66. - "{{ arg }}"
  67. {% endfor %}
  68. env:
  69. - name: NODE_NAME
  70. valueFrom:
  71. fieldRef:
  72. fieldPath: spec.nodeName
  73. - name: KUBE_ROUTER_CNI_CONF_FILE
  74. value: /etc/cni/net.d/10-kuberouter.conflist
  75. livenessProbe:
  76. httpGet:
  77. path: /healthz
  78. port: 20244
  79. initialDelaySeconds: 10
  80. periodSeconds: 3
  81. resources:
  82. requests:
  83. cpu: 250m
  84. memory: 250Mi
  85. securityContext:
  86. privileged: true
  87. volumeMounts:
  88. {% if kube_router_enable_dsr %}
  89. - name: docker-socket
  90. mountPath: /var/run/docker.sock
  91. readOnly: true
  92. {% endif %}
  93. - name: lib-modules
  94. mountPath: /lib/modules
  95. readOnly: true
  96. - name: cni-conf-dir
  97. mountPath: /etc/cni/net.d
  98. - name: kubeconfig
  99. mountPath: /var/lib/kube-router
  100. readOnly: true
  101. - name: xtables-lock
  102. mountPath: /run/xtables.lock
  103. readOnly: false
  104. {% if kube_router_enable_metrics %}
  105. ports:
  106. - containerPort: {{ kube_router_metrics_port }}
  107. hostPort: {{ kube_router_metrics_port }}
  108. name: metrics
  109. protocol: TCP
  110. {% endif %}
  111. hostNetwork: true
  112. dnsPolicy: {{ kube_router_dns_policy }}
  113. {% if kube_router_enable_dsr %}
  114. hostIPC: true
  115. hostPID: true
  116. {% endif %}
  117. tolerations:
  118. - operator: Exists
  119. volumes:
  120. {% if kube_router_enable_dsr %}
  121. - name: docker-socket
  122. hostPath:
  123. path: /var/run/docker.sock
  124. type: Socket
  125. {% endif %}
  126. - name: lib-modules
  127. hostPath:
  128. path: /lib/modules
  129. - name: cni-conf-dir
  130. hostPath:
  131. path: /etc/cni/net.d
  132. - name: kubeconfig
  133. hostPath:
  134. path: /var/lib/kube-router
  135. - name: xtables-lock
  136. hostPath:
  137. path: /run/xtables.lock
  138. type: FileOrCreate
  139. ---
  140. apiVersion: v1
  141. kind: ServiceAccount
  142. metadata:
  143. name: kube-router
  144. namespace: kube-system
  145. ---
  146. kind: ClusterRole
  147. apiVersion: rbac.authorization.k8s.io/v1
  148. metadata:
  149. name: kube-router
  150. namespace: kube-system
  151. rules:
  152. - apiGroups:
  153. - ""
  154. resources:
  155. - namespaces
  156. - pods
  157. - services
  158. - nodes
  159. - endpoints
  160. verbs:
  161. - list
  162. - get
  163. - watch
  164. - apiGroups:
  165. - "networking.k8s.io"
  166. resources:
  167. - networkpolicies
  168. verbs:
  169. - list
  170. - get
  171. - watch
  172. - apiGroups:
  173. - extensions
  174. resources:
  175. - networkpolicies
  176. verbs:
  177. - get
  178. - list
  179. - watch
  180. ---
  181. kind: ClusterRoleBinding
  182. apiVersion: rbac.authorization.k8s.io/v1
  183. metadata:
  184. name: kube-router
  185. roleRef:
  186. apiGroup: rbac.authorization.k8s.io
  187. kind: ClusterRole
  188. name: kube-router
  189. subjects:
  190. - kind: ServiceAccount
  191. name: kube-router
  192. namespace: kube-system