kilo-k3s-cilium.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. apiVersion: v1
  2. kind: ServiceAccount
  3. metadata:
  4. name: kilo
  5. namespace: kube-system
  6. ---
  7. apiVersion: rbac.authorization.k8s.io/v1
  8. kind: ClusterRole
  9. metadata:
  10. name: kilo
  11. rules:
  12. - apiGroups:
  13. - ""
  14. resources:
  15. - nodes
  16. verbs:
  17. - list
  18. - patch
  19. - watch
  20. - apiGroups:
  21. - kilo.squat.ai
  22. resources:
  23. - peers
  24. verbs:
  25. - list
  26. - watch
  27. - apiGroups:
  28. - apiextensions.k8s.io
  29. resources:
  30. - customresourcedefinitions
  31. verbs:
  32. - get
  33. ---
  34. apiVersion: rbac.authorization.k8s.io/v1
  35. kind: ClusterRoleBinding
  36. metadata:
  37. name: kilo
  38. roleRef:
  39. apiGroup: rbac.authorization.k8s.io
  40. kind: ClusterRole
  41. name: kilo
  42. subjects:
  43. - kind: ServiceAccount
  44. name: kilo
  45. namespace: kube-system
  46. ---
  47. apiVersion: v1
  48. kind: ConfigMap
  49. metadata:
  50. name: kilo-scripts
  51. namespace: kube-system
  52. data:
  53. init.sh: |
  54. #!/bin/sh
  55. cat > /etc/kubernetes/kubeconfig <<EOF
  56. apiVersion: v1
  57. kind: Config
  58. name: kilo
  59. clusters:
  60. - cluster:
  61. server: $(sed -n 's/.*server: \(.*\)/\1/p' /var/lib/rancher/k3s/agent/kubelet.kubeconfig)
  62. certificate-authority: /var/lib/rancher/k3s/agent/server-ca.crt
  63. users:
  64. - name: kilo
  65. user:
  66. token: $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
  67. contexts:
  68. - name: kilo
  69. context:
  70. cluster: kilo
  71. namespace: ${NAMESPACE}
  72. user: kilo
  73. current-context: kilo
  74. EOF
  75. ---
  76. apiVersion: apps/v1
  77. kind: DaemonSet
  78. metadata:
  79. name: kilo
  80. namespace: kube-system
  81. labels:
  82. app.kubernetes.io/name: kilo
  83. app.kubernetes.io/part-of: kilo
  84. spec:
  85. selector:
  86. matchLabels:
  87. app.kubernetes.io/name: kilo
  88. app.kubernetes.io/part-of: kilo
  89. template:
  90. metadata:
  91. labels:
  92. app.kubernetes.io/name: kilo
  93. app.kubernetes.io/part-of: kilo
  94. spec:
  95. serviceAccountName: kilo
  96. hostNetwork: true
  97. containers:
  98. - name: kilo
  99. image: squat/kilo:0.7.0
  100. args:
  101. - --kubeconfig=/etc/kubernetes/kubeconfig
  102. - --hostname=$(NODE_NAME)
  103. - --cni=false
  104. - --compatibility=cilium
  105. - --local=false
  106. - --encapsulate=crosssubnet
  107. - --clean-up-interface=true
  108. - --log-level=all
  109. - --internal-cidr=$(NODE_IP)/32
  110. env:
  111. - name: NODE_NAME
  112. valueFrom:
  113. fieldRef:
  114. fieldPath: spec.nodeName
  115. - name: NODE_IP
  116. valueFrom:
  117. fieldRef:
  118. fieldPath: status.hostIP
  119. ports:
  120. - containerPort: 1107
  121. name: metrics
  122. securityContext:
  123. privileged: true
  124. volumeMounts:
  125. - name: kilo-dir
  126. mountPath: /var/lib/kilo
  127. - name: kubeconfig
  128. mountPath: /etc/kubernetes
  129. readOnly: true
  130. - name: lib-modules
  131. mountPath: /lib/modules
  132. readOnly: true
  133. - name: xtables-lock
  134. mountPath: /run/xtables.lock
  135. readOnly: false
  136. initContainers:
  137. - name: generate-kubeconfig
  138. image: squat/kilo:0.7.0
  139. command:
  140. - /bin/sh
  141. args:
  142. - /scripts/init.sh
  143. imagePullPolicy: Always
  144. volumeMounts:
  145. - name: kubeconfig
  146. mountPath: /etc/kubernetes
  147. - name: scripts
  148. mountPath: /scripts/
  149. readOnly: true
  150. - name: k3s-agent
  151. mountPath: /var/lib/rancher/k3s/agent/
  152. readOnly: true
  153. env:
  154. - name: NAMESPACE
  155. valueFrom:
  156. fieldRef:
  157. fieldPath: metadata.namespace
  158. tolerations:
  159. - effect: NoSchedule
  160. operator: Exists
  161. - effect: NoExecute
  162. operator: Exists
  163. volumes:
  164. - name: kilo-dir
  165. hostPath:
  166. path: /var/lib/kilo
  167. - name: kubeconfig
  168. emptyDir: {}
  169. - name: scripts
  170. configMap:
  171. name: kilo-scripts
  172. - name: k3s-agent
  173. hostPath:
  174. path: /var/lib/rancher/k3s/agent
  175. - name: lib-modules
  176. hostPath:
  177. path: /lib/modules
  178. - name: xtables-lock
  179. hostPath:
  180. path: /run/xtables.lock
  181. type: FileOrCreate