trivy-operator
trivy-operator copied to clipboard
Missing volumeMounts for /tmp in OLM package
What steps did you take and what happened:
In recent versions (for sure 0.22.0 and 0.21.*) there's a problem related to the OLM installation of the operator, that prevents everything from working properly:
{"level":"error","ts":"2024-08-29T13:53:06Z","logger":"policyLoader.Get misconfig bundle policies","msg":"failed to load policies","error":"failed to download policies: failed to download built-in policies: download error: oci download error: failed to create a temp dir: mkdir /tmp/trivy730842185: read-only file system","stacktrace":"github.com/aquasecurity/trivy-operator/pkg/policy.(*policyLoader).GetPolicies\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/policy/loader.go:61\ngithub.com/aquasecurity/trivy-operator/pkg/policy.(*Policies).loadPolicies\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/policy/policy.go:144\ngithub.com/aquasecurity/trivy-operator/pkg/policy.(*Policies).Hash\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/policy/policy.go:114\ngithub.com/aquasecurity/trivy-operator/pkg/configauditreport/controller.(*ResourceController).SetupWithManager.(*ResourceController).reconcileResource.func1\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/configauditreport/controller/resource.go:208\nsigs.k8s.io/controller-runtime/pkg/reconcile.Func.Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/reconcile/reconcile.go:113\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:114\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:311\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:261\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:222"}
This is caused by the fact that the trivy-operator
Pod in the deployment does not have the proper /tmp
directory configuration:
volumeMounts:
- mountPath: /tmp
name: cache-policies
readOnly: false
volumes:
- emptyDir: {}
name: cache-policies
This is part of the static installation file, but does not come when you install everything via OLM.
Note that this does not happen when using a previous version like 0.17.1
.
What did you expect to happen:
Same behavior as the static file.
Environment:
- Trivy-Operator version (use
trivy-operator version
): v0.22.0 (but this applies for sure on v0.21.*) and not on v0.17.1. - Kubernetes version (use
kubectl version
): v1.30.4 - OS (macOS 10.15, Windows 10, Ubuntu 19.10 etc): AlmaLinux release 9.4 (Seafoam Ocelot)