Skip to content

Commit c482a4e

Browse files
Fix: Add securityContext to Trigger dispatcher. (#970)
🐛 I was puzzled when picking up 1.8 that the ingress warnings went away, but the "dispatcher" warnings stuck around in GKE security posture. Turns out there are two places calling things "dispatcher" 🤦 so this fixes the other, which was also missed in the later source cleanup. /kind bug Co-authored-by: Matt Moore <[email protected]>
1 parent faa52e7 commit c482a4e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

pkg/reconciler/trigger/resources/dispatcher.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232

3333
"knative.dev/pkg/apis"
3434
"knative.dev/pkg/kmeta"
35+
"knative.dev/pkg/ptr"
3536
"knative.dev/pkg/system"
3637
)
3738

@@ -118,6 +119,14 @@ func MakeDispatcherDeployment(args *DispatcherArgs) *appsv1.Deployment {
118119
Name: "http-metrics",
119120
ContainerPort: 9090,
120121
}},
122+
SecurityContext: &corev1.SecurityContext{
123+
AllowPrivilegeEscalation: ptr.Bool(false),
124+
ReadOnlyRootFilesystem: ptr.Bool(true),
125+
RunAsNonRoot: ptr.Bool(true),
126+
Capabilities: &corev1.Capabilities{
127+
Drop: []corev1.Capability{"ALL"},
128+
},
129+
},
121130
}
122131
if args.Configs != nil {
123132
dispatcher.Env = append(dispatcher.Env, args.Configs.ToEnvVars()...)

pkg/reconciler/trigger/resources/dispatcher_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,14 @@ func deployment(opts ...func(*appsv1.Deployment)) *appsv1.Deployment {
215215
Name: "http-metrics",
216216
ContainerPort: 9090,
217217
}},
218+
SecurityContext: &corev1.SecurityContext{
219+
AllowPrivilegeEscalation: ptr.Bool(false),
220+
ReadOnlyRootFilesystem: ptr.Bool(true),
221+
RunAsNonRoot: ptr.Bool(true),
222+
Capabilities: &corev1.Capabilities{
223+
Drop: []corev1.Capability{"ALL"},
224+
},
225+
},
218226
}},
219227
},
220228
},

0 commit comments

Comments
 (0)