@@ -110,6 +110,7 @@ import (
110
110
"k8s.io/kubernetes/pkg/util/mount"
111
111
nodeutil "k8s.io/kubernetes/pkg/util/node"
112
112
"k8s.io/kubernetes/pkg/util/oom"
113
+ "k8s.io/kubernetes/pkg/util/selinux"
113
114
"k8s.io/kubernetes/pkg/volume"
114
115
"k8s.io/kubernetes/pkg/volume/csi"
115
116
"k8s.io/kubernetes/pkg/volume/util/subpath"
@@ -1222,6 +1223,8 @@ type Kubelet struct {
1222
1223
// 4. the pod-resources directory
1223
1224
func (kl * Kubelet ) setupDataDirs () error {
1224
1225
kl .rootDirectory = path .Clean (kl .rootDirectory )
1226
+ pluginRegistrationDir := kl .getPluginsRegistrationDir ()
1227
+ pluginsDir := kl .getPluginsDir ()
1225
1228
if err := os .MkdirAll (kl .getRootDir (), 0750 ); err != nil {
1226
1229
return fmt .Errorf ("error creating root directory: %v" , err )
1227
1230
}
@@ -1240,6 +1243,16 @@ func (kl *Kubelet) setupDataDirs() error {
1240
1243
if err := os .MkdirAll (kl .getPodResourcesDir (), 0750 ); err != nil {
1241
1244
return fmt .Errorf ("error creating podresources directory: %v" , err )
1242
1245
}
1246
+ if selinux .SELinuxEnabled () {
1247
+ err := selinux .SetFileLabel (pluginRegistrationDir , config .KubeletPluginsDirSELinuxLabel )
1248
+ if err != nil {
1249
+ klog .Warningf ("Unprivileged containerized plugins might not work. Could not set selinux context on %s: %v" , pluginRegistrationDir , err )
1250
+ }
1251
+ err = selinux .SetFileLabel (pluginsDir , config .KubeletPluginsDirSELinuxLabel )
1252
+ if err != nil {
1253
+ klog .Warningf ("Unprivileged containerized plugins might not work. Could not set selinux context on %s: %v" , pluginsDir , err )
1254
+ }
1255
+ }
1243
1256
return nil
1244
1257
}
1245
1258
0 commit comments