Skip to content

Commit

Permalink
Removes podTemplate field from EventListener
Browse files Browse the repository at this point in the history
This removes the deprecated podTemplate field from eventlistener spec.

Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
  • Loading branch information
SM43 committed Jun 2, 2021
1 parent e4d3752 commit bedb80e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 146 deletions.
24 changes: 0 additions & 24 deletions docs/eventlisteners.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +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 a `PodTemplate`](#specifying-a-podtemplate)
- [Specifying `Resources`](#specifying-resources)
- [Specifying a `kubernetesResource` object](#specifying-a-kubernetesresource-object)
- [Specifying `Replicas`](#specifying-replicas)
Expand Down Expand Up @@ -59,7 +58,6 @@ 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
- [`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 @@ -164,28 +162,6 @@ rules:
verbs: ["impersonate"]
```

### 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 Down
21 changes: 0 additions & 21 deletions pkg/apis/triggers/v1alpha1/event_listener_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,5 @@ func (el *EventListener) SetDefaults(ctx context.Context) {
}
}
}
el.Spec.updatePodTemplate()
}
}

func (spec *EventListenerSpec) updatePodTemplate() {
if spec.DeprecatedPodTemplate != nil {
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
}
spec.DeprecatedPodTemplate = nil
}
}
46 changes: 0 additions & 46 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 @@ -96,50 +94,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 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
23 changes: 5 additions & 18 deletions pkg/apis/triggers/v1alpha1/event_listener_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ type EventListener struct {
// EventListenerSpec defines the desired state of the EventListener, represented
// by a list of Triggers.
type EventListenerSpec struct {
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Triggers []EventListenerTrigger `json:"triggers"`
DeprecatedPodTemplate *PodTemplate `json:"podTemplate,omitempty"`
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
Resources Resources `json:"resources,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
Triggers []EventListenerTrigger `json:"triggers"`
NamespaceSelector NamespaceSelector `json:"namespaceSelector,omitempty"`
LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`
Resources Resources `json:"resources,omitempty"`
}

type Resources struct {
Expand All @@ -78,18 +77,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
35 changes: 0 additions & 35 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.

Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ type LRUCache interface {
// Clears all cache entries.
Purge()

// Resizes cache, returning number evicted
Resize(int) int
// Resizes cache, returning number evicted
Resize(int) int
}

0 comments on commit bedb80e

Please sign in to comment.