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

Add ClusterInterceptor CRD for registering interceptors #960

Merged
merged 1 commit into from
Mar 11, 2021

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Feb 17, 2021

Changes

This commit adds a new CRD type called ClusterInterceptor. In TEP-0026 this
type was called InterceptorConfig

The spec currently only contains a clientConfig field to locate where
the interceptoris running. Other fields will be added as they are
implemented in follow ups.

This commit also adds a simple reconciler for this type that resolves
the clientConfig to a URL and adds it to the status.address.url field.

Part of #868

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes

A new CRD called ClusterInterceptor has been added that allows for users to register new Interceptor types.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Feb 17, 2021
@tekton-robot tekton-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Feb 17, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 0.0%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 0.0%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 88.9%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 88.9%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/interceptortype/controller.go Do not exist 0.0%
pkg/reconciler/v1alpha1/interceptortype/interceptortype.go Do not exist 90.9%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 88.9%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/interceptortype/controller.go Do not exist 0.0%
pkg/reconciler/v1alpha1/interceptortype/interceptortype.go Do not exist 90.9%

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/interceptortype/controller.go Do not exist 0.0%
pkg/reconciler/v1alpha1/interceptortype/interceptortype.go Do not exist 90.9%

@dibyom dibyom marked this pull request as ready for review February 18, 2021 15:52
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 18, 2021
@dibyom
Copy link
Member Author

dibyom commented Feb 18, 2021

/cc @savitaashture @wlynch @MarcelMue @bigkevmcd

I broke off #921 into multiple PRs. One change I did was to call the CRD InterceptorType instead of just Interceptor to indicate that it defines a new type or kind of interceptor.

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/interceptortype/controller.go Do not exist 0.0%
pkg/reconciler/v1alpha1/interceptortype/interceptortype.go Do not exist 90.9%

-->
# InterceptorType

A `InterceptorType` is cluster scoped resource that registers a new Interceptor that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure we want this to be cluster scoped. In particular, I'm thinking about how we can expose custom interceptors that can only be used within a single tenant namespace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If its not cluster scoped, each new namespace would have to install their own version of Interceptors....could we not use RBAC to restrict if certain interceptors need to be limited?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chatted with @wlynch about this. We will start off with a cluster scoped CRD but will implement a Namespace scoped version of this in the future as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's update the docs to reflect the change.


