Skip to content

Commit

Permalink
Removing deprecated fields
Browse files Browse the repository at this point in the history
Closes #904

This PR removes the deprecated ServiceType and PodTemplate fields from the EventListener Spec
  • Loading branch information
jmcshane committed May 4, 2021
1 parent 4f77406 commit d9ddf9d
Show file tree
Hide file tree
Showing 13 changed files with 4 additions and 249 deletions.
40 changes: 0 additions & 40 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ spec:
value: application/json
pipelineRef:
name: simple-pipeline
podTemplate: {}
resources:
- name: git-source
resourceSpec:
Expand Down
4 changes: 0 additions & 4 deletions examples/bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions examples/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions examples/gitlab/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions examples/selectors/label/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions examples/selectors/namespace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions examples/v1alpha1-task/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 0 additions & 33 deletions pkg/apis/triggers/v1alpha1/event_listener_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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 = ""
}
}
63 changes: 0 additions & 63 deletions pkg/apis/triggers/v1alpha1/event_listener_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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{
Expand Down
24 changes: 4 additions & 20 deletions pkg/apis/triggers/v1alpha1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
31 changes: 0 additions & 31 deletions pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 0 additions & 35 deletions test/builder/eventlistener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit d9ddf9d

Please sign in to comment.