Back to Hub

cargo.ayedo.cloud/ayedo/k8s/kubescape 0.3.3 k8sapp Apache 2.0

Kubernetes security posture and vulnerability scanning: compliance frameworks (NSA, MITRE, CIS), misconfigurations, image CVEs and SBOMs. Results stay in-cluster for the Polycrate Operator

polycrate block pull cargo.ayedo.cloud/ayedo/k8s/kubescape:0.3.3

Kubescape

Installs the Kubescape operator via Helm. Kubescape scans the cluster on a schedule and keeps the results in-cluster:

Result Source Content
Posture / compliance kubescape (scheduled) Failed controls per framework (NSA, MITRE ATT&CK, CIS, SOC 2, ...) per workload and namespace
Vulnerabilities kubevuln (Grype) CVEs per image, summarized per workload and namespace
SBOMs kubevuln (Syft) SPDX SBOM per image
Metrics prometheus-exporter Counters per severity on cluster, namespace and workload level

Results are served by the Kubescape storage component as the aggregated API spdx.softwarecomposition.kubescape.io/v1beta1 (backed by a PVC), e.g.:

kubectl get vulnerabilitymanifestsummaries -A
kubectl get workloadconfigurationscansummaries -A
kubectl get sbomsyfts -A

This is the interface for the Polycrate Operator to sync findings into the Polycrate API.

  • Chart: kubescape/kubescape-operator 1.41.0 (Kubescape v4)
  • Repository: https://kubescape.github.io/helm-charts/
  • Namespace: kubescape
  • Requires Kubernetes >= 1.28 (checked on install)

Defaults and rationale

The chart defaults enable the full runtime stack. The block ships a status-quo profile instead:

  • No runtime components: relevancy, runtime observability, network policy generation, admission controller, seccomp and HTTP detection are off. None of them is enabled, so the node-agent DaemonSet (eBPF, one pod per node) is not deployed. Running components: operator, kubescape, kubevuln, storage, prometheus-exporter plus two scheduler CronJobs.
  • No phone-home (telemetry: false): sets kubescapeOffline and skipUpdateCheck, so neither daily reports nor update checks leave the cluster. No cloud backend (server) is configured; results never leave the cluster.
  • No self-modification: autoUpgrading, remediation, manageWorkloads and syncSBOM are always disabled. Upgrades happen through this block only.
  • Schedules: posture scan every 6 hours, vulnerability scan every 12 hours (chart: daily). kubevuln caches SBOMs per image digest, so repeated scans mainly re-match against the current Grype DB.
  • Certificates via initContainer: the storage mTLS CA is created once and reused. With the chart default template, every polycrate run kubescape install would rotate the certificates.
  • CRDs applied server-side on every install: Helm never upgrades crds/, so chart bumps would otherwise leave stale CRDs.
  • Only the prometheus-exporter is scraped: the kubescape pod also exposes /v1/metrics, but every request triggers a full scan.

Runtime profile (opt-in)

capabilities.relevancy: true together with runtime_observability: true deploys the node-agent DaemonSet. It learns which packages are actually loaded and marks CVEs as relevant, which typically removes most of the noise from image CVE counts (kubescape_vulnerabilities_relevant_*). Cost: one privileged-capable eBPF pod per node (100m / 180Mi requested, up to 1400Mi). node_agent.tolerations defaults to operator: Exists so tainted control-plane nodes are covered as well. See examples.poly → runtime.

With relevancy enabled, kubevuln only scans containers whose start the node-agent observed. Pods that were already running when the node-agent was installed get a partial container profile and are skipped (container profile is partial (workload restart required) in the kubevuln log) until they restart once. Enabling relevancy on an existing cluster therefore requires a rolling restart of the workloads, or coverage grows only with natural restarts. Without relevancy, kubevuln scans the full image of every workload immediately. When relevancy is disabled, install deletes container profiles left behind by a previous node-agent, because the operator would otherwise keep preferring them over image scans. The dashboard panel CVE scan coverage shows the share of scanned workloads.

Configuration

Key Default Purpose
cluster_name workspace name Cluster name in reports
scanning.exclude_namespaces kube-system, kube-public, kube-node-lease Namespaces skipped by all scans; the block namespace is always added
scanning.include_namespaces [] Restrict scans to these namespaces
scanning.frameworks [] (all) Posture frameworks of the scheduled scan, e.g. [nsa, mitre, cis-v1.10.0]
scanning.exclude_controls [] Control IDs never evaluated
schedules.* 0 */6 * * *, 30 */12 * * * Cron schedules of posture and vulnerability scans; the first posture scan runs on the schedule, not on install (use scan-configuration)
scanning.spill_volume enabled, 4Gi emptyDir on /tmp for the scanner's spill store; without it large scans stay in memory
capabilities.* status-quo profile true / false per Kubescape capability
vulnerability.grype_db_persistence true Keep the Grype DB on the PVC kubescape-kubevuln (persistence.kubevuln_size, 5Gi) instead of re-downloading it on every kubevuln start
resources.kubescape 250m / 400Mi, limit 600m / 2Gi GOMEMLIMIT is 80 % of the memory limit; raise it for large clusters
vulnerability.proxy_registry_map {} Rewrite image pulls of kubevuln to a mirror, e.g. Harbor proxy cache
private_registries [] Registry credentials for kubevuln (put them in secrets.poly)
persistence.storage_class cluster default StorageClass of the storage and Grype DB PVCs
metrics.workload_metrics true Per-workload series on the exporter
metrics.vmrule.* component and exporter alerts on Optional alerts on critical CVEs and controls
values_override {} Merged recursively into the chart values

kubevuln pulls every image itself to build the SBOM. Images of private registries are accessed with the workloads' imagePullSecrets (cluster-wide secret read access is enabled by the chart). Use private_registries only for registries without pull secrets.

Monitoring

When the VictoriaMetrics operator CRDs exist, the block installs:

  • VMServiceScrape kubescape for the prometheus-exporter (job="kubescape-prometheus-exporter")
  • VMRule kubescape:
  • KubescapeComponentNotReady: a Kubescape Deployment has no available replica for 15 minutes (needs kube-state-metrics)
  • KubescapeExporterDown: no healthy exporter target for 15 minutes
  • KubescapeCriticalVulnerabilities (off by default): workloads above threshold critical CVEs; source: relevant requires the runtime profile
  • KubescapeCriticalControlsFailed (off by default): critical posture controls failing cluster-wide
  • Grafana dashboard ConfigMap (label grafana_dashboard: "1"), uid kubescape. Variables cluster and namespace. The coverage row compares workloads with a vulnerability scan result to running Deployments, StatefulSets and DaemonSets (needs kube-state-metrics); the relevant CVE panels show n/a without the runtime profile

The storage component registers an aggregated APIService. If it is unavailable, API discovery returns errors for that group and namespace deletion can hang. KubescapeComponentNotReady covers the storage Deployment; the API server metric aggregator_unavailable_apiservice covers the APIService itself.

Actions

Action Effect
install Validates the config, applies CRDs, installs or upgrades the chart and the monitoring resources
scan-configuration Starts a posture scan now (Job from the kubescape-scheduler CronJob, removed after 1 h)
scan-vulnerabilities Starts an image vulnerability scan of all workloads now (Job from the kubevuln-scheduler CronJob)
uninstall Removes the monitoring resources and the Helm release; keeps CRDs and the namespace
purge uninstall plus deletion of the Kubescape CRDs and the namespace (all scan results, SBOMs and exceptions)

Exceptions

Accepted findings are managed with the SecurityException / ClusterSecurityException CRDs (kubescape.io/v1beta1). Kubescape only honors them with capabilities.risk_acceptance: true (block default; the chart default is off). They are user data and not managed by this block; purge deletes them.