kilo-k3s-flannel.yaml 4.0 KB

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