@@ -162,7 +162,7 @@ func setupPortForwarding(namespace, podName string, port int) error {
162
162
}
163
163
164
164
func mountPVCOverSSH (namespace , podName string , port int , localMountPoint , pvcName string ) error {
165
- sshfsCmd := exec .Command ("sshfs" , "-o" , "StrictHostKeyChecking=no,UserKnownHostsFile=/dev/null" , fmt .Sprintf ("root @localhost:/volume" ), localMountPoint , "-p" , fmt .Sprintf ("%d" , port ))
165
+ sshfsCmd := exec .Command ("sshfs" , "-o" , "StrictHostKeyChecking=no,UserKnownHostsFile=/dev/null" , fmt .Sprintf ("ve @localhost:/volume" ), localMountPoint , "-p" , fmt .Sprintf ("%d" , port ))
166
166
sshfsCmd .Stdout = os .Stdout
167
167
sshfsCmd .Stderr = os .Stderr
168
168
if err := sshfsCmd .Run (); err != nil {
@@ -200,6 +200,12 @@ func createPodSpec(podName string, port int, pvcName, sshKey, role string) *core
200
200
})
201
201
}
202
202
203
+ runAsNonRoot := true
204
+ runAsUser := int64 (2137 )
205
+ runAsGroup := int64 (2137 )
206
+ allowPrivilegeEscalation := false
207
+ readOnlyRootFilesystem := false
208
+
203
209
container := corev1.Container {
204
210
Name : "volume-exposer" ,
205
211
Image : "bfenski/volume-exposer:latest" ,
@@ -209,6 +215,13 @@ func createPodSpec(podName string, port int, pvcName, sshKey, role string) *core
209
215
},
210
216
},
211
217
Env : envVars ,
218
+ SecurityContext : & corev1.SecurityContext {
219
+ AllowPrivilegeEscalation : & allowPrivilegeEscalation ,
220
+ ReadOnlyRootFilesystem : & readOnlyRootFilesystem ,
221
+ Capabilities : & corev1.Capabilities {
222
+ Drop : []corev1.Capability {"ALL" },
223
+ },
224
+ },
212
225
}
213
226
214
227
podSpec := & corev1.Pod {
@@ -222,6 +235,11 @@ func createPodSpec(podName string, port int, pvcName, sshKey, role string) *core
222
235
},
223
236
Spec : corev1.PodSpec {
224
237
Containers : []corev1.Container {container },
238
+ SecurityContext : & corev1.PodSecurityContext {
239
+ RunAsNonRoot : & runAsNonRoot ,
240
+ RunAsUser : & runAsUser ,
241
+ RunAsGroup : & runAsGroup ,
242
+ },
225
243
},
226
244
}
227
245
0 commit comments