kilo-k3s-userspace-heterogeneous.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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.4.0",
  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. - watch
  62. - apiGroups:
  63. - apiextensions.k8s.io
  64. resources:
  65. - customresourcedefinitions
  66. verbs:
  67. - get
  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: v1
  83. kind: ConfigMap
  84. metadata:
  85. name: kilo-scripts
  86. namespace: kube-system
  87. data:
  88. init.sh: |
  89. #!/bin/sh
  90. cat > /etc/kubernetes/kubeconfig <<EOF
  91. apiVersion: v1
  92. kind: Config
  93. name: kilo
  94. clusters:
  95. - cluster:
  96. server: $(sed -n 's/.*server: \(.*\)/\1/p' /var/lib/rancher/k3s/agent/kubelet.kubeconfig)
  97. certificate-authority: /var/lib/rancher/k3s/agent/server-ca.crt
  98. users:
  99. - name: kilo
  100. user:
  101. token: $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
  102. contexts:
  103. - name: kilo
  104. context:
  105. cluster: kilo
  106. namespace: ${NAMESPACE}
  107. user: kilo
  108. current-context: kilo
  109. EOF
  110. ---
  111. apiVersion: apps/v1
  112. kind: DaemonSet
  113. metadata:
  114. name: kilo
  115. namespace: kube-system
  116. labels:
  117. app.kubernetes.io/name: kilo
  118. app.kubernetes.io/part-of: kilo
  119. spec:
  120. selector:
  121. matchLabels:
  122. app.kubernetes.io/name: kilo
  123. app.kubernetes.io/part-of: kilo
  124. template:
  125. metadata:
  126. labels:
  127. app.kubernetes.io/name: kilo
  128. app.kubernetes.io/part-of: kilo
  129. spec:
  130. nodeSelector:
  131. nkml.squat.ai/wireguard: "true"
  132. serviceAccountName: kilo
  133. hostNetwork: true
  134. containers:
  135. - name: kilo
  136. image: squat/kilo:0.7.0
  137. args:
  138. - --kubeconfig=/etc/kubernetes/kubeconfig
  139. - --hostname=$(NODE_NAME)
  140. - --interface=kilo0
  141. env:
  142. - name: NODE_NAME
  143. valueFrom:
  144. fieldRef:
  145. fieldPath: spec.nodeName
  146. ports:
  147. - containerPort: 1107
  148. name: metrics
  149. securityContext:
  150. privileged: true
  151. volumeMounts:
  152. - name: cni-conf-dir
  153. mountPath: /etc/cni/net.d
  154. - name: kilo-dir
  155. mountPath: /var/lib/kilo
  156. - name: kubeconfig
  157. mountPath: /etc/kubernetes
  158. readOnly: true
  159. - name: lib-modules
  160. mountPath: /lib/modules
  161. readOnly: true
  162. - name: xtables-lock
  163. mountPath: /run/xtables.lock
  164. readOnly: false
  165. initContainers:
  166. - name: generate-kubeconfig
  167. image: squat/kilo:0.7.0
  168. command:
  169. - /bin/sh
  170. args:
  171. - /scripts/init.sh
  172. imagePullPolicy: Always
  173. volumeMounts:
  174. - name: kubeconfig
  175. mountPath: /etc/kubernetes
  176. - name: scripts
  177. mountPath: /scripts/
  178. readOnly: true
  179. - name: k3s-agent
  180. mountPath: /var/lib/rancher/k3s/agent/
  181. readOnly: true
  182. env:
  183. - name: NAMESPACE
  184. valueFrom:
  185. fieldRef:
  186. fieldPath: metadata.namespace
  187. - name: install-cni
  188. image: squat/kilo:0.7.0
  189. command:
  190. - /bin/sh
  191. - -c
  192. - |
  193. set -e -x;
  194. cp /opt/cni/bin/* /host/opt/cni/bin/;
  195. TMP_CONF="$CNI_CONF_NAME".tmp;
  196. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  197. rm -f /host/etc/cni/net.d/*;
  198. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  199. env:
  200. - name: CNI_CONF_NAME
  201. value: 10-kilo.conflist
  202. - name: CNI_NETWORK_CONFIG
  203. valueFrom:
  204. configMapKeyRef:
  205. name: kilo
  206. key: cni-conf.json
  207. volumeMounts:
  208. - name: cni-bin-dir
  209. mountPath: /host/opt/cni/bin
  210. - name: cni-conf-dir
  211. mountPath: /host/etc/cni/net.d
  212. tolerations:
  213. - effect: NoSchedule
  214. operator: Exists
  215. - effect: NoExecute
  216. operator: Exists
  217. volumes:
  218. - name: cni-bin-dir
  219. hostPath:
  220. path: /opt/cni/bin
  221. - name: cni-conf-dir
  222. hostPath:
  223. path: /etc/cni/net.d
  224. - name: kilo-dir
  225. hostPath:
  226. path: /var/lib/kilo
  227. - name: kubeconfig
  228. emptyDir: {}
  229. - name: scripts
  230. configMap:
  231. name: kilo-scripts
  232. - name: k3s-agent
  233. hostPath:
  234. path: /var/lib/rancher/k3s/agent
  235. - name: lib-modules
  236. hostPath:
  237. path: /lib/modules
  238. - name: xtables-lock
  239. hostPath:
  240. path: /run/xtables.lock
  241. type: FileOrCreate
  242. ---
  243. apiVersion: apps/v1
  244. kind: DaemonSet
  245. metadata:
  246. name: kilo-userspace
  247. namespace: kube-system
  248. labels:
  249. app.kubernetes.io/name: kilo-userspace
  250. app.kubernetes.io/part-of: kilo
  251. spec:
  252. selector:
  253. matchLabels:
  254. app.kubernetes.io/name: kilo-userspace
  255. app.kubernetes.io/part-of: kilo
  256. template:
  257. metadata:
  258. labels:
  259. app.kubernetes.io/name: kilo-userspace
  260. app.kubernetes.io/part-of: kilo
  261. spec:
  262. nodeSelector:
  263. nkml.squat.ai/wireguard: "false"
  264. serviceAccountName: kilo
  265. hostNetwork: true
  266. containers:
  267. - name: kilo
  268. image: squat/kilo:0.7.0
  269. args:
  270. - --kubeconfig=/etc/kubernetes/kubeconfig
  271. - --hostname=$(NODE_NAME)
  272. - --create-interface=false
  273. - --interface=kilo0
  274. env:
  275. - name: NODE_NAME
  276. valueFrom:
  277. fieldRef:
  278. fieldPath: spec.nodeName
  279. ports:
  280. - containerPort: 1107
  281. name: metrics
  282. securityContext:
  283. privileged: true
  284. volumeMounts:
  285. - name: cni-conf-dir
  286. mountPath: /etc/cni/net.d
  287. - name: kilo-dir
  288. mountPath: /var/lib/kilo
  289. - name: kubeconfig
  290. mountPath: /etc/kubernetes
  291. readOnly: true
  292. - name: lib-modules
  293. mountPath: /lib/modules
  294. readOnly: true
  295. - name: xtables-lock
  296. mountPath: /run/xtables.lock
  297. readOnly: false
  298. - name: wireguard
  299. mountPath: /var/run/wireguard
  300. readOnly: false
  301. - name: wireguard
  302. image: ghcr.io/masipcat/wireguard-go-docker:0.0.20230223
  303. args:
  304. - wireguard-go
  305. - --foreground
  306. - kilo0
  307. securityContext:
  308. privileged: true
  309. volumeMounts:
  310. - name: wireguard
  311. mountPath: /var/run/wireguard
  312. readOnly: false
  313. initContainers:
  314. - name: generate-kubeconfig
  315. image: squat/kilo:0.7.0
  316. command:
  317. - /bin/sh
  318. args:
  319. - /scripts/init.sh
  320. imagePullPolicy: Always
  321. volumeMounts:
  322. - name: kubeconfig
  323. mountPath: /etc/kubernetes
  324. - name: scripts
  325. mountPath: /scripts/
  326. readOnly: true
  327. - name: k3s-agent
  328. mountPath: /var/lib/rancher/k3s/agent/
  329. readOnly: true
  330. env:
  331. - name: NAMESPACE
  332. valueFrom:
  333. fieldRef:
  334. fieldPath: metadata.namespace
  335. - name: install-cni
  336. image: squat/kilo:0.7.0
  337. command:
  338. - /bin/sh
  339. - -c
  340. - |
  341. set -e -x;
  342. cp /opt/cni/bin/* /host/opt/cni/bin/;
  343. TMP_CONF="$CNI_CONF_NAME".tmp;
  344. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  345. rm -f /host/etc/cni/net.d/*;
  346. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  347. env:
  348. - name: CNI_CONF_NAME
  349. value: 10-kilo.conflist
  350. - name: CNI_NETWORK_CONFIG
  351. valueFrom:
  352. configMapKeyRef:
  353. name: kilo
  354. key: cni-conf.json
  355. volumeMounts:
  356. - name: cni-bin-dir
  357. mountPath: /host/opt/cni/bin
  358. - name: cni-conf-dir
  359. mountPath: /host/etc/cni/net.d
  360. tolerations:
  361. - effect: NoSchedule
  362. operator: Exists
  363. - effect: NoExecute
  364. operator: Exists
  365. volumes:
  366. - name: cni-bin-dir
  367. hostPath:
  368. path: /opt/cni/bin
  369. - name: cni-conf-dir
  370. hostPath:
  371. path: /etc/cni/net.d
  372. - name: kilo-dir
  373. hostPath:
  374. path: /var/lib/kilo
  375. - name: kubeconfig
  376. emptyDir: {}
  377. - name: scripts
  378. configMap:
  379. name: kilo-scripts
  380. - name: k3s-agent
  381. hostPath:
  382. path: /var/lib/rancher/k3s/agent
  383. - name: lib-modules
  384. hostPath:
  385. path: /lib/modules
  386. - name: xtables-lock
  387. hostPath:
  388. path: /run/xtables.lock
  389. type: FileOrCreate
  390. - name: wireguard
  391. hostPath:
  392. path: /var/run/wireguard
  393. ---
  394. kind: DaemonSet
  395. apiVersion: apps/v1
  396. metadata:
  397. name: nkml
  398. namespace: kube-system
  399. labels:
  400. app.kubernetes.io/name: nkml
  401. spec:
  402. selector:
  403. matchLabels:
  404. app.kubernetes.io/name: nkml
  405. template:
  406. metadata:
  407. labels:
  408. app.kubernetes.io/name: nkml
  409. spec:
  410. hostNetwork: true
  411. serviceAccountName: kilo
  412. containers:
  413. - name: nkml
  414. image: ghcr.io/leonnicolas/nkml:0.1.2
  415. args:
  416. - --hostname=$(NODE_NAME)
  417. - --label-mod=wireguard
  418. - --kubeconfig=/etc/kubernetes/kubeconfig
  419. env:
  420. - name: NODE_NAME
  421. valueFrom:
  422. fieldRef:
  423. fieldPath: spec.nodeName
  424. ports:
  425. - name: http
  426. containerPort: 8080
  427. volumeMounts:
  428. - name: kubeconfig
  429. mountPath: /etc/kubernetes
  430. readOnly: true
  431. initContainers:
  432. - name: generate-kubeconfig
  433. image: squat/kilo:0.7.0
  434. command:
  435. - /bin/sh
  436. args:
  437. - /scripts/init.sh
  438. imagePullPolicy: Always
  439. volumeMounts:
  440. - name: kubeconfig
  441. mountPath: /etc/kubernetes
  442. - name: scripts
  443. mountPath: /scripts/
  444. readOnly: true
  445. - name: k3s-agent
  446. mountPath: /var/lib/rancher/k3s/agent/
  447. readOnly: true
  448. env:
  449. - name: NAMESPACE
  450. valueFrom:
  451. fieldRef:
  452. fieldPath: metadata.namespace
  453. volumes:
  454. - name: kubeconfig
  455. emptyDir: {}
  456. - name: scripts
  457. configMap:
  458. name: kilo-scripts
  459. - name: k3s-agent
  460. hostPath:
  461. path: /var/lib/rancher/k3s/agent