// InterceptorTypeSpec describes the Spec for an InterceptorType
type InterceptorTypeSpec struct {
ClientConfig ClientConfig `json:"clientConfig"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reuse WebhookClientConfig?

At the very least we can likely reuse the ServiceReference if we want to use the apis.URL for URL. The cert data is also useful for HTTPS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using a WebhookClientConfig is a good idea - maybe just reimplementing the type here if we are concerned about dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I am basically reimplementing the type here....two differences:

  1. using apis.URL instead of string for the URL type for better validation/json marshalling
  2. we do not have a caCert field type (yet!) for HTTPS

Pulling in a new dependency for just the two structs seems much so I decided to copy the structs. It also allows us to make changes (e.g. making the port a *int instead of int as suggested below)


## Syntax

To define a configuration file for an `Interceptor` resource, you can specify
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bikeshed: I kind of like InterceptorConfiguration to be consistent with ValidatingWebhookConfiguration.

Other good ideas to borrow from admission webhooks we should look into later:

  • Version info (e.g. have different routes based on interceptor version)
  • Timeout

Copy link
Member Author

@dibyom dibyom Feb 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm yeah...this CRD is definitely based on the WebhookConfiguration CRDs....I don't have a strong preference on calling this InterceptorConfguration or something else --> I thought it was a bit confusing in the sense its not clear if it is some interceptor configuration that can be reused within a trigger vs configuration for a new kind of interceptor.

The InterceptorType name can be a bit awkward a times too though like we now have a file called interceptor_type_types.go

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't love the Configuration suffix. It makes sense if we have a different Interceptor object but a Configuration suffix without an Interceptor CRD seems weird to me.

No strong opinions though.

docs/interceptortypes.md Outdated Show resolved Hide resolved
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Outdated Show resolved Hide resolved
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/interceptor_type_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/interceptor_type_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/interceptortype/controller.go Do not exist 0.0%
pkg/reconciler/v1alpha1/interceptortype/interceptortype.go Do not exist 90.9%

@dibyom dibyom changed the title Add InterceptorType as a cluster scoped CRD for registering interceptors Add ClusterInterceptor as a cluster scoped CRD for registering interceptors Feb 24, 2021
@dibyom dibyom changed the title Add ClusterInterceptor as a cluster scoped CRD for registering interceptors Add ClusterInterceptor CRD for registering interceptors Feb 24, 2021
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm w/ minor doc changes.

Since this is a new type, would appreciate a second pair of eyes as an approver!

Comment on lines 17 to 35
- [Interceptors](#interceptors)
- [Syntax](#syntax)
- [clientConfig](#clientConfig)

## Syntax

To define a configuration file for an `Interceptor` resource, you can specify
the following fields:

- Required:
- [`apiVersion`][kubernetes-overview] - Specifies the API version, for example
`triggers.tekton.dev/v1alpha1`.
- [`kind`][kubernetes-overview] - Specifies the `Trigger` resource
object.
- [`metadata`][kubernetes-overview] - Specifies data to uniquely identify the
`Interceptor` resource object, for example a `name`.
- [`spec`][kubernetes-overview] - Specifies the configuration information for
your Interceptor resource object. The spec include:
- [`clientConfig`] - Specifies how a client (e.g. an EventListener) can communicate with the Interceptor.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few more Interceptor -> ClusterInterceptor replacements need to be made in here.

@dibyom
Copy link
Member Author

dibyom commented Feb 26, 2021

/cc @sergetron for a docs review!

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/cluster_interceptor_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/clusterinterceptor/clusterinterceptor.go Do not exist 90.9%
pkg/reconciler/v1alpha1/clusterinterceptor/controller.go Do not exist 0.0%

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 3, 2021
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 4, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/cluster_interceptor_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/clusterinterceptor/clusterinterceptor.go Do not exist 90.9%
pkg/reconciler/v1alpha1/clusterinterceptor/controller.go Do not exist 0.0%

Base automatically changed from master to main March 10, 2021 15:03
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/cluster_interceptor_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/clusterinterceptor/clusterinterceptor.go Do not exist 90.9%
pkg/reconciler/v1alpha1/clusterinterceptor/controller.go Do not exist 0.0%

@dibyom
Copy link
Member Author

dibyom commented Mar 10, 2021

/test pull-tekton-triggers-integration-tests

Copy link
Contributor

@savitaashture savitaashture left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2021
@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 11, 2021
This commit adds a new CRD type called ClusterInterceptor. In TEP-0026 this
type was called InterceptorConfiguration

The `spec` currently only contains a clientConfig field to locate where
the interceptor is running. Other fields will be added as they are
implemented in follow ups.

This commit also adds a simple reconciler for this type that resolves
the clientConfig to a URL and adds it to the `status.address.url` field.

Part of tektoncd#868

Signed-off-by: Dibyo Mukherjee <[email protected]>
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2021
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/triggers/v1alpha1/cluster_interceptor_defaults.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_types.go Do not exist 100.0%
pkg/apis/triggers/v1alpha1/cluster_interceptor_validation.go Do not exist 100.0%
pkg/reconciler/v1alpha1/clusterinterceptor/clusterinterceptor.go Do not exist 90.9%
pkg/reconciler/v1alpha1/clusterinterceptor/controller.go Do not exist 0.0%

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 11, 2021
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: savitaashture, wlynch

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [savitaashture,wlynch]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot merged commit 61544a0 into tektoncd:main Mar 11, 2021
@dibyom dibyom deleted the itype branch March 18, 2021 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants