Skip to content

useStrictSecurity: default pod securityContext sets fsGroup without fsGroupChangePolicy: OnRootMismatch #2854

Open

Description

@SLoeuillet

Describe the bug

With useStrictSecurity: true, getDefaultPodSecurityContext (internal/controller/operator/factory/build/security.go) sets fsGroup: 65534 but leaves fsGroupChangePolicy unset. Kubernetes then defaults it to Always: on every pod start, the kubelet recursively chowns and chmods the whole data volume. That affects every CR with persistent storage: VMSingle, VLSingle, VMAgent persistent queue, VMStorage, VLStorage, VMAlertmanager and so on.

On large volumes this slows every restart. Our VLSingle holds about 730 GiB in 180k files; VMSingle about 73 GiB. The first switch from a root-owned volume to 65534 needs the full walk, but after that, OnRootMismatch would skip it.

Setting it yourself means giving a full spec.securityContext. That replaces the strict defaults entirely (containerSecurityContext() takes the user value as-is), so you have to restate all of them just to add one field.

To Reproduce

  1. Create a VMSingle (or VLSingle) with useStrictSecurity: true and a PVC.
  2. kubectl get pod -o jsonpath='{.spec.securityContext}' shows fsGroup: 65534 with no fsGroupChangePolicy.
  3. Restart the pod: the kubelet walks the whole volume on each start.

Expected behavior

The strict defaults include fsGroupChangePolicy: OnRootMismatch, as the operator already defaults for VMAlertmanager outside strict mode (#2392).

Version

vm-operator v0.75.2 (the default is the same on master), GKE 1.37.2.

Additional context

Alternatively, merge a user securityContext field by field over the strict defaults instead of replacing them. Then securityContext: {fsGroupChangePolicy: OnRootMismatch} next to useStrictSecurity: true would be enough.

Activity

  1. f41gh7 commented on Nov 23, 2026

    @f41gh7
    Collaborator

    As far as I understand, by default operator sets fsGroupChangePolicy.

    There is only one condition, if it's not correct - if k8stools.IsFSGroupChangePolicySupported() returns false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions