Merge pull request #2540 from travisn/disable-fsgroup
Allow disabling of fsGroup in the flex driver
This commit is contained in:
5 files changed
+57
-4
No files matched your search
@@ -13,7 +13,8 @@
|
||||
|
||||
### Ceph
|
||||
- A `CephNFS` CRD will start NFS daemon(s) for exporting CephFS volumes or RGW buckets. See the [NFS documentation](Documentation/ceph-nfs-crd.md).
|
||||
- Selinux labeling for mounts can now be toggled with the ROOK_ENABLE_SELINUX_RELABELING environment variable. This addresses https://github.com/rook/rook/issues/2417
|
||||
- Selinux labeling for mounts can now be toggled with the [ROOK_ENABLE_SELINUX_RELABELING](https://github.com/rook/rook/issues/2417) environment variable.
|
||||
- Recursive chown for mounts can now be toggled with the [ROOK_ENABLE_FSGROUP](https://github.com/rook/rook/issues/2254) environment variable.
|
||||
- Added the dashboard `port` configuration setting.
|
||||
- Added the dashboard `ssl` configuration setting.
|
||||
|
||||
|
||||
@@ -475,6 +475,10 @@ spec:
|
||||
# For more details see https://github.com/rook/rook/issues/2417
|
||||
- name: ROOK_ENABLE_SELINUX_RELABELING
|
||||
value: "true"
|
||||
# In large volumes it will take some time to chown all the files. Disable it here if you have performance issues.
|
||||
# For more details see https://github.com/rook/rook/issues/2254
|
||||
- name: ROOK_ENABLE_FSGROUP
|
||||
value: "true"
|
||||
# The name of the node to pass with the downward API
|
||||
- name: NODE_NAME
|
||||
valueFrom:
|
||||
|
||||
@@ -45,12 +45,19 @@ func initPlugin(cmd *cobra.Command, args []string) error {
|
||||
rookEnableSelinuxRelabeling = true
|
||||
}
|
||||
|
||||
status := flexvolume.DriverStatus{
|
||||
rookEnableFSGroup, err := strconv.ParseBool(os.Getenv(agent.RookEnableFSGroupEnv))
|
||||
if err != nil {
|
||||
// Don't log any errors to stdout as this will break the init. Just default the value to true.
|
||||
rookEnableFSGroup = true
|
||||
}
|
||||
|
||||
status := DriverStatus{
|
||||
Status: flexvolume.StatusSuccess,
|
||||
Capabilities: &flexvolume.DriverCapabilities{
|
||||
Capabilities: &DriverCapabilities{
|
||||
Attach: false,
|
||||
// Required for any mount performed on a host running selinux
|
||||
SELinuxRelabel: rookEnableSelinuxRelabeling,
|
||||
FSGroup: rookEnableFSGroup,
|
||||
},
|
||||
}
|
||||
if err := json.NewEncoder(os.Stdout).Encode(&status); err != nil {
|
||||
@@ -59,3 +66,35 @@ func initPlugin(cmd *cobra.Command, args []string) error {
|
||||
os.Exit(0)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FIX: After we move to the k8s 1.13 dependencies, we can remove this type
|
||||
// and reference the type in k8s.io/kubernetes/pkg/volume/flexvolume/driver-call.go
|
||||
type DriverStatus struct {
|
||||
// Status of the callout. One of "Success", "Failure" or "Not supported".
|
||||
Status string `json:"status"`
|
||||
// Reason for success/failure.
|
||||
Message string `json:"message,omitempty"`
|
||||
// Path to the device attached. This field is valid only for attach calls.
|
||||
// ie: /dev/sdx
|
||||
DevicePath string `json:"device,omitempty"`
|
||||
// Cluster wide unique name of the volume.
|
||||
VolumeName string `json:"volumeName,omitempty"`
|
||||
// Represents volume is attached on the node
|
||||
Attached bool `json:"attached,omitempty"`
|
||||
// Returns capabilities of the driver.
|
||||
// By default we assume all the capabilities are supported.
|
||||
// If the plugin does not support a capability, it can return false for that capability.
|
||||
Capabilities *DriverCapabilities `json:",omitempty"`
|
||||
// Returns the actual size of the volume after resizing is done, the size is in bytes.
|
||||
ActualVolumeSize int64 `json:"volumeNewSize,omitempty"`
|
||||
}
|
||||
|
||||
// FIX: After we move to the k8s 1.13 dependencies, we can remove this type
|
||||
// and reference the type in k8s.io/kubernetes/pkg/volume/flexvolume/driver-call.go
|
||||
type DriverCapabilities struct {
|
||||
Attach bool `json:"attach"`
|
||||
SELinuxRelabel bool `json:"selinuxRelabel"`
|
||||
SupportsMetrics bool `json:"supportsMetrics"`
|
||||
FSGroup bool `json:"fsGroup"`
|
||||
RequiresFSResize bool `json:"requiresFSResize"`
|
||||
}
|
||||
@@ -43,6 +43,7 @@ const (
|
||||
agentDaemonsetTolerationKeyEnv = "AGENT_TOLERATION_KEY"
|
||||
AgentMountSecurityModeEnv = "AGENT_MOUNT_SECURITY_MODE"
|
||||
RookEnableSelinuxRelabelingEnv = "ROOK_ENABLE_SELINUX_RELABELING"
|
||||
RookEnableFSGroupEnv = "ROOK_ENABLE_FSGROUP"
|
||||
|
||||
// MountSecurityModeAny "any" security mode for the agent for mount action
|
||||
MountSecurityModeAny = "Any"
|
||||
@@ -94,6 +95,13 @@ func (a *Agent) createAgentDaemonSet(namespace, agentImage, serviceAccount strin
|
||||
rookEnableSelinuxRelabeling = "true"
|
||||
}
|
||||
|
||||
rookEnableFSGroup := os.Getenv(RookEnableFSGroupEnv)
|
||||
_, err = strconv.ParseBool(rookEnableFSGroup)
|
||||
if err != nil {
|
||||
logger.Warningf("Invalid %s value \"%s\". Defaulting to \"true\".", RookEnableFSGroupEnv, rookEnableFSGroup)
|
||||
rookEnableFSGroup = "true"
|
||||
}
|
||||
|
||||
privileged := true
|
||||
ds := &extensions.DaemonSet{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -142,6 +150,7 @@ func (a *Agent) createAgentDaemonSet(namespace, agentImage, serviceAccount strin
|
||||
k8sutil.NodeEnvVar(),
|
||||
{Name: AgentMountSecurityModeEnv, Value: agentMountSecurityMode},
|
||||
{Name: RookEnableSelinuxRelabelingEnv, Value: rookEnableSelinuxRelabeling},
|
||||
{Name: RookEnableFSGroupEnv, Value: rookEnableFSGroup},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestStartAgentDaemonset(t *testing.T) {
|
||||
volumeMounts := agentDS.Spec.Template.Spec.Containers[0].VolumeMounts
|
||||
assert.Equal(t, 4, len(volumeMounts))
|
||||
envs := agentDS.Spec.Template.Spec.Containers[0].Env
|
||||
assert.Equal(t, 4, len(envs))
|
||||
assert.Equal(t, 5, len(envs))
|
||||
image := agentDS.Spec.Template.Spec.Containers[0].Image
|
||||
assert.Equal(t, "rook/rook:myversion", image)
|
||||
assert.Nil(t, agentDS.Spec.Template.Spec.Tolerations)
|
||||
|
||||
Reference in new issue
Block a user