trivy

by deployment-aqua

Helm chartv0.28.2App 0.76.2

Trivy helm chart

About this chart

Trivy Scanner

Trivy vulnerability scanner standalone installation.

TL;DR;

$ helm install trivy . --namespace trivy --create-namespace

Introduction

This chart bootstraps a Trivy deployment on a Kubernetes cluster using the Helm package manager.

Prerequisites

  • Kubernetes 1.12+
  • Helm 3+

Installing from the Aqua Chart Repository

helm repo add aquasecurity https://aquasecurity.github.io/helm-charts/
helm repo update
helm search repo trivy
helm install my-trivy aquasecurity/trivy

Installing the Chart

To install the chart with the release name my-release:

$ helm install my-release .

The command deploys Trivy on the Kubernetes cluster in the default configuration. The Parameters section lists the parameters that can be configured during installation.

Tip: List all releases using helm list.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Parameters

The following table lists the configurable parameters of the Trivy chart and their default values.

ParameterDescriptionDefault
image.registryImage registrydocker.io
image.repositoryImage nameaquasec/trivy
image.tagImage tag{TAG_NAME}
image.pullPolicyImage pull policyIfNotPresent
image.pullSecretThe name of an imagePullSecret used to pull trivy image from e.g. Docker Hub or a private registry
replicaCountNumber of Trivy Pods to run1
trivy.debugModeThe flag to enable or disable Trivy debug modefalse
trivy.gitHubTokenThe GitHub access token to download Trivy DB. More info: https://trivy.dev/docs/latest/references/troubleshooting/#github-rate-limiting
trivy.registryUsernameThe username used to log in at dockerhub. More info: https://trivy.dev/docs/latest/advanced/private-registries/docker-hub/
trivy.registryPasswordThe password used to log in at dockerhub. More info: https://trivy.dev/docs/latest/advanced/private-registries/docker-hub/
trivy.registryCredentialsExistingSecretName of Secret containing dockerhub credentials. Alternative to the 2 parameters above, has precedence if set.
trivy.serviceAccount.annotationsAdditional annotations to add to the Kubernetes service account resource
trivy.skipDBUpdateThe flag to enable or disable Trivy DB downloads from GitHubfalse
trivy.dbRepositoryOCI repository to retrieve the trivy vulnerability database fromghcr.io/aquasecurity/trivy-db
trivy.cache.redis.enabledEnable Redis as caching backendfalse
trivy.cache.redis.urlSpecify redis connection url, e.g. redis://redis.redis.svc:6379``
trivy.cache.redis.ttlSpecify redis TTL, e.g. 3600s or 24h``
trivy.cache.redis.tlsEnable Redis TLS with public certificates``
trivy.serverTokenThe token to authenticate Trivy client with Trivy server``
trivy.existingSecretexistingSecret if an existing secret has been created outside the chart. Overrides gitHubToken, registryUsername, registryPassword, serverToken``
trivy.podAnnotationsAnnotations for pods created by statefulset{}
trivy.extraEnvVarsextraEnvVars to be set on the container{}
trivy.sslCertDirCan be used to override the system default locations for SSL certificate files directory, example: /ssl/certs``
service.nameIf specified, the name used for the Trivy service
service.typeKubernetes service typeClusterIP
service.portKubernetes service port4954
service.sessionAffinityKubernetes service session affinityClientIP
httpProxyThe URL of the HTTP proxy server
httpsProxyThe URL of the HTTPS proxy server
noProxyThe URLs that the proxy settings do not apply to
nodeSelectorNode labels for pod assignment
affinityAffinity settings for pod assignment
tolerationsTolerations for pod assignment
podAnnotationsAnnotations for pods created by statefulset{}

The above parameters map to the env variables defined in trivy.

Specify each parameter using the --set key=value[,key=value] argument to helm install.

$ helm install my-release . \
       --namespace my-namespace \
       --set "service.port=9090" \
       --set "trivy.vulnType=os\,library"

Storage

This chart uses a PersistentVolumeClaim to reduce the number of database downloads between POD restarts or updates. The storageclass should have the reclaim policy Retain.

Caching

You can specify a Redis server as cache backend. This Redis server has to be already present. You can use the bitnami chart. More Information about the caching backends can be found here.

Deploy trivy with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has trivy on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charttrivy is pinned at v0.28.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply