kilo-k3s-userspace.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: kilo
  5. namespace: kube-system
  6. labels:
  7. app.kubernetes.io/name: kilo
  8. data:
  9. cni-conf.json: |
  10. {
  11. "cniVersion":"0.3.1",
  12. "name":"kilo",
  13. "plugins":[
  14. {
  15. "name":"kubernetes",
  16. "type":"bridge",
  17. "bridge":"kube-bridge",
  18. "isDefaultGateway":true,
  19. "forceAddress":true,
  20. "mtu": 1420,
  21. "ipam":{
  22. "type":"host-local"
  23. }
  24. },
  25. {
  26. "type":"portmap",
  27. "snat":true,
  28. "capabilities":{
  29. "portMappings":true
  30. }
  31. }
  32. ]
  33. }
  34. ---
  35. apiVersion: v1
  36. kind: ServiceAccount
  37. metadata:
  38. name: kilo
  39. namespace: kube-system
  40. ---
  41. apiVersion: rbac.authorization.k8s.io/v1
  42. kind: ClusterRole
  43. metadata:
  44. name: kilo
  45. rules:
  46. - apiGroups:
  47. - ""
  48. resources:
  49. - nodes
  50. verbs:
  51. - list
  52. - patch
  53. - watch
  54. - apiGroups:
  55. - kilo.squat.ai
  56. resources:
  57. - peers
  58. verbs:
  59. - list
  60. - update
  61. - watch
  62. - apiGroups:
  63. - apiextensions.k8s.io
  64. resources:
  65. - customresourcedefinitions
  66. verbs:
  67. - create
  68. ---
  69. apiVersion: rbac.authorization.k8s.io/v1
  70. kind: ClusterRoleBinding
  71. metadata:
  72. name: kilo
  73. roleRef:
  74. apiGroup: rbac.authorization.k8s.io
  75. kind: ClusterRole
  76. name: kilo
  77. subjects:
  78. - kind: ServiceAccount
  79. name: kilo
  80. namespace: kube-system
  81. ---
  82. apiVersion: apps/v1
  83. kind: DaemonSet
  84. metadata:
  85. name: kilo
  86. namespace: kube-system
  87. labels:
  88. app.kubernetes.io/name: kilo
  89. spec:
  90. selector:
  91. matchLabels:
  92. app.kubernetes.io/name: kilo
  93. template:
  94. metadata:
  95. labels:
  96. app.kubernetes.io/name: kilo
  97. spec:
  98. serviceAccountName: kilo
  99. hostNetwork: true
  100. containers:
  101. - name: kilo
  102. image: squat/kilo
  103. args:
  104. - --kubeconfig=/etc/kubernetes/kubeconfig
  105. - --hostname=$(NODE_NAME)
  106. - --create-interface=false
  107. - --interface=kilo0
  108. env:
  109. - name: NODE_NAME
  110. valueFrom:
  111. fieldRef:
  112. fieldPath: spec.nodeName
  113. securityContext:
  114. privileged: true
  115. volumeMounts:
  116. - name: cni-conf-dir
  117. mountPath: /etc/cni/net.d
  118. - name: kilo-dir
  119. mountPath: /var/lib/kilo
  120. - name: kubeconfig
  121. mountPath: /etc/kubernetes/kubeconfig
  122. readOnly: true
  123. - name: lib-modules
  124. mountPath: /lib/modules
  125. readOnly: true
  126. - name: xtables-lock
  127. mountPath: /run/xtables.lock
  128. readOnly: false
  129. - name: wireguard
  130. mountPath: /var/run/wireguard
  131. readOnly: false
  132. - name: boringtun
  133. image: leonnicolas/boringtun
  134. args:
  135. - --disable-drop-privileges=true
  136. - --foreground
  137. - kilo0
  138. securityContext:
  139. privileged: true
  140. volumeMounts:
  141. - name: wireguard
  142. mountPath: /var/run/wireguard
  143. readOnly: false
  144. initContainers:
  145. - name: install-cni
  146. image: squat/kilo
  147. command:
  148. - /bin/sh
  149. - -c
  150. - set -e -x;
  151. cp /opt/cni/bin/* /host/opt/cni/bin/;
  152. TMP_CONF="$CNI_CONF_NAME".tmp;
  153. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  154. rm -f /host/etc/cni/net.d/*;
  155. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  156. env:
  157. - name: CNI_CONF_NAME
  158. value: 10-kilo.conflist
  159. - name: CNI_NETWORK_CONFIG
  160. valueFrom:
  161. configMapKeyRef:
  162. name: kilo
  163. key: cni-conf.json
  164. volumeMounts:
  165. - name: cni-bin-dir
  166. mountPath: /host/opt/cni/bin
  167. - name: cni-conf-dir
  168. mountPath: /host/etc/cni/net.d
  169. tolerations:
  170. - effect: NoSchedule
  171. operator: Exists
  172. - effect: NoExecute
  173. operator: Exists
  174. volumes:
  175. - name: cni-bin-dir
  176. hostPath:
  177. path: /opt/cni/bin
  178. - name: cni-conf-dir
  179. hostPath:
  180. path: /etc/cni/net.d
  181. - name: kilo-dir
  182. hostPath:
  183. path: /var/lib/kilo
  184. - name: kubeconfig
  185. hostPath:
  186. # Since kilo runs as a daemonset, it is recommended that you copy the
  187. # k3s.yaml kubeconfig file from the master node to all worker nodes
  188. # with the same path structure.
  189. path: /etc/rancher/k3s/k3s.yaml
  190. - name: lib-modules
  191. hostPath:
  192. path: /lib/modules
  193. - name: xtables-lock
  194. hostPath:
  195. path: /run/xtables.lock
  196. type: FileOrCreate
  197. - name: wireguard
  198. hostPath:
  199. path: /var/run/wireguard