Skip to content

vlagent: replace the default tmpDataPath hostPath volume with emptyDir #2544

Open

Description

@Haleygo

Describe the bug

In vlagent, when k8sCollector.enabled: true is set, the operator backs -tmpDataPath with a hostPath volume at the fixed node path /var/lib/vlagent-data by default. This can cause the following issues:

  1. Kubelet’s fsGroup ownership management does not apply to hostPath volumes. The directory is created on the node with 0755 root:root permissions and ownership, which can cause permission issues when runAsNonRoot: true is configured or on platforms such as OpenShift, where SCC admission can assign the container UID and fsGroup from the namespace’s permitted ranges, leaving the process unable to write to the root-owned host directory.
  2. Since the path is fixed rather than unique to each CR, two VLAgent CRs with k8sCollector enabled and scheduled on the same node may write to the same directory.
  3. Deleting the VLAgent still leaves its data on the node.

For comparison, VMAgent does not have these issues. By default, its persistent queue uses an emptyDir volume mounted at /tmp/vmagent-remotewrite-data.

To reproduce

Create a VLAgent with a non-root security context:

apiVersion: operator.victoriametrics.com/v1
kind: VLAgent
metadata:
  name: example
spec:
  useStrictSecurity: true
  securityContext:
    runAsUser: 65534
    runAsNonRoot: true
    fsGroup: 65534
    supplementalGroups: [0]
  k8sCollector:
    enabled: true
  # ...

Describe the solution you’d like

Back tmpDataPath with an emptyDir volume and mount it at a non-host path, the same approach as VMAgent.

Activity

  1. AndrewChubatiuk commented on Aug 26, 2026

    @AndrewChubatiuk
    Contributor

    Since the path is fixed rather than unique to each CR, two VLAgent CRs with k8sCollector enabled and scheduled on the same node may write to the same directory.

    what is a use case for two VLAgent with k8sCollector enabled on the same node?

    Kubelet’s fsGroup ownership management does not apply to hostPath volumes. The directory is created on the node with 0755 root:root permissions and ownership, which can cause permission issues when runAsNonRoot: true is configured or on platforms such as OpenShift, where SCC admission can assign the container UID and fsGroup from the namespace’s permitted ranges, leaving the process unable to write to the root-owned host directory.

    would rather add init container that configures directories permissions instead of using emptyDir, which may lead to data loss

  2. Haleygo commented on Aug 26, 2026

    @Haleygo
    MemberAuthor

    @AndrewChubatiuk

    Would rather add an init container that configures directory permissions instead of using emptyDir, which may lead to data loss.

    I think an init container would be only a workaround and an unnecessary detour in this case. Users could instead set tmpDataPath to an actual /tmp path or mount a volume. As I understand it, this approach would also not work easily on OpenShift because the init container would still lack the permissions.

    I think data loss during restarts is expected for the default temporary data path(the name already indicates that the data is temporary:)).
    VMAgent also loses this data by default unless users explicitly configure persistent storage, so this behavior seems acceptable.

    What is a use case for two VLAgent instances with k8sCollector enabled on the same node?

    I just wanted to list the potential issues I see with the current default temporary data path.

    The main question is, is there a specific reason why VLAgent uses the fixed node path /var/lib/vlagent-data by default, unlike VMAgent?

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