Skip to content

feat: add podSecurityContext option#1917

Open
yzapf wants to merge 4 commits into
fluxcd:mainfrom
yzapf:feat/add-podsecuritycontext-option
Open

feat: add podSecurityContext option#1917
yzapf wants to merge 4 commits into
fluxcd:mainfrom
yzapf:feat/add-podsecuritycontext-option

Conversation

@yzapf
Copy link
Copy Markdown

@yzapf yzapf commented May 12, 2026

Description

Adds option to specify securityContext on pod level to be able to address Pod Security Standards natively in the helm chart.

Motivation

We want flagger to be able to run in restricted environments natively as well. Currently we are doing some workarounds with postRenderers in its HelmRelease, but being able to configure these settings directly in the values would be a nice quality-of-life improvement in order to reduce general complexity.

Changes

  • added section for securityContext on pod level in flagger deployment template as opt-in value (default: enabled)
  • refactored comments and default securityContext on container and pod level

Verification

Just ran

helm template flagger charts/flagger

to verify the desired outcome as shown below:

# Source: flagger/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flagger
  namespace: default
  labels:
    helm.sh/chart: flagger-1.43.0
    app.kubernetes.io/name: flagger
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/instance: flagger
    app.kubernetes.io/version: 1.43.0
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: flagger
      app.kubernetes.io/instance: flagger
  template:
    metadata:
      labels:
        app.kubernetes.io/name: flagger
        app.kubernetes.io/instance: flagger
        app.kubernetes.io/version: 1.43.0
      annotations:
        appmesh.k8s.aws/sidecarInjectorWebhook: disabled
        linkerd.io/inject: enabled
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"
    spec:
      serviceAccountName: flagger
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - podAffinityTerm:
              labelSelector:
                matchLabels:
                  app.kubernetes.io/instance: 'flagger'
                  app.kubernetes.io/name: 'flagger'
              topologyKey: kubernetes.io/hostname
            weight: 100                  
      containers:
        - name: flagger
          securityContext:
            allowPrivilegeEscalation: false
            capabilities:
              drop:
              - ALL
            privileged: false
            readOnlyRootFilesystem: true
          image: "ghcr.io/fluxcd/flagger:1.43.0"
          imagePullPolicy: IfNotPresent
          ports:
          - name: http
            containerPort: 8080
          command:
          - ./flagger
          - -log-level=info
          - -metrics-server=http://prometheus:9090
          - -enable-config-tracking=true
          - -slack-user=flagger
          livenessProbe:
            exec:
              command:
              - wget
              - --quiet
              - --tries=1
              - --timeout=4
              - --spider
              - http://localhost:8080/healthz
            timeoutSeconds: 5
          readinessProbe:
            exec:
              command:
              - wget
              - --quiet
              - --tries=1
              - --timeout=4
              - --spider
              - http://localhost:8080/healthz
            timeoutSeconds: 5
          resources:
            limits:
              cpu: 1000m
              memory: 512Mi
            requests:
              cpu: 10m
              memory: 32Mi
      securityContext:
        fsGroup: 10001
        runAsGroup: 10001
        runAsNonRoot: true
        runAsUser: 10001
        supplementalGroups:
        - 10001

Flagger is running with these settings in our environment with no problems noticable so far.

@yzapf yzapf changed the title Feat/add podsecuritycontext option feat: add podsecuritycontext option May 12, 2026
yzapf added 4 commits May 12, 2026 16:41
Signed-off-by: Yannick Zapf <yannick.zapf99@gmail.com>
Signed-off-by: Yannick Zapf <yannick.zapf99@gmail.com>
Signed-off-by: Yannick Zapf <yannick.zapf99@gmail.com>
Signed-off-by: Yannick Zapf <yannick.zapf99@gmail.com>
@yzapf yzapf force-pushed the feat/add-podsecuritycontext-option branch from a615e6d to 97e9b57 Compare May 12, 2026 14:41
@yzapf yzapf changed the title feat: add podsecuritycontext option feat: add podSecurityContext option May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant