From d9ddf9d3cbcdbee570996623f101d2d536b8eefc Mon Sep 17 00:00:00 2001 From: jmcshane Date: Fri, 9 Apr 2021 19:13:46 -0500 Subject: [PATCH] Removing deprecated fields Closes #904 This PR removes the deprecated ServiceType and PodTemplate fields from the EventListener Spec --- docs/eventlisteners.md | 40 ------------ examples/README.md | 1 - examples/bitbucket/README.md | 4 -- examples/github/README.md | 4 -- examples/gitlab/README.md | 4 -- examples/selectors/label/README.md | 5 -- examples/selectors/namespace/README.md | 5 -- examples/v1alpha1-task/README.md | 4 -- .../v1alpha1/event_listener_defaults.go | 33 ---------- .../v1alpha1/event_listener_defaults_test.go | 63 ------------------- .../triggers/v1alpha1/event_listener_types.go | 24 ++----- .../v1alpha1/zz_generated.deepcopy.go | 31 --------- test/builder/eventlistener.go | 35 ----------- 13 files changed, 4 insertions(+), 249 deletions(-) diff --git a/docs/eventlisteners.md b/docs/eventlisteners.md index c20692db5..ace4b3158 100644 --- a/docs/eventlisteners.md +++ b/docs/eventlisteners.md @@ -21,8 +21,6 @@ or more [`Interceptors`](./interceptors.md). - [Structure of an `EventListener`](#structure-of-an-eventlistener) - [Specifying the Kubernetes service account](#specifiying-the-kubernetes-service-account) - [Specifying `Triggers`](#specifying-triggers) -- [Specifying the Kubernetes service type](#specifying-the-kubernetes-service-type) -- [Specifying a `PodTemplate`](#specifying-a-podtemplate) - [Specifying `Resources`](#specifying-resources) - [Specifying a `kubernetesResource` object](#specifying-a-kubernetesresource-object) - [Specifying a `CustomResource` object](#specifying-a-customresource-object) @@ -59,9 +57,7 @@ An `EventListener` definition consists of the following fields: - [`serviceAccountName`](#specifiying-the-kubernetes-service-account) - Specifies the `ServiceAccount` the `EventListener` will use to instantiate Tekton resources - Optional: - [`triggers`](#specifying-triggers) - specifies a list of `Triggers` to execute upon event detection - - [`serviceType`](#specifying-the-kubernetes-service-type) - specifies the type of service you want the `EventListener` to use to listen for events - [`replicas`](#specifying-a-kubernetesresource-object) - specifies the number of `EventListener` pods to create (only for `kubernetesResource` objects) - - [`podTemplate`](#specifying-a-podtemplate) - specifies the `PodTemplate` for your `EventListener` pod - [`resources`](#specifying-resources) - specifies the resources that will be available to the event listening service - [`namespaceSelector`](#constraining-eventlisteners-to-specific-namespaces) - specifies the namespace for the `EventListener`; this is where the `EventListener` looks for the specified `Triggers` and stores the Tekton objects it instantiates upon event detection @@ -166,39 +162,6 @@ rules: verbs: ["impersonate"] ``` -## Specifying the Kubernetes Service type - -**Note:** This field has been deprecated; use the `Resources` field instead. The legacy documentation below is presented for reference only. - -You must specify a [Kubernetes Service](https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types) type -for your `EventListener` in the `serviceType` field. The default value is `ClusterIP` which allows all pods running on your Kubernetes cluster -to access services using the cluster's DNS. You can also specify `NodePort` and `LoadBalancer` as the value. For information, see the Kubernetes -Service documentation. - -If you want to allow external services, such as Github Webhooks, to connect to your cluster, see [Exposing an `EventListener` outside of the cluster](#exposing-an-event-listener-outside-of-the-cluster). - -### Specifying a `PodTemplate` - -**Note:** This field has been deprecated; use the `Resources` field instead. The legacy documentation below is presented for reference only. - -The `podTemplate` field is optional. A PodTemplate is specifications for -creating EventListener pod. A PodTemplate consists of: -- `tolerations` - list of toleration which allows pods to schedule onto the nodes with matching taints. -This is needed only if you want to schedule EventListener pod to a tainted node. -- `nodeSelector` - key-value labels the node has which an EventListener pod should be scheduled on. - -```yaml -spec: - podTemplate: - nodeSelector: - app: test - tolerations: - - key: key - value: value - operator: Equal - effect: NoSchedule -``` - ## Specifying `Resources` You can optionally customize the sink deployment for your `EventListener` using the `resources` field. It accepts the following types of objects: @@ -221,9 +184,6 @@ VolumeMounts Env ``` -**Note:** The `resources` field is currently optional to ensure backward compatibility with the legacy behavior of the `podTemplate`, `serviceType`, and `serviceAccountName` fieds. -We plan to deprecate the `serviceType` and `podTemplate` fields in a future release and replace them entirely with the `resources` field. See [TEP-0008](https://github.com/tektoncd/community/blob/master/teps/0008-support-knative-service-for-triggers-eventlistener-pod.md) for more information. - ### Specifying a `kubernetesResource` object Below is an example `resources:` field definition specifying a `kubernetesResource` object: diff --git a/examples/README.md b/examples/README.md index 3ed2f5c5d..ec3dbc524 100644 --- a/examples/README.md +++ b/examples/README.md @@ -105,7 +105,6 @@ spec: value: application/json pipelineRef: name: simple-pipeline - podTemplate: {} resources: - name: git-source resourceSpec: diff --git a/examples/bitbucket/README.md b/examples/bitbucket/README.md index 5ca6bec3f..201f8cc3a 100644 --- a/examples/bitbucket/README.md +++ b/examples/bitbucket/README.md @@ -18,10 +18,6 @@ Creates an EventListener that listens for Bitbucket webhook events. 8080 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/main/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - 1. Test by sending the sample payload. ```bash diff --git a/examples/github/README.md b/examples/github/README.md index 54faaf2b1..0a365f4fb 100644 --- a/examples/github/README.md +++ b/examples/github/README.md @@ -18,10 +18,6 @@ Creates an EventListener that listens for GitHub webhook events. 8080 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/main/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - 1. Test by sending the sample payload. ```bash diff --git a/examples/gitlab/README.md b/examples/gitlab/README.md index a103fe546..a4b0021af 100644 --- a/examples/gitlab/README.md +++ b/examples/gitlab/README.md @@ -18,10 +18,6 @@ Creates an EventListener that listens for GitLab webhook events. 8080 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/main/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - 1. Test by sending the sample payload. ```bash diff --git a/examples/selectors/label/README.md b/examples/selectors/label/README.md index 450f795b1..b8a863522 100644 --- a/examples/selectors/label/README.md +++ b/examples/selectors/label/README.md @@ -17,11 +17,6 @@ Creates an EventListener that serve triggers selected via a label selector. -l eventlistener=listener-label-selector) 8000 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/master/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - For this example, modify `02_eventlistener-label-sel.yaml` - 3. Create sample pipeline in namespace `foo`: ```bash kubectl apply -f examples/example-pipeline.yaml -n foo diff --git a/examples/selectors/namespace/README.md b/examples/selectors/namespace/README.md index ab19d55f9..40856f856 100644 --- a/examples/selectors/namespace/README.md +++ b/examples/selectors/namespace/README.md @@ -17,11 +17,6 @@ Creates an EventListener that serve triggers in multiple namespaces. -l eventlistener=listener-sel) 8000 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/main/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - For this example, modify `02_eventlistener-sel.yaml` - 3. Create sample pipeline in namespace bar: ```bash kubectl apply -f examples/example-pipeline.yaml -n bar diff --git a/examples/v1alpha1-task/README.md b/examples/v1alpha1-task/README.md index ce6d9917d..839217f1e 100644 --- a/examples/v1alpha1-task/README.md +++ b/examples/v1alpha1-task/README.md @@ -18,10 +18,6 @@ Creates an EventListener that creates a v1alpha1 TaskRun. 8080 ``` - **Note**: Instead of port forwarding, you can set the - [`serviceType`](https://github.com/tektoncd/triggers/blob/master/docs/eventlisteners.md#serviceType) - to `LoadBalancer` to expose the EventListener with a public IP. - 1. Test by sending the sample payload. ```shell script diff --git a/pkg/apis/triggers/v1alpha1/event_listener_defaults.go b/pkg/apis/triggers/v1alpha1/event_listener_defaults.go index c7b30d0eb..5f878152f 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_defaults.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_defaults.go @@ -45,10 +45,6 @@ func (el *EventListener) SetDefaults(ctx context.Context) { } } } - // Remove Deprecated Resource Fields - // To be removed in a later release #904 - el.Spec.updatePodTemplate() - el.Spec.updateServiceType() // To be removed in a later release #1020 el.Spec.updateReplicas() } @@ -72,32 +68,3 @@ func (spec *EventListenerSpec) updateReplicas() { } } } - -// To be Removed in a later release #904 -func (spec *EventListenerSpec) updatePodTemplate() { - if spec.DeprecatedPodTemplate.NodeSelector != nil { - if spec.Resources.KubernetesResource == nil { - spec.Resources.KubernetesResource = &KubernetesResource{} - } - spec.Resources.KubernetesResource.Template.Spec.NodeSelector = spec.DeprecatedPodTemplate.NodeSelector - spec.DeprecatedPodTemplate.NodeSelector = nil - } - if spec.DeprecatedPodTemplate.Tolerations != nil { - if spec.Resources.KubernetesResource == nil { - spec.Resources.KubernetesResource = &KubernetesResource{} - } - spec.Resources.KubernetesResource.Template.Spec.Tolerations = spec.DeprecatedPodTemplate.Tolerations - spec.DeprecatedPodTemplate.Tolerations = nil - } -} - -// To be Removed in a later release #904 -func (spec *EventListenerSpec) updateServiceType() { - if spec.DeprecatedServiceType != "" { - if spec.Resources.KubernetesResource == nil { - spec.Resources.KubernetesResource = &KubernetesResource{} - } - spec.Resources.KubernetesResource.ServiceType = spec.DeprecatedServiceType - spec.DeprecatedServiceType = "" - } -} diff --git a/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go b/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go index 49ee5bc92..cd515911d 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go @@ -22,8 +22,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1" - corev1 "k8s.io/api/core/v1" - duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/ptr" ) @@ -113,67 +111,6 @@ func TestEventListenerSetDefaults(t *testing.T) { }, }, }, - }, { - name: "deprecate podTemplate nodeselector to resource", - in: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - DeprecatedPodTemplate: v1alpha1.PodTemplate{ - NodeSelector: map[string]string{"beta.kubernetes.io/os": "linux"}, - }, - }, - }, - wc: v1alpha1.WithUpgradeViaDefaulting, - want: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - Resources: v1alpha1.Resources{ - KubernetesResource: &v1alpha1.KubernetesResource{ - WithPodSpec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{ - NodeSelector: map[string]string{"beta.kubernetes.io/os": "linux"}, - }, - }, - }}, - }, - }, - }, - }, { - name: "deprecate serviceType to resource", - in: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - DeprecatedServiceType: "NodePort", - }, - }, - wc: v1alpha1.WithUpgradeViaDefaulting, - want: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - Resources: v1alpha1.Resources{ - KubernetesResource: &v1alpha1.KubernetesResource{ - ServiceType: "NodePort", - }, - }, - }, - }, - }, { - name: "deprecate podTemplate toleration to resource", - in: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - DeprecatedPodTemplate: v1alpha1.PodTemplate{Tolerations: []corev1.Toleration{{Key: "key"}}}, - }, - }, - wc: v1alpha1.WithUpgradeViaDefaulting, - want: &v1alpha1.EventListener{ - Spec: v1alpha1.EventListenerSpec{ - Resources: v1alpha1.Resources{ - KubernetesResource: &v1alpha1.KubernetesResource{ - WithPodSpec: duckv1.WithPodSpec{ - Template: duckv1.PodSpecable{ - Spec: corev1.PodSpec{Tolerations: []corev1.Toleration{{Key: "key"}}}, - }, - }}, - }, - }, - }, }, { name: "different value for replicas other than 0", in: &v1alpha1.EventListener{ diff --git a/pkg/apis/triggers/v1alpha1/event_listener_types.go b/pkg/apis/triggers/v1alpha1/event_listener_types.go index 2c1918134..af7f349cd 100644 --- a/pkg/apis/triggers/v1alpha1/event_listener_types.go +++ b/pkg/apis/triggers/v1alpha1/event_listener_types.go @@ -58,14 +58,10 @@ type EventListenerSpec struct { ServiceAccountName string `json:"serviceAccountName"` Triggers []EventListenerTrigger `json:"triggers"` // To be removed in a later release #1020 - DeprecatedReplicas *int32 `json:"replicas,omitempty"` - // To be removed in a later release #904 - DeprecatedServiceType corev1.ServiceType `json:"serviceType,omitempty"` - // To be removed in a later release #904 - DeprecatedPodTemplate PodTemplate `json:"podTemplate,omitempty"` - NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"` - LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` - Resources Resources `json:"resources,omitempty"` + DeprecatedReplicas *int32 `json:"replicas,omitempty"` + NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"` + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` + Resources Resources `json:"resources,omitempty"` } type Resources struct { @@ -83,18 +79,6 @@ type KubernetesResource struct { duckv1.WithPodSpec `json:"spec,omitempty"` } -type PodTemplate struct { - // If specified, the pod's tolerations. - // +optional - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - - // NodeSelector is a selector which must be true for the pod to fit on a node. - // Selector which must match a node's labels for the pod to be scheduled on that node. - // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` -} - // EventListenerTrigger represents a connection between TriggerBinding, Params, // and TriggerTemplate; TriggerBinding provides extracted values for // TriggerTemplate to then create resources from. TriggerRef can also be diff --git a/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go index 03846de71..506fc7343 100644 --- a/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go @@ -383,7 +383,6 @@ func (in *EventListenerSpec) DeepCopyInto(out *EventListenerSpec) { *out = new(int32) **out = **in } - in.DeprecatedPodTemplate.DeepCopyInto(&out.DeprecatedPodTemplate) in.NamespaceSelector.DeepCopyInto(&out.NamespaceSelector) if in.LabelSelector != nil { in, out := &in.LabelSelector, &out.LabelSelector @@ -631,36 +630,6 @@ func (in *ParamSpec) DeepCopy() *ParamSpec { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PodTemplate) DeepCopyInto(out *PodTemplate) { - *out = *in - if in.Tolerations != nil { - in, out := &in.Tolerations, &out.Tolerations - *out = make([]corev1.Toleration, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodTemplate. -func (in *PodTemplate) DeepCopy() *PodTemplate { - if in == nil { - return nil - } - out := new(PodTemplate) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Resources) DeepCopyInto(out *Resources) { *out = *in diff --git a/test/builder/eventlistener.go b/test/builder/eventlistener.go index a5feaa215..82a5ba533 100644 --- a/test/builder/eventlistener.go +++ b/test/builder/eventlistener.go @@ -32,9 +32,6 @@ type EventListenerOp func(*v1alpha1.EventListener) // EventListenerSpecOp is an operation which modifies the EventListenerSpec. type EventListenerSpecOp func(*v1alpha1.EventListenerSpec) -// EventListenerPodTemplateOp is an operation which modifies the PodTemplate. -type EventListenerPodTemplateOp func(*v1alpha1.PodTemplate) - // EventListenerStatusOp is an operation which modifies the EventListenerStatus. type EventListenerStatusOp func(*v1alpha1.EventListenerStatus) @@ -106,38 +103,6 @@ func EventListenerReplicas(replicas int32) EventListenerSpecOp { } } -// EventListenerPodTemplate sets the specified pod template of the EventListener. -func EventListenerPodTemplate(podTemplate v1alpha1.PodTemplate) EventListenerSpecOp { - return func(spec *v1alpha1.EventListenerSpec) { - spec.DeprecatedPodTemplate = podTemplate - } -} - -// EventListenerPodTemplateSpec creates an PodTemplate. -// Any number of EventListenerPodTemplateOp modifiers can be passed to transform it. -func EventListenerPodTemplateSpec(ops ...EventListenerPodTemplateOp) v1alpha1.PodTemplate { - pt := v1alpha1.PodTemplate{} - for _, op := range ops { - op(&pt) - } - - return pt -} - -// EventListenerPodTemplateTolerations sets the specified Tolerations of the EventListener PodTemplate. -func EventListenerPodTemplateTolerations(tolerations []corev1.Toleration) EventListenerPodTemplateOp { - return func(pt *v1alpha1.PodTemplate) { - pt.Tolerations = tolerations - } -} - -// EventListenerPodTemplateNodeSelector sets the specified NodeSelector of the EventListener PodTemplate. -func EventListenerPodTemplateNodeSelector(nodeSelector map[string]string) EventListenerPodTemplateOp { - return func(pt *v1alpha1.PodTemplate) { - pt.NodeSelector = nodeSelector - } -} - // EventListenerTrigger adds an EventListenerTrigger to the EventListenerSpec Triggers. // Any number of EventListenerTriggerOp modifiers can be passed to create/modify it. func EventListenerTrigger(ttName, apiVersion string, ops ...EventListenerTriggerOp) EventListenerSpecOp {