2
0

kilo-k3s-userspace-heterogeneous.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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. - 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
  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
  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
  189. command:
  190. - /bin/sh
  191. - -c
  192. - set -e -x;
  193. cp /opt/cni/bin/* /host/opt/cni/bin/;
  194. TMP_CONF="$CNI_CONF_NAME".tmp;
  195. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  196. rm -f /host/etc/cni/net.d/*;
  197. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  198. env:
  199. - name: CNI_CONF_NAME
  200. value: 10-kilo.conflist
  201. - name: CNI_NETWORK_CONFIG
  202. valueFrom:
  203. configMapKeyRef:
  204. name: kilo
  205. key: cni-conf.json
  206. volumeMounts:
  207. - name: cni-bin-dir
  208. mountPath: /host/opt/cni/bin
  209. - name: cni-conf-dir
  210. mountPath: /host/etc/cni/net.d
  211. tolerations:
  212. - effect: NoSchedule
  213. operator: Exists
  214. - effect: NoExecute
  215. operator: Exists
  216. volumes:
  217. - name: cni-bin-dir
  218. hostPath:
  219. path: /opt/cni/bin
  220. - name: cni-conf-dir
  221. hostPath:
  222. path: /etc/cni/net.d
  223. - name: kilo-dir
  224. hostPath:
  225. path: /var/lib/kilo
  226. - name: kubeconfig
  227. emptyDir: {}
  228. - name: scripts
  229. configMap:
  230. name: kilo-scripts
  231. - name: k3s-agent
  232. hostPath:
  233. path: /var/lib/rancher/k3s/agent
  234. - name: lib-modules
  235. hostPath:
  236. path: /lib/modules
  237. - name: xtables-lock
  238. hostPath:
  239. path: /run/xtables.lock
  240. type: FileOrCreate
  241. ---
  242. apiVersion: apps/v1
  243. kind: DaemonSet
  244. metadata:
  245. name: kilo-userspace
  246. namespace: kube-system
  247. labels:
  248. app.kubernetes.io/name: kilo-userspace
  249. app.kubernetes.io/part-of: kilo
  250. spec:
  251. selector:
  252. matchLabels:
  253. app.kubernetes.io/name: kilo-userspace
  254. app.kubernetes.io/part-of: kilo
  255. template:
  256. metadata:
  257. labels:
  258. app.kubernetes.io/name: kilo-userspace
  259. app.kubernetes.io/part-of: kilo
  260. spec:
  261. nodeSelector:
  262. nkml.squat.ai/wireguard: "false"
  263. serviceAccountName: kilo
  264. hostNetwork: true
  265. containers:
  266. - name: kilo
  267. image: squat/kilo
  268. args:
  269. - --kubeconfig=/etc/kubernetes/kubeconfig
  270. - --hostname=$(NODE_NAME)
  271. - --create-interface=false
  272. - --interface=kilo0
  273. env:
  274. - name: NODE_NAME
  275. valueFrom:
  276. fieldRef:
  277. fieldPath: spec.nodeName
  278. ports:
  279. - containerPort: 1107
  280. name: metrics
  281. securityContext:
  282. privileged: true
  283. volumeMounts:
  284. - name: cni-conf-dir
  285. mountPath: /etc/cni/net.d
  286. - name: kilo-dir
  287. mountPath: /var/lib/kilo
  288. - name: kubeconfig
  289. mountPath: /etc/kubernetes
  290. readOnly: true
  291. - name: lib-modules
  292. mountPath: /lib/modules
  293. readOnly: true
  294. - name: xtables-lock
  295. mountPath: /run/xtables.lock
  296. readOnly: false
  297. - name: wireguard
  298. mountPath: /var/run/wireguard
  299. readOnly: false
  300. - name: boringtun
  301. image: leonnicolas/boringtun
  302. args:
  303. - --disable-drop-privileges=true
  304. - --foreground
  305. - kilo0
  306. securityContext:
  307. privileged: true
  308. volumeMounts:
  309. - name: wireguard
  310. mountPath: /var/run/wireguard
  311. readOnly: false
  312. initContainers:
  313. - name: generate-kubeconfig
  314. image: squat/kilo
  315. command:
  316. - /bin/sh
  317. args:
  318. - /scripts/init.sh
  319. imagePullPolicy: Always
  320. volumeMounts:
  321. - name: kubeconfig
  322. mountPath: /etc/kubernetes
  323. - name: scripts
  324. mountPath: /scripts/
  325. readOnly: true
  326. - name: k3s-agent
  327. mountPath: /var/lib/rancher/k3s/agent/
  328. readOnly: true
  329. env:
  330. - name: NAMESPACE
  331. valueFrom:
  332. fieldRef:
  333. fieldPath: metadata.namespace
  334. - name: install-cni
  335. image: squat/kilo
  336. command:
  337. - /bin/sh
  338. - -c
  339. - set -e -x;
  340. cp /opt/cni/bin/* /host/opt/cni/bin/;
  341. TMP_CONF="$CNI_CONF_NAME".tmp;
  342. echo "$CNI_NETWORK_CONFIG" > $TMP_CONF;
  343. rm -f /host/etc/cni/net.d/*;
  344. mv $TMP_CONF /host/etc/cni/net.d/$CNI_CONF_NAME
  345. env:
  346. - name: CNI_CONF_NAME
  347. value: 10-kilo.conflist
  348. - name: CNI_NETWORK_CONFIG
  349. valueFrom:
  350. configMapKeyRef:
  351. name: kilo
  352. key: cni-conf.json
  353. volumeMounts:
  354. - name: cni-bin-dir
  355. mountPath: /host/opt/cni/bin
  356. - name: cni-conf-dir
  357. mountPath: /host/etc/cni/net.d
  358. tolerations:
  359. - effect: NoSchedule
  360. operator: Exists
  361. - effect: NoExecute
  362. operator: Exists
  363. volumes:
  364. - name: cni-bin-dir
  365. hostPath:
  366. path: /opt/cni/bin
  367. - name: cni-conf-dir
  368. hostPath:
  369. path: /etc/cni/net.d
  370. - name: kilo-dir
  371. hostPath:
  372. path: /var/lib/kilo
  373. - name: kubeconfig
  374. emptyDir: {}
  375. - name: scripts
  376. configMap:
  377. name: kilo-scripts
  378. - name: k3s-agent
  379. hostPath:
  380. path: /var/lib/rancher/k3s/agent
  381. - name: lib-modules
  382. hostPath:
  383. path: /lib/modules
  384. - name: xtables-lock
  385. hostPath:
  386. path: /run/xtables.lock
  387. type: FileOrCreate
  388. - name: wireguard
  389. hostPath:
  390. path: /var/run/wireguard
  391. ---
  392. kind: DaemonSet
  393. apiVersion: apps/v1
  394. metadata:
  395. name: nkml
  396. namespace: kube-system
  397. labels:
  398. app.kubernetes.io/name: nkml
  399. spec:
  400. selector:
  401. matchLabels:
  402. app.kubernetes.io/name: nkml
  403. template:
  404. metadata:
  405. labels:
  406. app.kubernetes.io/name: nkml
  407. spec:
  408. hostNetwork: true
  409. serviceAccountName: kilo
  410. containers:
  411. - name: nkml
  412. image: leonnicolas/nkml
  413. args:
  414. - --hostname=$(NODE_NAME)
  415. - --label-mod=wireguard
  416. - --kubeconfig=/etc/kubernetes/kubeconfig
  417. env:
  418. - name: NODE_NAME
  419. valueFrom:
  420. fieldRef:
  421. fieldPath: spec.nodeName
  422. ports:
  423. - name: http
  424. containerPort: 8080
  425. volumeMounts:
  426. - name: kubeconfig
  427. mountPath: /etc/kubernetes
  428. readOnly: true
  429. initContainers:
  430. - name: generate-kubeconfig
  431. image: squat/kilo
  432. command:
  433. - /bin/sh
  434. args:
  435. - /scripts/init.sh
  436. imagePullPolicy: Always
  437. volumeMounts:
  438. - name: kubeconfig
  439. mountPath: /etc/kubernetes
  440. - name: scripts
  441. mountPath: /scripts/
  442. readOnly: true
  443. - name: k3s-agent
  444. mountPath: /var/lib/rancher/k3s/agent/
  445. readOnly: true
  446. env:
  447. - name: NAMESPACE
  448. valueFrom:
  449. fieldRef:
  450. fieldPath: metadata.namespace
  451. volumes:
  452. - name: kubeconfig
  453. emptyDir: {}
  454. - name: scripts
  455. configMap:
  456. name: kilo-scripts
  457. - name: k3s-agent
  458. hostPath:
  459. path: /var/lib/rancher/k3s/agent