Skip to content
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

Provide the capability for 3rd parties to integrate in our validation webhook #4395

Open
tomkerkhove opened this issue Mar 21, 2023 · 9 comments
Labels
feature-request All issues for new features that have not been committed to needs-discussion stale-bot-ignore All issues that should not be automatically closed by our stale bot

Comments

@tomkerkhove
Copy link
Member

Proposal

Provide the capability for 3rd parties to integrate in our validation webhook so that they integrate their own logic.

This should be done by introducing a new CRD which defines an HTTP/gRPC endpoint that KEDA will call during validation. If the validation endpoint becomes unreachable/non responding, then the status of the new CRD should reflect this but validation will be skipped for a while to avoid it causing KEDA to fail/time out.

Use-Case

Provide the capability for 3rd parties to integrate in our validation webhook so that they integrate their own logic.

This allows platform builders/cluster operators to enforce their own best practices and tie in to our validation process.

Is this a feature you are interested in implementing yourself?

No

Anything else?

No response

@tomkerkhove tomkerkhove added needs-discussion feature-request All issues for new features that have not been committed to labels Mar 21, 2023
@stale
Copy link

stale bot commented May 20, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label May 20, 2023
@tomkerkhove tomkerkhove removed the stale All issues that are marked as stale due to inactivity label May 21, 2023
@tomkerkhove
Copy link
Member Author

Any thoughts on this @kedacore/keda-maintainers?

@zroubalik
Copy link
Member

We should have this.

@stale
Copy link

stale bot commented Jul 22, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale All issues that are marked as stale due to inactivity label Jul 22, 2023
@stale
Copy link

stale bot commented Jul 29, 2023

This issue has been automatically closed due to inactivity.

@stale stale bot closed this as completed Jul 29, 2023
@tomkerkhove tomkerkhove reopened this Aug 10, 2023
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Aug 10, 2023
@tomkerkhove tomkerkhove added stale-bot-ignore All issues that should not be automatically closed by our stale bot stale All issues that are marked as stale due to inactivity labels Aug 10, 2023
@stale stale bot removed the stale All issues that are marked as stale due to inactivity label Aug 10, 2023
@pokgak
Copy link

pokgak commented Jan 14, 2024

Since no one has commented on this yet; 3rd-party validation can be done with the upcoming feature ValidatingAdmissionPolicy without any changes required on keda part.

https://kubernetes.io/docs/reference/access-authn-authz/validating-admission-policy/

@Tomer20
Copy link

Tomer20 commented Aug 23, 2024

Good call @pokgak!

That configuration worked well for me:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: "limit-apps-replicas.example.com"
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups:   ["apps"]
      apiVersions: ["v1"]
      operations:  ["CREATE", "UPDATE"]
      resources:   ["deployments", "replicasets"]
  validations:
    - expression: "object.spec.replicas <= 10"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: "limit-keda-replicas.example.com"
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups:   ["keda.sh"]
      apiVersions: ["v1alpha1"]
      operations:  ["CREATE", "UPDATE"]
      resources:   ["scaledobjects"]
  validations:
    - expression: "object.spec.maxReplicaCount <= 10"
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: "limit-apps-replicas-binding.example.com"
spec:
  policyName: "limit-apps-replicas.example.com"
  validationActions: [Deny]
  matchResources:
    namespaceSelector:
      matchLabels:
        kubernetes.io/metadata.name: k8s-limitations
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicyBinding
metadata:
  name: "limit-keda-replicas-binding.example.com"
spec:
  policyName: "limit-keda-replicas.example.com"
  validationActions: [Deny]
  matchResources:
    namespaceSelector:
      matchLabels:
        kubernetes.io/metadata.name: k8s-limitations

@zroubalik
Copy link
Member

@Tomer20 this is great, could you please contribute this to our documentation? Probably here: https://keda.sh/docs/2.15/operate/admission-webhooks/

@Tomer20
Copy link

Tomer20 commented Sep 20, 2024

@Tomer20 this is great, could you please contribute this to our documentation? Probably here: https://keda.sh/docs/2.15/operate/admission-webhooks/

Sure thing @zroubalik 😄 Here's the PR, any feedback is welcome: kedacore/keda-docs#1471.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request All issues for new features that have not been committed to needs-discussion stale-bot-ignore All issues that should not be automatically closed by our stale bot
Projects
Status: Proposed
Development

No branches or pull requests

4 participants