Skip to content

Commit

Permalink
Add ImagePullSecrets field when create Deployment by EventListener
Browse files Browse the repository at this point in the history
Signed-off-by: lx1036 <[email protected]>
  • Loading branch information
lx1036 committed Dec 30, 2024
1 parent ed98593 commit bf5b195
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/apis/triggers/v1beta1/event_listener_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ func podSpecMask(in *corev1.PodSpec) *corev1.PodSpec {
out.NodeSelector = in.NodeSelector
out.Affinity = in.Affinity
out.TopologySpreadConstraints = in.TopologySpreadConstraints
out.ImagePullSecrets = in.ImagePullSecrets

// Disallowed fields
// This list clarifies which all podspec fields are not allowed.
out.Volumes = nil
out.EnableServiceLinks = nil
out.ImagePullSecrets = nil
out.InitContainers = nil
out.RestartPolicy = ""
out.TerminationGracePeriodSeconds = nil
Expand Down
5 changes: 5 additions & 0 deletions pkg/reconciler/eventlistener/resources/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func MakeDeployment(ctx context.Context, el *v1beta1.EventListener, configAcc re
nodeSelector, annotations map[string]string
affinity *corev1.Affinity
topologySpreadConstraints []corev1.TopologySpreadConstraint
imagePullSecrets []corev1.LocalObjectReference
)

for _, v := range container.Env {
Expand All @@ -106,6 +107,9 @@ func MakeDeployment(ctx context.Context, el *v1beta1.EventListener, configAcc re
if len(el.Spec.Resources.KubernetesResource.Template.Spec.NodeSelector) != 0 {
nodeSelector = el.Spec.Resources.KubernetesResource.Template.Spec.NodeSelector
}
if len(el.Spec.Resources.KubernetesResource.Template.Spec.ImagePullSecrets) != 0 {
imagePullSecrets = el.Spec.Resources.KubernetesResource.Template.Spec.ImagePullSecrets
}
if el.Spec.Resources.KubernetesResource.Template.Spec.ServiceAccountName != "" {
serviceAccountName = el.Spec.Resources.KubernetesResource.Template.Spec.ServiceAccountName
}
Expand Down Expand Up @@ -137,6 +141,7 @@ func MakeDeployment(ctx context.Context, el *v1beta1.EventListener, configAcc re
Annotations: annotations,
},
Spec: corev1.PodSpec{
ImagePullSecrets: imagePullSecrets,
Tolerations: tolerations,
NodeSelector: nodeSelector,
ServiceAccountName: serviceAccountName,
Expand Down

0 comments on commit bf5b195

Please sign in to comment.