You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
5.7 KiB

  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: metallb-system
  5. labels:
  6. app: metallb
  7. ---
  8. apiVersion: v1
  9. kind: ServiceAccount
  10. metadata:
  11. namespace: metallb-system
  12. name: controller
  13. labels:
  14. app: metallb
  15. ---
  16. apiVersion: v1
  17. kind: ServiceAccount
  18. metadata:
  19. namespace: metallb-system
  20. name: speaker
  21. labels:
  22. app: metallb
  23. ---
  24. apiVersion: rbac.authorization.k8s.io/v1
  25. kind: ClusterRole
  26. metadata:
  27. name: metallb-system:controller
  28. labels:
  29. app: metallb
  30. rules:
  31. - apiGroups: [""]
  32. resources: ["services"]
  33. verbs: ["get", "list", "watch", "update"]
  34. - apiGroups: [""]
  35. resources: ["services/status"]
  36. verbs: ["update"]
  37. - apiGroups: [""]
  38. resources: ["events"]
  39. verbs: ["create", "patch"]
  40. ---
  41. apiVersion: rbac.authorization.k8s.io/v1
  42. kind: ClusterRole
  43. metadata:
  44. name: metallb-system:speaker
  45. labels:
  46. app: metallb
  47. rules:
  48. - apiGroups: [""]
  49. resources: ["services", "endpoints", "nodes"]
  50. verbs: ["get", "list", "watch"]
  51. - apiGroups: [""]
  52. resources: ["events"]
  53. verbs: ["create"]
  54. {% if podsecuritypolicy_enabled %}
  55. - apiGroups: ["policy"]
  56. resourceNames: ["metallb"]
  57. resources: ["podsecuritypolicies"]
  58. verbs: ["use"]
  59. ---
  60. apiVersion: policy/v1beta1
  61. kind: PodSecurityPolicy
  62. metadata:
  63. name: metallb
  64. annotations:
  65. seccomp.security.alpha.kubernetes.io/defaultProfileName: 'runtime/default'
  66. seccomp.security.alpha.kubernetes.io/allowedProfileNames: 'runtime/default'
  67. {% if apparmor_enabled %}
  68. apparmor.security.beta.kubernetes.io/defaultProfileName: 'runtime/default'
  69. apparmor.security.beta.kubernetes.io/allowedProfileNames: 'runtime/default'
  70. {% endif %}
  71. labels:
  72. app: metallb
  73. spec:
  74. privileged: true
  75. allowPrivilegeEscalation: false
  76. allowedCapabilities:
  77. - net_raw
  78. volumes:
  79. - secret
  80. hostNetwork: true
  81. hostPorts:
  82. - min: {{ metallb.port }}
  83. max: {{ metallb.port }}
  84. hostIPC: false
  85. hostPID: false
  86. runAsUser:
  87. rule: 'RunAsAny'
  88. seLinux:
  89. rule: 'RunAsAny'
  90. supplementalGroups:
  91. rule: 'RunAsAny'
  92. fsGroup:
  93. rule: 'RunAsAny'
  94. readOnlyRootFilesystem: true
  95. {% endif %}
  96. ---
  97. apiVersion: rbac.authorization.k8s.io/v1
  98. kind: Role
  99. metadata:
  100. namespace: metallb-system
  101. name: config-watcher
  102. labels:
  103. app: metallb
  104. rules:
  105. - apiGroups: [""]
  106. resources: ["configmaps"]
  107. verbs: ["get", "list", "watch"]
  108. - apiGroups: [""]
  109. resources: ["events"]
  110. verbs: ["create"]
  111. ---
  112. ## Role bindings
  113. apiVersion: rbac.authorization.k8s.io/v1
  114. kind: ClusterRoleBinding
  115. metadata:
  116. name: metallb-system:controller
  117. labels:
  118. app: metallb
  119. subjects:
  120. - kind: ServiceAccount
  121. name: controller
  122. namespace: metallb-system
  123. roleRef:
  124. apiGroup: rbac.authorization.k8s.io
  125. kind: ClusterRole
  126. name: metallb-system:controller
  127. ---
  128. apiVersion: rbac.authorization.k8s.io/v1
  129. kind: ClusterRoleBinding
  130. metadata:
  131. name: metallb-system:speaker
  132. labels:
  133. app: metallb
  134. subjects:
  135. - kind: ServiceAccount
  136. name: speaker
  137. namespace: metallb-system
  138. roleRef:
  139. apiGroup: rbac.authorization.k8s.io
  140. kind: ClusterRole
  141. name: metallb-system:speaker
  142. ---
  143. apiVersion: rbac.authorization.k8s.io/v1
  144. kind: RoleBinding
  145. metadata:
  146. namespace: metallb-system
  147. name: config-watcher
  148. labels:
  149. app: metallb
  150. subjects:
  151. - kind: ServiceAccount
  152. name: controller
  153. - kind: ServiceAccount
  154. name: speaker
  155. roleRef:
  156. apiGroup: rbac.authorization.k8s.io
  157. kind: Role
  158. name: config-watcher
  159. ---
  160. apiVersion: apps/v1
  161. kind: DaemonSet
  162. metadata:
  163. namespace: metallb-system
  164. name: speaker
  165. labels:
  166. app: metallb
  167. component: speaker
  168. spec:
  169. selector:
  170. matchLabels:
  171. app: metallb
  172. component: speaker
  173. template:
  174. metadata:
  175. labels:
  176. app: metallb
  177. component: speaker
  178. annotations:
  179. prometheus.io/scrape: "true"
  180. prometheus.io/port: "{{ metallb.port }}"
  181. spec:
  182. serviceAccountName: speaker
  183. terminationGracePeriodSeconds: 0
  184. hostNetwork: true
  185. containers:
  186. - name: speaker
  187. image: metallb/speaker:{{ metallb.version }}
  188. imagePullPolicy: IfNotPresent
  189. args:
  190. - --port={{ metallb.port }}
  191. - --config=config
  192. env:
  193. - name: METALLB_NODE_NAME
  194. valueFrom:
  195. fieldRef:
  196. fieldPath: spec.nodeName
  197. ports:
  198. - name: monitoring
  199. containerPort: {{ metallb.port }}
  200. resources:
  201. limits:
  202. cpu: {{ metallb.limits.cpu }}
  203. memory: {{ metallb.limits.memory }}
  204. securityContext:
  205. allowPrivilegeEscalation: false
  206. readOnlyRootFilesystem: true
  207. capabilities:
  208. drop:
  209. - all
  210. add:
  211. - net_raw
  212. ---
  213. apiVersion: apps/v1
  214. kind: Deployment
  215. metadata:
  216. namespace: metallb-system
  217. name: controller
  218. labels:
  219. app: metallb
  220. component: controller
  221. spec:
  222. revisionHistoryLimit: 3
  223. selector:
  224. matchLabels:
  225. app: metallb
  226. component: controller
  227. template:
  228. metadata:
  229. labels:
  230. app: metallb
  231. component: controller
  232. annotations:
  233. prometheus.io/scrape: "true"
  234. prometheus.io/port: "{{ metallb.port }}"
  235. spec:
  236. serviceAccountName: controller
  237. terminationGracePeriodSeconds: 0
  238. securityContext:
  239. runAsNonRoot: true
  240. runAsUser: 65534 # nobody
  241. containers:
  242. - name: controller
  243. image: metallb/controller:{{ metallb.version }}
  244. imagePullPolicy: IfNotPresent
  245. args:
  246. - --port={{ metallb.port }}
  247. - --config=config
  248. ports:
  249. - name: monitoring
  250. containerPort: {{ metallb.port }}
  251. resources:
  252. limits:
  253. cpu: {{ metallb.limits.cpu }}
  254. memory: {{ metallb.limits.memory }}
  255. securityContext:
  256. allowPrivilegeEscalation: false
  257. capabilities:
  258. drop:
  259. - all
  260. readOnlyRootFilesystem: true
  261. ---