Skip to content

feat(helm): Add parameter to customize container args - #11315

Open
mrachuta wants to merge 2 commits into
aquasecurity:mainfrom
mrachuta:feat/helm-chart-custom-container-args
Open

mrachuta wants to merge 2 commits into
aquasecurity:mainfrom
mrachuta:feat/helm-chart-custom-container-args

Conversation

@mrachuta

Copy link
Copy Markdown

Description

This is retry of previous PR: #10525

The organisation I work for uses customised Docker images and official Helm charts. The challenge with trivy was that we were unable to adjust the container arguments to use our customised image with the official Helm chart. This feature adds a new parameter, trivy.customContainerArgs, which allows the default value, server, to be overridden.

In addition to updating the documentation for the new parameter, the table in the README has been updated to include missing default values for other parameters, as well as the values.yaml file, to ensure consistency.

Simple tests:

  • before
$ helm template my-trivy .

# Source: trivy/templates/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: my-trivy
  labels:
    app.kubernetes.io/name: trivy
    helm.sh/chart: trivy-0.21.3
    app.kubernetes.io/instance: my-trivy
    app.kubernetes.io/version: "0.69.3"
    app.kubernetes.io/managed-by: Helm
spec:
  podManagementPolicy: "Parallel"
  serviceName: my-trivy
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: trivy
      app.kubernetes.io/instance: my-trivy
  volumeClaimTemplates:
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: data
      spec:
        resources:
          requests:
            storage: 5Gi
        accessModes:
          - ReadWriteOnce
        storageClassName: 
  template:
    metadata:
      annotations:
        checksum/config: e9c603f8c1a7b460736add81d62a8b20e83d6c01c2799b7d458068a959d9757a
      labels:
        app.kubernetes.io/name: trivy
        app.kubernetes.io/instance: my-trivy
    spec:
      serviceAccountName: my-trivy
      automountServiceAccountToken: false
      securityContext:
        fsGroup: 65534
        runAsNonRoot: true
        runAsUser: 65534
      containers:
        - name: main
          image: docker.io/aquasec/trivy:0.69.3
          imagePullPolicy: "IfNotPresent"
          securityContext:
            privileged: false
            readOnlyRootFilesystem: true
          args:
            - server
          envFrom:
            - configMapRef:
                name: my-trivy
            - secretRef:
                name: my-trivy
          ports:
            - name: trivy-http
              containerPort: 4954
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /healthz
              port: trivy-http
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 10
          readinessProbe:
            httpGet:
              scheme: HTTP
              path: /healthz
              port: trivy-http
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          volumeMounts:
            - mountPath: /tmp
              name: tmp-data
              readOnly: false
            - mountPath: /home/scanner/.cache
              name: data
              readOnly: false
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 200m
              memory: 512Mi
      volumes:
        - name: tmp-data
          emptyDir: {}
  • after
$ helm template my-trivy . --set "trivy.customContainerArgs={arg1,arg2}"

# Source: trivy/templates/statefulset.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: my-trivy
  labels:
    app.kubernetes.io/name: trivy
    helm.sh/chart: trivy-0.21.3
    app.kubernetes.io/instance: my-trivy
    app.kubernetes.io/version: "0.69.3"
    app.kubernetes.io/managed-by: Helm
spec:
  podManagementPolicy: "Parallel"
  serviceName: my-trivy
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: trivy
      app.kubernetes.io/instance: my-trivy
  volumeClaimTemplates:
    - apiVersion: v1
      kind: PersistentVolumeClaim
      metadata:
        name: data
      spec:
        resources:
          requests:
            storage: 5Gi
        accessModes:
          - ReadWriteOnce
        storageClassName: 
  template:
    metadata:
      annotations:
        checksum/config: e9c603f8c1a7b460736add81d62a8b20e83d6c01c2799b7d458068a959d9757a
      labels:
        app.kubernetes.io/name: trivy
        app.kubernetes.io/instance: my-trivy
    spec:
      serviceAccountName: my-trivy
      automountServiceAccountToken: false
      securityContext:
        fsGroup: 65534
        runAsNonRoot: true
        runAsUser: 65534
      containers:
        - name: main
          image: docker.io/aquasec/trivy:0.69.3
          imagePullPolicy: "IfNotPresent"
          securityContext:
            privileged: false
            readOnlyRootFilesystem: true
          args:
            - arg1
            - arg2
          envFrom:
            - configMapRef:
                name: my-trivy
            - secretRef:
                name: my-trivy
          ports:
            - name: trivy-http
              containerPort: 4954
          livenessProbe:
            httpGet:
              scheme: HTTP
              path: /healthz
              port: trivy-http
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 10
          readinessProbe:
            httpGet:
              scheme: HTTP
              path: /healthz
              port: trivy-http
            initialDelaySeconds: 5
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          volumeMounts:
            - mountPath: /tmp
              name: tmp-data
              readOnly: false
            - mountPath: /home/scanner/.cache
              name: data
              readOnly: false
          resources:
            limits:
              cpu: 1
              memory: 1Gi
            requests:
              cpu: 200m
              memory: 512Mi
      volumes:
        - name: tmp-data
          emptyDir: {}

Related issues

  • There is no issue created for such feature.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@mrachuta
mrachuta requested a review from afdesk as a code owner September 26, 2026 22:42
@mrachuta

Copy link
Copy Markdown
Author

Bump. Any updates there?

This branch has not been deployed

No deployments
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