简体   繁体   English

EKS 上的 Trivy 无法扫描任何图像

[英]Trivy on EKS unable to scan any images

I am trying to scan all images deployed on my EKS cluster I am setting up for high security (will be deployed to classified IL5 environment).我正在尝试扫描部署在我为高安全性设置的 EKS 集群上的所有图像(将部署到机密的 IL5 环境)。 Kube.netes v1.23, all worker nodes run on Bottlerocket OS. Kube.netes v1.23,所有工作节点都运行在 Bottlerocket OS 上。

I expect images to be scanned and available in the VulnerabilityReports CRD.我希望图像能够被扫描并在 VulnerabilityReports CRD 中可用。

I was able to successfully install Falco to the cluster (uses containerd).我能够成功地将 Falco 安装到集群(使用 containerd)。 However, when deploying the official Helm chart (0.6.0-rc3) the scan-vulnerability containers start and then immediately error out.但是,当部署官方 Helm chart (0.6.0-rc3) 时,扫描漏洞容器会启动,然后立即出错。 I set this environment variable on the trivy-operator deployment:我在 trivy-operator 部署中设置了这个环境变量:

- name: CONTAINER_RUNTIME_ENDPOINT
  value: /run/containerd/containerd.sock

Output of run with -debug :使用-debug运行的 Output:

{
  "level": "error",
  "ts": 1668286646.865245,
  "logger": "reconciler.vulnerabilityreport",
  "msg": "Scan job container",
  "job": "trivy-system/scan-vulnerabilityreport-74f54b6cd",
  "container": "discovery",
  "status.reason": "Error",
  "status.message": "2022-11-12T20:57:13.674Z\t\u001b[31mFATAL\u001b[0m\timage scan error: scan error: unable to initialize a scanner: unable to initialize a docker scanner: 4 errors occurred:\n\t* unable to inspect the image (023620263533.dkr.ecr.us-gov-east-1.amazonaws.com/docker.io/istio/pilot:1.15.2): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?\n\t* unable to initialize Podman client: no podman socket found: stat podman/podman.sock: no such file or directory\n\t* containerd socket not found: /run/containerd/containerd.sock\n\t* GET https://023620263533.dkr.ecr.us-gov-east-1.amazonaws.com/v2/docker.io/istio/pilot/manifests/1.15.2: unexpected status code 401 Unauthorized: Not Authorized\n\n\n\n",
  "stacktrace": "github.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).processFailedScanJob\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:551\ngithub.com/aquasecurity/trivy-operator/pkg/vulnerabilityreport.(*WorkloadController).reconcileJobs.func1\n\t/home/runner/work/trivy-operator/trivy-operator/pkg/vulnerabilityreport/controller.go:376\nsigs.k8s.io/controller-runtime/pkg/reconcile.Func.Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.13.1/pkg/reconcile/reconcile.go:102\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.13.1/pkg/internal/controller/controller.go:121\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.13.1/pkg/internal/controller/controller.go:320\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.13.1/pkg/internal/controller/controller.go:273\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2\n\t/home/runner/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.13.1/pkg/internal/controller/controller.go:234"
}

I confirmed that bottlerocket uses containerd, as /run/containerd/containerd.sock is specified on my Falco deployment.我确认 bottlerocket 使用 containerd,因为/run/containerd/containerd.sock在我的 Falco 部署中指定。 Even when I mount this as volume onto the pod and set the CONTAINER_RUNTIME_ENDPOINT to this path I get the same error.即使当我将其作为卷安装到 pod 并将CONTAINER_RUNTIME_ENDPOINT设置为此路径时,我也会遇到同样的错误。

Edit I added the following security context:编辑我添加了以下安全上下文:

  seLinuxOptions:
    user: system_u
    role: system_r
    type: control_t
    level: s0-s0:c0.c1023

Initially I mounted the dockershim.sock from the host to the pod, then realized that was not necessary, the error messages were a little misleading, it was really an authentication with ECR issue.最初我将 dockershim.sock 从主机挂载到 pod,然后意识到没有必要,错误消息有点误导,这实际上是一个带有 ECR 问题的身份验证。 Furthermore, the seLinux flags needed to be specified at the pod level, and not the container level.此外,需要在 pod 级别而不是容器级别指定seLinux标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM