Skip to content

Commit

Permalink
Merge pull request topolvm#960 from dsvetl/main
Browse files Browse the repository at this point in the history
Add ObjectSelector Configuration for Webhooks
  • Loading branch information
daichimukai authored Sep 9, 2024
2 parents f5c95d6 + 2d0c4ce commit 736f451
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions charts/topolvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ See [Getting Started](https://github.com/topolvm/topolvm/blob/topolvm-chart-v15.
| webhook.caBundle | string | `nil` | Specify the certificate to be used for AdmissionWebhook. |
| webhook.existingCertManagerIssuer | object | `{}` | Specify the cert-manager issuer to be used for AdmissionWebhook. |
| webhook.podMutatingWebhook.enabled | bool | `false` | Enable Pod MutatingWebhook. |
| webhook.podMutatingWebhook.objectSelector | object | `{}` | Labels required on Pods for webhook action. **WARNING**: Modifying objectSelector can affect TopoLVM Pod scheduling. Proceed with caution. # ref: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-objectselector |
| webhook.pvcMutatingWebhook.enabled | bool | `true` | Enable PVC MutatingWebhook. |
| webhook.pvcMutatingWebhook.objectSelector | object | `{}` | Labels required on PVCs for webhook action. **WARNING**: Modifying objectSelector can affect TopoLVM PVC management. Proceed with caution. # ref: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-objectselector |

## Generate Manifests

Expand Down
14 changes: 14 additions & 0 deletions charts/topolvm/templates/mutatingwebhooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ webhooks:
- key: {{ include "topolvm.pluginName" . }}/webhook
operator: NotIn
values: ["ignore"]
{{- if .Values.webhook.podMutatingWebhook.objectSelector }}
objectSelector:
matchLabels:
{{- range $key, $value := .Values.webhook.podMutatingWebhook.objectSelector }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
failurePolicy: Fail
matchPolicy: Equivalent
clientConfig:
Expand Down Expand Up @@ -52,6 +59,13 @@ webhooks:
- key: {{ include "topolvm.pluginName" . }}/webhook
operator: NotIn
values: ["ignore"]
{{- if .Values.webhook.pvcMutatingWebhook.objectSelector }}
objectSelector:
matchLabels:
{{- range $key, $value := .Values.webhook.pvcMutatingWebhook.objectSelector }}
{{ $key }}: {{ $value }}
{{- end }}
{{- end }}
failurePolicy: Fail
matchPolicy: Equivalent
clientConfig:
Expand Down
10 changes: 10 additions & 0 deletions charts/topolvm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,19 @@ webhook:
podMutatingWebhook:
# webhook.podMutatingWebhook.enabled -- Enable Pod MutatingWebhook.
enabled: false
# webhook.podMutatingWebhook.objectSelector -- Labels required on Pods for webhook action.
# **WARNING**: Modifying objectSelector can affect TopoLVM Pod scheduling. Proceed with caution.
## ref: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-objectselector
objectSelector: {}
# webhook: topolvm
pvcMutatingWebhook:
# webhook.pvcMutatingWebhook.enabled -- Enable PVC MutatingWebhook.
enabled: true
# webhook.pvcMutatingWebhook.objectSelector -- Labels required on PVCs for webhook action.
# **WARNING**: Modifying objectSelector can affect TopoLVM PVC management. Proceed with caution.
## ref: https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/#matching-requests-objectselector
objectSelector: {}
# webhook: topolvm

# Container Security Context
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/
Expand Down

0 comments on commit 736f451

Please sign in to comment.