useStrictSecurity: default pod securityContext sets fsGroup without fsGroupChangePolicy: OnRootMismatch

Aperta Adatta ai principianti
#2,854 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes
Ambito
backend

Direzione di ricerca

Inizia da getDefaultPodSecurityContext in internal/controller/operator/factory/build/security.go e leggi come vengono assemblati i default strict insieme a containerSecurityContext(). Confronta con la configurazione di default di VMAlertmanager citata in #2392 per vedere come fsGroupChangePolicy: OnRootMismatch sia già impostato al di fuori della modalità strict. Aggiungi lo stesso campo accanto a fsGroup: 65534 nei default strict. Il lavoro è completato quando un VMSingle o un VLSingle con useStrictSecurity: true riporta la policy in .spec.securityContext e un riavvio non scorre più l'intero volume.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Go
Stelle
603
Fork
242
Merge medio
1g 14h
PR unite (30g)
57

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di VictoriaMetrics/operator

Tutte le issue di VictoriaMetrics/operator

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.