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.

225 lines
5.6 KiB

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: kube-router-cfg
  5. namespace: kube-system
  6. labels:
  7. tier: node
  8. k8s-app: kube-router
  9. data:
  10. cni-conf.json: |
  11. {
  12. "name":"kubernetes",
  13. "type":"bridge",
  14. "bridge":"kube-bridge",
  15. "isDefaultGateway":true,
  16. {% if kube_router_support_hairpin_mode %}
  17. "hairpinMode":true,
  18. {% endif %}
  19. "ipam": {
  20. "type":"host-local"
  21. }
  22. }
  23. kubeconfig: |
  24. apiVersion: v1
  25. kind: Config
  26. clusterCIDR: {{ kube_pods_subnet }}
  27. clusters:
  28. - name: cluster
  29. cluster:
  30. certificate-authority: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
  31. server: {{ kube_apiserver_endpoint }}
  32. users:
  33. - name: kube-router
  34. user:
  35. tokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
  36. contexts:
  37. - context:
  38. cluster: cluster
  39. user: kube-router
  40. name: kube-router-context
  41. current-context: kube-router-context
  42. ---
  43. apiVersion: extensions/v1beta1
  44. kind: DaemonSet
  45. metadata:
  46. labels:
  47. k8s-app: kube-router
  48. tier: node
  49. name: kube-router
  50. namespace: kube-system
  51. spec:
  52. minReadySeconds: 3
  53. updateStrategy:
  54. rollingUpdate:
  55. maxUnavailable: 1
  56. type: RollingUpdate
  57. template:
  58. metadata:
  59. labels:
  60. k8s-app: kube-router
  61. tier: node
  62. annotations:
  63. scheduler.alpha.kubernetes.io/critical-pod: ''
  64. spec:
  65. {% if kube_version is version('v1.11.1', '>=') %}
  66. priorityClassName: system-cluster-critical
  67. {% endif %}
  68. serviceAccountName: kube-router
  69. containers:
  70. - name: kube-router
  71. image: {{ kube_router_image_repo }}:{{ kube_router_image_tag }}
  72. imagePullPolicy: IfNotPresent
  73. args:
  74. - --run-router={{ kube_router_run_router | bool }}
  75. - --run-firewall={{ kube_router_run_firewall | bool }}
  76. - --run-service-proxy={{ kube_router_run_service_proxy | bool }}
  77. - --kubeconfig=/var/lib/kube-router/kubeconfig
  78. {% if kube_router_advertise_cluster_ip %}
  79. - --advertise-cluster-ip
  80. {% endif %}
  81. {% if kube_router_advertise_external_ip %}
  82. - --advertise-external-ip
  83. {% endif %}
  84. {% if kube_router_advertise_loadbalancer_ip %}
  85. - --advertise-loadbalancer-ip
  86. {% endif %}
  87. {% if kube_router_peer_router_asns %}
  88. - --peer-router-asns {{ kube_router_peer_router_asns }}
  89. {% endif %}
  90. {% if kube_router_peer_router_ips %}
  91. - --peer-router-ips {{ kube_router_peer_router_ips }}
  92. {% endif %}
  93. {% if kube_router_peer_router_ports %}
  94. - --peer-router-ports {{ kube_router_peer_router_ports }}
  95. {% endif %}
  96. {% for arg in kube_router_extra_args %}
  97. - "{{ arg }}"
  98. {% endfor %}
  99. env:
  100. - name: NODE_NAME
  101. valueFrom:
  102. fieldRef:
  103. fieldPath: spec.nodeName
  104. livenessProbe:
  105. httpGet:
  106. path: /healthz
  107. port: 20244
  108. initialDelaySeconds: 10
  109. periodSeconds: 3
  110. resources:
  111. requests:
  112. cpu: 250m
  113. memory: 250Mi
  114. securityContext:
  115. privileged: true
  116. volumeMounts:
  117. - name: lib-modules
  118. mountPath: /lib/modules
  119. readOnly: true
  120. - name: cni-conf-dir
  121. mountPath: /etc/cni/net.d
  122. - name: kubeconfig
  123. mountPath: /var/lib/kube-router
  124. readOnly: true
  125. initContainers:
  126. - name: install-cni
  127. image: {{ busybox_image_repo }}:{{ busybox_image_tag }}
  128. imagePullPolicy: IfNotPresent
  129. command:
  130. - /bin/sh
  131. - -c
  132. - set -e -x;
  133. if [ ! -f /etc/cni/net.d/10-kuberouter.conf ]; then
  134. TMP=/etc/cni/net.d/.tmp-kuberouter-cfg;
  135. cp /etc/kube-router/cni-conf.json ${TMP};
  136. mv ${TMP} /etc/cni/net.d/10-kuberouter.conf;
  137. fi;
  138. if [ ! -f /var/lib/kube-router/kubeconfig ]; then
  139. TMP=/var/lib/kube-router/.tmp-kubeconfig;
  140. cp /etc/kube-router/kubeconfig ${TMP};
  141. mv ${TMP} /var/lib/kube-router/kubeconfig;
  142. fi
  143. volumeMounts:
  144. - mountPath: /etc/cni/net.d
  145. name: cni-conf-dir
  146. - mountPath: /etc/kube-router
  147. name: kube-router-cfg
  148. - name: kubeconfig
  149. mountPath: /var/lib/kube-router
  150. hostNetwork: true
  151. tolerations:
  152. - operator: Exists
  153. # Mark pod as critical for rescheduling (Will have no effect starting with kubernetes 1.12)
  154. - key: CriticalAddonsOnly
  155. operator: "Exists"
  156. volumes:
  157. - name: lib-modules
  158. hostPath:
  159. path: /lib/modules
  160. - name: cni-conf-dir
  161. hostPath:
  162. path: /etc/cni/net.d
  163. - name: kube-router-cfg
  164. configMap:
  165. name: kube-router-cfg
  166. - name: kubeconfig
  167. hostPath:
  168. path: /var/lib/kube-router
  169. ---
  170. apiVersion: v1
  171. kind: ServiceAccount
  172. metadata:
  173. name: kube-router
  174. namespace: kube-system
  175. ---
  176. kind: ClusterRole
  177. apiVersion: rbac.authorization.k8s.io/v1beta1
  178. metadata:
  179. name: kube-router
  180. namespace: kube-system
  181. rules:
  182. - apiGroups:
  183. - ""
  184. resources:
  185. - namespaces
  186. - pods
  187. - services
  188. - nodes
  189. - endpoints
  190. verbs:
  191. - list
  192. - get
  193. - watch
  194. - apiGroups:
  195. - "networking.k8s.io"
  196. resources:
  197. - networkpolicies
  198. verbs:
  199. - list
  200. - get
  201. - watch
  202. - apiGroups:
  203. - extensions
  204. resources:
  205. - networkpolicies
  206. verbs:
  207. - get
  208. - list
  209. - watch
  210. ---
  211. kind: ClusterRoleBinding
  212. apiVersion: rbac.authorization.k8s.io/v1beta1
  213. metadata:
  214. name: kube-router
  215. roleRef:
  216. apiGroup: rbac.authorization.k8s.io
  217. kind: ClusterRole
  218. name: kube-router
  219. subjects:
  220. - kind: ServiceAccount
  221. name: kube-router
  222. namespace: kube-system