Skip to content

Commit b2818f1

Browse files
committed
fix: disable service account token automount for user pods
1 parent 8c0b0cf commit b2818f1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/types/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,10 @@ func (service *Service) ToPodSpec(cfg *Config) (*v1.PodSpec, error) {
351351
if err != nil {
352352
return nil, err
353353
}
354+
disableServiceAccountTokenAutomount := false
354355

355356
podSpec := &v1.PodSpec{
357+
AutomountServiceAccountToken: &disableServiceAccountTokenAutomount,
356358
ImagePullSecrets: SetImagePullSecrets(service.ImagePullSecrets),
357359
Containers: []v1.Container{
358360
{

pkg/types/service_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ func TestToPodSpec(t *testing.T) {
354354
if podSpec.Containers[0].Command[0] != fmt.Sprintf("%s/%s", VolumePath, WatchdogName) {
355355
t.Fatalf("expected command to be supervisor path %s, got %s", fmt.Sprintf("%s/%s", VolumePath, WatchdogName), podSpec.Containers[0].Command[0])
356356
}
357+
if podSpec.AutomountServiceAccountToken == nil {
358+
t.Fatalf("expected automountServiceAccountToken to be set")
359+
}
360+
if *podSpec.AutomountServiceAccountToken {
361+
t.Fatalf("expected automountServiceAccountToken to be false")
362+
}
357363

358364
}
359365
})

0 commit comments

Comments
 (0)