VictoriaMetrics / VictoriaMetrics/operator

vlagent: replace the default tmpDataPath hostPath volume with emptyDir

Open
#2,544 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
589
Forks
229
Avg merge
1d 9h
Merged PRs (30d)
77

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the VLAgent reconciliation or rendering path that handles k8sCollector and tmpDataPath, then compare it with VMAgent’s default persistent queue configuration. Done means the default VLAgent volume is an emptyDir mounted at a non-host path, while the supplied non-root security-context example can write successfully; run the relevant operator tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, kubernetes
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.