kilo-k3s-userspace-heterogeneous.yaml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. - get
  53. - patch
  54. - watch
  55. - apiGroups:
  56. - kilo.squat.ai
  57. resources:
  58. - peers
  59. verbs:
  60. - list
  61. - update
  62. - watch
  63. - apiGroups:
  64. - apiextensions.k8s.io
  65. resources:
  66. - customresourcedefinitions
  67. verbs:
  68. - get
  69. ---
  70. apiVersion: rbac.authorization.k8s.io/v1
  71. kind: ClusterRoleBinding
  72. metadata:
  73. name: kilo
  74. roleRef:
  75. apiGroup: rbac.authorization.k8s.io
  76. kind: ClusterRole
  77. name: kilo
  78. subjects:
  79. - kind: ServiceAccount
  80. name: kilo
  81. namespace: kube-system
  82. ---
  83. apiVersion: apps/v1
  84. kind: DaemonSet
  85. metadata:
  86. name: kilo
  87. namespace: kube-system
  88. labels:
  89. app.kubernetes.io/name: kilo
  90. app.kubernetes.io/part-of: kilo
  91. spec:
  92. selector:
  93. matchLabels:
  94. app.kubernetes.io/name: kilo
  95. app.kubernetes.io/part-of: kilo
  96. template:
  97. metadata:
  98. labels:
  99. app.kubernetes.io/name: kilo
  100. app.kubernetes.io/part-of: kilo
  101. spec:
  102. nodeSelector:
  103. nkml.squat.ai/wireguard: "true"
  104. serviceAccountName: kilo
  105. hostNetwork: true
  106. containers:
  107. - name: kilo
  108. image: squat/kilo
  109. args:
  110. - --kubeconfig=/etc/kubernetes/kubeconfig
  111. - --hostname=$(NODE_NAME)
  112. - --interface=kilo0
  113. env:
  114. - name: NODE_NAME
  115. valueFrom:
  116. fieldRef:
  117. fieldPath: spec.nodeName
  118. ports:
  119. - containerPort: 1107
  120. name: metrics
  121. securityContext:
  122. privileged: true
  123. volumeMounts:
  124. - name: cni-conf-dir
  125. mountPath: /etc/cni/net.d
  126. - name: kilo-dir
  127. mountPath: /var/lib/kilo
  128. - name: kubeconfig
  129. mountPath: /etc/kubernetes/kubeconfig
  130. readOnly: true
  131. - name: lib-modules
  132. mountPath: /lib/modules
  133. readOnly: true
  134. - name: xtables-lock
  135. mountPath: /run/xtables.lock
  136. readOnly: false
  137. initContainers:
  138. - name: install-cni
  139. image: squat/kilo
  140. command:
  141. - /bin/sh
  142. - -c
  143. - set -e -x;
  144. cp /opt/cni/bin/* /host/opt/cni/bin/;
  145. TMP_CONF="$CNI_CONF_NAME".tmp;
  146. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  147. rm -f /host/etc/cni/net.d/*;
  148. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  149. env:
  150. - name: CNI_CONF_NAME
  151. value: 10-kilo.conflist
  152. - name: CNI_NETWORK_CONFIG
  153. valueFrom:
  154. configMapKeyRef:
  155. name: kilo
  156. key: cni-conf.json
  157. volumeMounts:
  158. - name: cni-bin-dir
  159. mountPath: /host/opt/cni/bin
  160. - name: cni-conf-dir
  161. mountPath: /host/etc/cni/net.d
  162. tolerations:
  163. - effect: NoSchedule
  164. operator: Exists
  165. - effect: NoExecute
  166. operator: Exists
  167. volumes:
  168. - name: cni-bin-dir
  169. hostPath:
  170. path: /opt/cni/bin
  171. - name: cni-conf-dir
  172. hostPath:
  173. path: /etc/cni/net.d
  174. - name: kilo-dir
  175. hostPath:
  176. path: /var/lib/kilo
  177. - name: kubeconfig
  178. hostPath:
  179. # Since kilo runs as a daemonset, it is recommended that you copy the
  180. # k3s.yaml kubeconfig file from the master node to all worker nodes
  181. # with the same path structure.
  182. path: /etc/rancher/k3s/k3s.yaml
  183. - name: lib-modules
  184. hostPath:
  185. path: /lib/modules
  186. - name: xtables-lock
  187. hostPath:
  188. path: /run/xtables.lock
  189. type: FileOrCreate
  190. ---
  191. apiVersion: apps/v1
  192. kind: DaemonSet
  193. metadata:
  194. name: kilo-userspace
  195. namespace: kube-system
  196. labels:
  197. app.kubernetes.io/name: kilo-userspace
  198. app.kubernetes.io/part-of: kilo
  199. spec:
  200. selector:
  201. matchLabels:
  202. app.kubernetes.io/name: kilo-userspace
  203. app.kubernetes.io/part-of: kilo
  204. template:
  205. metadata:
  206. labels:
  207. app.kubernetes.io/name: kilo-userspace
  208. app.kubernetes.io/part-of: kilo
  209. spec:
  210. nodeSelector:
  211. nkml.squat.ai/wireguard: "false"
  212. serviceAccountName: kilo
  213. hostNetwork: true
  214. containers:
  215. - name: kilo
  216. image: squat/kilo
  217. args:
  218. - --kubeconfig=/etc/kubernetes/kubeconfig
  219. - --hostname=$(NODE_NAME)
  220. - --create-interface=false
  221. - --interface=kilo0
  222. env:
  223. - name: NODE_NAME
  224. valueFrom:
  225. fieldRef:
  226. fieldPath: spec.nodeName
  227. ports:
  228. - containerPort: 1107
  229. name: metrics
  230. securityContext:
  231. privileged: true
  232. volumeMounts:
  233. - name: cni-conf-dir
  234. mountPath: /etc/cni/net.d
  235. - name: kilo-dir
  236. mountPath: /var/lib/kilo
  237. - name: kubeconfig
  238. mountPath: /etc/kubernetes/kubeconfig
  239. readOnly: true
  240. - name: lib-modules
  241. mountPath: /lib/modules
  242. readOnly: true
  243. - name: xtables-lock
  244. mountPath: /run/xtables.lock
  245. readOnly: false
  246. - name: wireguard
  247. mountPath: /var/run/wireguard
  248. readOnly: false
  249. - name: boringtun
  250. image: leonnicolas/boringtun
  251. args:
  252. - --disable-drop-privileges=true
  253. - --foreground
  254. - kilo0
  255. securityContext:
  256. privileged: true
  257. volumeMounts:
  258. - name: wireguard
  259. mountPath: /var/run/wireguard
  260. readOnly: false
  261. initContainers:
  262. - name: install-cni
  263. image: squat/kilo
  264. command:
  265. - /bin/sh
  266. - -c
  267. - set -e -x;
  268. cp /opt/cni/bin/* /host/opt/cni/bin/;
  269. TMP_CONF="$CNI_CONF_NAME".tmp;
  270. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  271. rm -f /host/etc/cni/net.d/*;
  272. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  273. env:
  274. - name: CNI_CONF_NAME
  275. value: 10-kilo.conflist
  276. - name: CNI_NETWORK_CONFIG
  277. valueFrom:
  278. configMapKeyRef:
  279. name: kilo
  280. key: cni-conf.json
  281. volumeMounts:
  282. - name: cni-bin-dir
  283. mountPath: /host/opt/cni/bin
  284. - name: cni-conf-dir
  285. mountPath: /host/etc/cni/net.d
  286. tolerations:
  287. - effect: NoSchedule
  288. operator: Exists
  289. - effect: NoExecute
  290. operator: Exists
  291. volumes:
  292. - name: cni-bin-dir
  293. hostPath:
  294. path: /opt/cni/bin
  295. - name: cni-conf-dir
  296. hostPath:
  297. path: /etc/cni/net.d
  298. - name: kilo-dir
  299. hostPath:
  300. path: /var/lib/kilo
  301. - name: kubeconfig
  302. hostPath:
  303. # Since kilo runs as a daemonset, it is recommended that you copy the
  304. # k3s.yaml kubeconfig file from the master node to all worker nodes
  305. # with the same path structure.
  306. path: /etc/rancher/k3s/k3s.yaml
  307. - name: lib-modules
  308. hostPath:
  309. path: /lib/modules
  310. - name: xtables-lock
  311. hostPath:
  312. path: /run/xtables.lock
  313. type: FileOrCreate
  314. - name: wireguard
  315. hostPath:
  316. path: /var/run/wireguard
  317. ---
  318. kind: DaemonSet
  319. apiVersion: apps/v1
  320. metadata:
  321. name: nkml
  322. namespace: kube-system
  323. labels:
  324. app.kubernetes.io/name: nkml
  325. spec:
  326. selector:
  327. matchLabels:
  328. app.kubernetes.io/name: nkml
  329. template:
  330. metadata:
  331. labels:
  332. app.kubernetes.io/name: nkml
  333. spec:
  334. hostNetwork: true
  335. containers:
  336. - name: nkml
  337. image: leonnicolas/nkml
  338. args:
  339. - --hostname=$(NODE_NAME)
  340. - --label-mod=wireguard
  341. - --kubeconfig=/etc/kubernetes/kubeconfig
  342. env:
  343. - name: NODE_NAME
  344. valueFrom:
  345. fieldRef:
  346. fieldPath: spec.nodeName
  347. ports:
  348. - name: http
  349. containerPort: 8080
  350. volumeMounts:
  351. - name: kubeconfig
  352. mountPath: /etc/kubernetes/kubeconfig
  353. readOnly: true
  354. volumes:
  355. - name: kubeconfig
  356. hostPath:
  357. # since the above DaemonSets are dependant on the labels
  358. # and nkml would need a cni to start
  359. # it needs run on the hostnetwork and use the kubeconfig
  360. # to label the nodes
  361. path: /etc/rancher/k3s/k3s.yaml