kilo-k3s-flannel.yaml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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
  100. args:
  101. - --kubeconfig=/etc/kubernetes/kubeconfig
  102. - --hostname=$(NODE_NAME)
  103. - --cni=false
  104. - --compatibility=flannel
  105. - --local=false
  106. env:
  107. - name: NODE_NAME
  108. valueFrom:
  109. fieldRef:
  110. fieldPath: spec.nodeName
  111. ports:
  112. - containerPort: 1107
  113. name: metrics
  114. securityContext:
  115. privileged: true
  116. volumeMounts:
  117. - name: kilo-dir
  118. mountPath: /var/lib/kilo
  119. - name: kubeconfig
  120. mountPath: /etc/kubernetes
  121. readOnly: true
  122. - name: lib-modules
  123. mountPath: /lib/modules
  124. readOnly: true
  125. - name: xtables-lock
  126. mountPath: /run/xtables.lock
  127. readOnly: false
  128. initContainers:
  129. - name: generate-kubeconfig
  130. image: squat/kilo
  131. command:
  132. - /bin/sh
  133. args:
  134. - /scripts/init.sh
  135. imagePullPolicy: Always
  136. volumeMounts:
  137. - name: kubeconfig
  138. mountPath: /etc/kubernetes
  139. - name: scripts
  140. mountPath: /scripts/
  141. readOnly: true
  142. - name: k3s-agent
  143. mountPath: /var/lib/rancher/k3s/agent/
  144. readOnly: true
  145. env:
  146. - name: NAMESPACE
  147. valueFrom:
  148. fieldRef:
  149. fieldPath: metadata.namespace
  150. tolerations:
  151. - effect: NoSchedule
  152. operator: Exists
  153. - effect: NoExecute
  154. operator: Exists
  155. volumes:
  156. - name: kilo-dir
  157. hostPath:
  158. path: /var/lib/kilo
  159. - name: kubeconfig
  160. emptyDir: {}
  161. - name: scripts
  162. configMap:
  163. name: kilo-scripts
  164. - name: k3s-agent
  165. hostPath:
  166. path: /var/lib/rancher/k3s/agent
  167. - name: lib-modules
  168. hostPath:
  169. path: /lib/modules
  170. - name: xtables-lock
  171. hostPath:
  172. path: /run/xtables.lock
  173. type: FileOrCreate