Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: run discover daemonset as root uid #9512

Merged
merged 1 commit into from Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions pkg/operator/discover/discover.go
Expand Up @@ -30,6 +30,7 @@ import (
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/clusterd"
discoverDaemon "github.com/rook/rook/pkg/daemon/discover"
"github.com/rook/rook/pkg/operator/ceph/controller"
k8sutil "github.com/rook/rook/pkg/operator/k8sutil"
"github.com/rook/rook/pkg/util/sys"

Expand Down Expand Up @@ -79,7 +80,6 @@ func (d *Discover) Start(ctx context.Context, namespace, discoverImage, security
}

func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, discoverImage, securityAccount string, useCephVolume bool) error {
privileged := true
discovery_parameters := []string{"discover",
"--discover-interval", getEnvVar(discoverIntervalEnv, defaultDiscoverInterval)}
if useCephVolume {
Expand Down Expand Up @@ -108,12 +108,10 @@ func (d *Discover) createDiscoverDaemonSet(ctx context.Context, namespace, disco
ServiceAccountName: securityAccount,
Containers: []v1.Container{
{
Name: discoverDaemonsetName,
Image: discoverImage,
Args: discovery_parameters,
SecurityContext: &v1.SecurityContext{
Privileged: &privileged,
},
Name: discoverDaemonsetName,
Image: discoverImage,
Args: discovery_parameters,
SecurityContext: controller.PrivilegedContext(true),
VolumeMounts: []v1.VolumeMount{
{
Name: "dev",
Expand Down
1 change: 1 addition & 0 deletions pkg/operator/discover/discover_test.go
Expand Up @@ -79,6 +79,7 @@ func TestStartDiscoveryDaemonset(t *testing.T) {
assert.Equal(t, "mysa", agentDS.Spec.Template.Spec.ServiceAccountName)
assert.Equal(t, "my-priority-class", agentDS.Spec.Template.Spec.PriorityClassName)
assert.True(t, *agentDS.Spec.Template.Spec.Containers[0].SecurityContext.Privileged)
assert.Equal(t, int64(0), *agentDS.Spec.Template.Spec.Containers[0].SecurityContext.RunAsUser)
volumes := agentDS.Spec.Template.Spec.Volumes
assert.Equal(t, 3, len(volumes))
volumeMounts := agentDS.Spec.Template.Spec.Containers[0].VolumeMounts
Expand Down