webhook.yaml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: wavy
  5. labels:
  6. app.kubernetes.io/name: wavy
  7. ---
  8. apiVersion: admissionregistration.k8s.io/v1
  9. kind: MutatingWebhookConfiguration
  10. metadata:
  11. name: wavy.squat.ai
  12. webhooks:
  13. - name: wavy.squat.ai
  14. namespaceSelector:
  15. matchExpressions:
  16. - key: app.kubernetes.io/name
  17. operator: NotIn
  18. values: [wavy]
  19. rules:
  20. - apiGroups: [""]
  21. apiVersions: [v1]
  22. operations: [CREATE]
  23. resources: [pods]
  24. scope: Namespaced
  25. - apiGroups: [apps]
  26. apiVersions: [v1]
  27. operations: [CREATE, UPDATE]
  28. resources: [daemonsets, deployments, replicasets, statefulsets]
  29. scope: Namespaced
  30. - apiGroups: [batch]
  31. apiVersions: [v1]
  32. operations: [CREATE, UPDATE]
  33. resources: [cronjobs, jobs]
  34. scope: Namespaced
  35. clientConfig:
  36. service:
  37. namespace: wavy
  38. name: wavy-webhook
  39. path: /mutate
  40. admissionReviewVersions: [v1]
  41. sideEffects: None
  42. timeoutSeconds: 5
  43. ---
  44. apiVersion: apps/v1
  45. kind: Deployment
  46. metadata:
  47. name: wavy-webhook
  48. namespace: wavy
  49. labels:
  50. app.kubernetes.io/name: wavy
  51. app.kubernetes.io/component: webhook-server
  52. spec:
  53. replicas: 1
  54. selector:
  55. matchLabels:
  56. app.kubernetes.io/name: wavy
  57. app.kubernetes.io/component: webhook-server
  58. template:
  59. metadata:
  60. labels:
  61. app.kubernetes.io/name: wavy
  62. app.kubernetes.io/component: webhook-server
  63. spec:
  64. securityContext:
  65. runAsNonRoot: true
  66. runAsUser: 1000
  67. containers:
  68. - name: webhook
  69. image: ghcr.io/wavyland/wavy
  70. imagePullPolicy: IfNotPresent
  71. args:
  72. - webhook
  73. - --certificate=/run/secrets/tls/tls.crt
  74. - --key=/run/secrets/tls/tls.key
  75. - --listen-metrics=:9090
  76. - --listen=:8443
  77. ports:
  78. - containerPort: 8443
  79. name: webhook
  80. - containerPort: 9090
  81. name: metrics
  82. volumeMounts:
  83. - name: tls
  84. mountPath: /run/secrets/tls
  85. readOnly: true
  86. volumes:
  87. - name: tls
  88. secret:
  89. secretName: wavy-webhook-tls
  90. ---
  91. apiVersion: v1
  92. kind: Service
  93. metadata:
  94. name: wavy-webhook
  95. namespace: wavy
  96. labels:
  97. app.kubernetes.io/name: wavy
  98. app.kubernetes.io/component: webhook-server
  99. spec:
  100. selector:
  101. app.kubernetes.io/name: wavy
  102. app.kubernetes.io/component: webhook-server
  103. ports:
  104. - port: 443
  105. targetPort: webhook
  106. ---
  107. apiVersion: v1
  108. kind: ServiceAccount
  109. metadata:
  110. name: wavy-webhook
  111. namespace: wavy
  112. labels:
  113. app.kubernetes.io/name: wavy
  114. app.kubernetes.io/component: webhook-server
  115. ---
  116. apiVersion: rbac.authorization.k8s.io/v1
  117. kind: ClusterRole
  118. metadata:
  119. name: wavy-webhook
  120. labels:
  121. app.kubernetes.io/name: wavy
  122. app.kubernetes.io/component: webhook-server
  123. rules:
  124. - apiGroups:
  125. - admissionregistration.k8s.io
  126. resources:
  127. - mutatingwebhookconfigurations
  128. resourceNames:
  129. - wavy.squat.ai
  130. verbs:
  131. - get
  132. - update
  133. ---
  134. apiVersion: rbac.authorization.k8s.io/v1
  135. kind: ClusterRoleBinding
  136. metadata:
  137. name: wavy-webhook
  138. labels:
  139. app.kubernetes.io/name: wavy
  140. app.kubernetes.io/component: webhook-server
  141. roleRef:
  142. apiGroup: rbac.authorization.k8s.io
  143. kind: ClusterRole
  144. name: wavy-webhook
  145. subjects:
  146. - kind: ServiceAccount
  147. namespace: wavy
  148. name: wavy-webhook
  149. ---
  150. apiVersion: rbac.authorization.k8s.io/v1
  151. kind: Role
  152. metadata:
  153. name: wavy-webhook
  154. namespace: wavy
  155. labels:
  156. app.kubernetes.io/name: wavy
  157. app.kubernetes.io/component: webhook-server
  158. rules:
  159. - apiGroups:
  160. - ""
  161. resources:
  162. - secrets
  163. verbs:
  164. - get
  165. - create
  166. ---
  167. apiVersion: rbac.authorization.k8s.io/v1
  168. kind: RoleBinding
  169. metadata:
  170. name: wavy-webhook
  171. namespace: wavy
  172. labels:
  173. app.kubernetes.io/name: wavy
  174. app.kubernetes.io/component: webhook-server
  175. roleRef:
  176. apiGroup: rbac.authorization.k8s.io
  177. kind: Role
  178. name: wavy-webhook
  179. subjects:
  180. - kind: ServiceAccount
  181. namespace: wavy
  182. name: wavy-webhook
  183. ---
  184. apiVersion: batch/v1
  185. kind: Job
  186. metadata:
  187. name: cert-gen
  188. namespace: wavy
  189. labels:
  190. app.kubernetes.io/name: wavy
  191. app.kubernetes.io/component: certificate-generator
  192. spec:
  193. template:
  194. spec:
  195. serviceAccountName: wavy-webhook
  196. initContainers:
  197. - name: create
  198. image: k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
  199. args:
  200. - create
  201. - --namespace=wavy
  202. - --secret-name=wavy-webhook-tls
  203. - --host=wavy-webhook,wavy-webhook.wavy.svc
  204. - --key-name=tls.key
  205. - --cert-name=tls.crt
  206. containers:
  207. - name: patch
  208. image: k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0
  209. args:
  210. - patch
  211. - --webhook-name=wavy.squat.ai
  212. - --secret-name=wavy-webhook-tls
  213. - --namespace=wavy
  214. - --patch-validating=false
  215. restartPolicy: OnFailure
  216. backoffLimit: 4