@@ -81,8 +81,12 @@ func (s *csiNodeSyncer) SyncFn() error {
81
81
82
82
func (s * csiNodeSyncer ) ensurePodSpec () corev1.PodSpec {
83
83
return corev1.PodSpec {
84
- Containers : s .ensureContainersSpec (),
85
- Volumes : s .ensureVolumes (),
84
+ Containers : s .ensureContainersSpec (),
85
+ Volumes : s .ensureVolumes (),
86
+ SecurityContext : & corev1.PodSecurityContext {
87
+ RunAsNonRoot : func (b bool ) * bool { return & b }(true ),
88
+ RunAsUser : func (uid int64 ) * int64 { return & uid }(2121 ),
89
+ },
86
90
ServiceAccountName : constants .GetResourceName (constants .CSINodeServiceAccount ),
87
91
}
88
92
}
@@ -123,12 +127,12 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
123
127
})
124
128
125
129
nodePlugin .SecurityContext = & corev1.SecurityContext {
126
- Privileged : util .True (),
127
- AllowPrivilegeEscalation : util .True (),
130
+ RunAsNonRoot : util .False (),
131
+ Privileged : util .True (),
132
+ RunAsUser : func (uid int64 ) * int64 { return & uid }(0 ),
128
133
}
129
134
fillSecurityContextCapabilities (
130
135
nodePlugin .SecurityContext ,
131
- "SYS_ADMIN" ,
132
136
)
133
137
134
138
// node driver registrar sidecar
@@ -140,7 +144,9 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
140
144
"--v=5" ,
141
145
},
142
146
)
143
- registrar .SecurityContext = & corev1.SecurityContext {AllowPrivilegeEscalation : util .False ()}
147
+ registrar .SecurityContext = & corev1.SecurityContext {RunAsNonRoot : util .False (),
148
+ RunAsUser : func (uid int64 ) * int64 { return & uid }(0 ),
149
+ Privileged : util .False ()}
144
150
fillSecurityContextCapabilities (registrar .SecurityContext )
145
151
registrar .ImagePullPolicy = s .getCSINodeDriverRegistrarPullPolicy ()
146
152
registrar .Resources = getSidecarResourceRequests (s .driver , constants .CSINodeDriverRegistrar )
@@ -154,7 +160,10 @@ func (s *csiNodeSyncer) ensureContainersSpec() []corev1.Container {
154
160
healthPortArg ,
155
161
},
156
162
)
157
- livenessProbe .SecurityContext = & corev1.SecurityContext {AllowPrivilegeEscalation : util .False ()}
163
+ livenessProbe .SecurityContext = & corev1.SecurityContext {RunAsNonRoot : util .False (),
164
+ RunAsUser : func (uid int64 ) * int64 { return & uid }(0 ),
165
+ Privileged : util .False (),
166
+ }
158
167
fillSecurityContextCapabilities (livenessProbe .SecurityContext )
159
168
livenessProbe .ImagePullPolicy = s .getCSINodeDriverRegistrarPullPolicy ()
160
169
livenessProbe .Resources = getSidecarResourceRequests (s .driver , constants .LivenessProbe )
0 commit comments