-
Notifications
You must be signed in to change notification settings - Fork 127
Validation webhook implementation #1682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
83bde6d
eaed932
d5758bf
fc21f5c
d674a50
8a07a8b
b3029bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # The following manifests contain a self-signed issuer CR and a certificate CR. | ||
| # More document can be found at https://docs.cert-manager.io | ||
| # WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes. | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/name: issuer | ||
| app.kubernetes.io/instance: selfsigned-issuer | ||
| app.kubernetes.io/component: certificate | ||
| app.kubernetes.io/created-by: splunk-operator | ||
| app.kubernetes.io/part-of: splunk-operator | ||
| app.kubernetes.io/managed-by: kustomize | ||
| name: selfsigned-issuer | ||
| namespace: system | ||
| spec: | ||
| selfSigned: {} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/name: certificate | ||
| app.kubernetes.io/instance: serving-cert | ||
| app.kubernetes.io/component: certificate | ||
| app.kubernetes.io/created-by: splunk-operator | ||
| app.kubernetes.io/part-of: splunk-operator | ||
| app.kubernetes.io/managed-by: kustomize | ||
| name: serving-cert | ||
| namespace: system | ||
| spec: | ||
| dnsNames: | ||
| - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc | ||
| - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local | ||
| issuerRef: | ||
| kind: Issuer | ||
| name: selfsigned-issuer | ||
| secretName: webhook-server-cert |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| resources: | ||
| - certificate.yaml | ||
|
|
||
| configurations: | ||
| - kustomizeconfig.yaml |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # This configuration is for teaching kustomize how to update name ref and var substitution | ||
| nameReference: | ||
| - kind: Issuer | ||
| group: cert-manager.io | ||
| fieldSpecs: | ||
| - kind: Certificate | ||
| group: cert-manager.io | ||
| path: spec/issuerRef/name | ||
|
|
||
| varReference: | ||
| - kind: Certificate | ||
| group: cert-manager.io | ||
| path: spec/dnsNames |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # Adds namespace to all resources. | ||
| # Cluster-scoped deployment WITH webhook enabled (opt-in) | ||
| # Requires cert-manager to be installed in the cluster | ||
| namespace: splunk-operator | ||
|
|
||
| # Value of this field is prepended to the | ||
| # names of all resources, e.g. a deployment named | ||
| # "wordpress" becomes "alices-wordpress". | ||
| # Note that it should also match with the prefix (text before '-') of the namespace | ||
| # field above. | ||
| namePrefix: splunk-operator- | ||
|
|
||
| # Labels to add to all resources and selectors. | ||
| commonLabels: | ||
| name: splunk-operator | ||
|
|
||
| bases: | ||
| - ../crd | ||
| - ../rbac | ||
| - ../persistent-volume | ||
| - ../service | ||
| - ../manager | ||
| # [WEBHOOK] Enabled for opt-in webhook deployment | ||
| - ../webhook | ||
| # [CERTMANAGER] Required for webhook TLS | ||
| - ../certmanager | ||
| # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. | ||
| #- ../prometheus | ||
| # [METRICS] Expose the controller manager metrics service. | ||
| - metrics_service.yaml | ||
|
|
||
| patchesStrategicMerge: | ||
| # Mount the controller config file for loading manager configurations | ||
| # through a ComponentConfig type | ||
| #- manager_config_patch.yaml | ||
|
|
||
| # [WEBHOOK] Enabled for webhook deployment | ||
| - manager_webhook_patch.yaml | ||
|
|
||
| # [CERTMANAGER] Enabled for CA injection in the admission webhooks | ||
| - webhookcainjection_patch.yaml | ||
|
|
||
| # the following config is for teaching kustomize how to do var substitution | ||
| vars: | ||
| # [CERTMANAGER] Variables for cert-manager CA injection | ||
| - name: CERTIFICATE_NAMESPACE # namespace of the certificate CR | ||
| objref: | ||
| kind: Certificate | ||
| group: cert-manager.io | ||
| version: v1 | ||
| name: serving-cert # this name should match the one in certificate.yaml | ||
| fieldref: | ||
| fieldpath: metadata.namespace | ||
| - name: CERTIFICATE_NAME | ||
| objref: | ||
| kind: Certificate | ||
| group: cert-manager.io | ||
| version: v1 | ||
| name: serving-cert # this name should match the one in certificate.yaml | ||
| - name: SERVICE_NAMESPACE # namespace of the service | ||
| objref: | ||
| kind: Service | ||
| version: v1 | ||
| name: webhook-service | ||
| fieldref: | ||
| fieldpath: metadata.namespace | ||
| - name: SERVICE_NAME | ||
| objref: | ||
| kind: Service | ||
| version: v1 | ||
| name: webhook-service | ||
|
|
||
| #patches: | ||
| #- target: | ||
| # kind: Deployment | ||
| # name: controller-manager | ||
| # patch: |- | ||
| # - op: replace | ||
| # path: /metadata/name | ||
| # value: splunk-operator | ||
| #- target: | ||
| # kind: ServiceAccount | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this commented code?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To have the same behaviour as in config/default we should keep these options. There is an option that it's used by users |
||
| # name: controller-manager | ||
| # patch: |- | ||
| # - op: replace | ||
| # path: /metadata/name | ||
| # value: splunk-operator | ||
| #- target: | ||
| # kind: Service | ||
| # name: controller-manager-service | ||
| # patch: |- | ||
| # - op: replace | ||
| # path: /metadata/name | ||
| # value: splunk-operator-service | ||
| #- target: | ||
| # kind: Role | ||
| # name: manager-role | ||
| # patch: |- | ||
| # - op: replace | ||
| # path: /metadata/name | ||
| # value: splunk:operator:namespace-manager | ||
| #- target: | ||
| # kind: RoleBinding | ||
| # name: manager-rolebinding | ||
| # patch: |- | ||
| # - op: replace | ||
| # path: /metadata/name | ||
| # value: splunk:operator:namespace-manager | ||
|
|
||
| # currently patch is set to change deployment environment variables | ||
| patches: | ||
| - target: | ||
| kind: Deployment | ||
| name: controller-manager | ||
| patch: |- | ||
| - op: add | ||
| path: /spec/template/spec/containers/0/env | ||
| value: | ||
| - name: WATCH_NAMESPACE | ||
| value: WATCH_NAMESPACE_VALUE | ||
| - name: RELATED_IMAGE_SPLUNK_ENTERPRISE | ||
| value: SPLUNK_ENTERPRISE_IMAGE | ||
| - name: OPERATOR_NAME | ||
| value: splunk-operator | ||
| - name: SPLUNK_GENERAL_TERMS | ||
| value: SPLUNK_GENERAL_TERMS_VALUE | ||
| - name: ENABLE_WEBHOOKS | ||
| value: "true" | ||
| - name: POD_NAME | ||
| valueFrom: | ||
| fieldRef: | ||
| fieldPath: metadata.name | ||
| # [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443. | ||
| # More info: https://book.kubebuilder.io/reference/metrics | ||
| - path: manager_metrics_patch.yaml | ||
| target: | ||
| kind: Deployment | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... Maybe we should use name that express effect, not technology used. So maybe
ENABLE_EXTENDED_VALIDATION. I'm not sure TBH, what would be better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh I prefer to stick with
ENABLE_WEBHOOKS.random thoughts about this:
BUT
if we plan to add in future other types of webhooks, then probably we should split env per webhook. So my proposition is to use
ENABLE_VALIDATION_WEBHOOK