Skip to Content
IntegrationsKubernetes

Continuously Scan Kubernetes with the Mondoo Kubernetes Operator

Deploy the Mondoo Kubernetes Operator to continuously scan clusters, nodes, and workloads for security misconfigurations.

The Mondoo Kubernetes Operator runs inside your cluster and continuously scans it. Because it lives in the cluster, it scans on its own schedule instead of waiting for an external scan window, and with the resource watcher turned on, it also scans Kubernetes resources as they change.

The operator can:

  • Continuously scan nodes for misconfigurations and vulnerabilities
  • Continuously scan workloads in the cluster
  • Scan new nodes as they come online

Create the integration in the Mondoo App first

Start in the Mondoo App, not with the Helm chart. Installing the chart on its own only deploys the operator: it doesn't connect to Mondoo and no integration appears in your space. The operator reports to Mondoo after you create the token Secret and apply the audit configuration that the app generates when you add a Kubernetes integration. The token in that command expires 30 minutes after you create the integration, so run the commands right away.

Before you begin

  • Editor or Owner access to the Mondoo space that receives the scan results, or another role with permission to add integrations. To see every role, read Roles and permissions.
  • kubectl with cluster admin access to the cluster. The installation creates custom resource definitions, ClusterRoles, and ClusterRoleBindings, so namespace-scoped permissions aren't enough.
  • Helm 3 if you install with Helm (the recommended method).
  • Kubernetes 1.26 or later.
  • Outbound HTTPS (port 443) from the cluster to:
    • ghcr.io, to pull the operator and cnspec images, unless you pull them from a private registry.
    • Docker Hub, for a Helm install. The chart runs a job that installs the custom resource definitions with the bitnami/kubectl image.
    • The Mondoo API and ingest hosts for your region, such as us.api.mondoo.com and ingest.us.mondoo.com. To learn more, read Allow Access to Mondoo Service Endpoints.
    • The registries your workloads pull from, if you turn on container image scanning.
    • The registry of the helper image that some authentication methods for external clusters and container registries run, if you use them: gcr.io for GKE workload identity, Docker Hub for EKS (IRSA), mcr.microsoft.com for AKS workload identity, and ghcr.io for SPIFFE. The operator's mirror settings don't apply to these images.
  • Outbound HTTPS from the workstation where you run the install to mondoohq.github.io (the Helm chart, or ghcr.io if you install the chart from its OCI registry) and install.mondoo.com (the kubectl manifest and the audit configuration).

How the integration model works

A Mondoo Kubernetes integration consists of two parts:

  • A service account credential (stored as a Kubernetes Secret) that authenticates to Mondoo Platform
  • A MondooAuditConfig custom resource that tells the operator what to scan

Because these are separate, a single operator installation can serve multiple integrations. Each integration gets its own Secret and MondooAuditConfig, but they all share the same operator. This is useful when you want different scan configurations or want to report results to different spaces from the same cluster.

Add a Mondoo Kubernetes integration

You need the Editor or Owner role, or another role with this permission. To see every role, read Roles and permissions.

In the Mondoo App, navigate to the space where you want to add the integration. In the side navigation bar, select Integrations. In the top right, select INSTALL. On the Install Integration page, find Kubernetes by browsing or searching by name, then select it.

Kubernetes integration form with the integration name, scanning options, advanced options, and external clusters steps

Configure scanning options

  1. Under Choose an integration name, type a name for the integration to identify it in lists and distinguish it from other integrations.

  2. Under Select scanning options, to continuously assess the security posture of nodes in your Kubernetes cluster, enable Scan nodes.

  3. To continuously assess the security posture of workloads and resources in your cluster, leave Scan workloads enabled (the default).

    Scanning options in the Kubernetes integration form, with container image scanning and namespace filtering turned on

  4. To scan container images running in the cluster, enable Scan container images. Image scanning can exhaust your registry's pull quota. For private registries, either list the Secrets that hold registry credentials in Private registries pull secrets (one per line), or turn on Registry workload identity to authenticate to GCR, ECR, or ACR with workload identity instead. To learn more, read Private container image scanning with Workload Identity.

  5. To control which namespaces Mondoo scans, enable Filter namespaces (available when Scan workloads is on) and list the namespaces to which you want to allow or deny access.

    You control which namespaces to scan using either the Allow list or the Deny list boxes. To scan only the namespaces you specify, type them in the Allow list box. To scan all namespaces except the ones you specify, type the namespaces to skip in the Deny list box. If you list multiple namespaces, separate them with line breaks.

  6. Leave Scan local cluster enabled to scan the cluster where the operator runs. Turn it off if you only want to scan external clusters.

  7. If you plan to run multiple integrations on the same cluster, enable Use unique audit config name.

  8. (Optional) Expand Advanced options to override defaults:

    OptionDescription
    Namespace overrideDeploy the audit config to a namespace other than the default, mondoo-operator.
    Credentials secret nameName of the Secret with Mondoo client credentials. The default is mondoo-client.
    Token secret nameName of the Secret with the Mondoo token. The default is mondoo-token.
    Scan scheduleA cron schedule for scanning jobs, such as 0 */2 * * *. Empty uses the operator default. Mondoo Operator 14.0.1 and later run scans at most once an hour. To learn more, read Scan schedules.
  9. (Optional) Under External clusters (optional), select ADD EXTERNAL CLUSTER to scan remote clusters from this operator. To learn more, read Scan External Kubernetes Clusters.

  10. Select CREATE INTEGRATION.

Install the Mondoo Operator

After you create the integration, the Mondoo App shows installation commands. Under Choose an installation method, select either Helm (Recommended) or Kubectl. Then, under Install the Mondoo Operator, copy and run the command.

Install with Helm

helm repo add mondoo https://mondoohq.github.io/mondoo-operator
helm repo update
helm upgrade --install mondoo-operator mondoo/mondoo-operator \
  --namespace mondoo-operator --create-namespace

The chart is also published as an OCI artifact at oci://ghcr.io/mondoohq/mondoo-operator/charts/mondoo-operator, which helps if you mirror charts into a private OCI registry. To install from it, run:

helm upgrade --install mondoo-operator oci://ghcr.io/mondoohq/mondoo-operator/charts/mondoo-operator \
  --namespace mondoo-operator --create-namespace

Customize the Helm installation

The chart's defaults work for most clusters. To change them, add --set key=value flags or --values values.yaml to the helm upgrade --install command. These are the values new installations most often need. For the full list, read the chart's values.yaml.

ValueDefaultUse it to
controllerManager.manager.image.repositoryghcr.io/mondoohq/mondoo-operatorPull the operator image from your own registry.
operator.imageRegistryEmptyPull the Mondoo images the operator starts, such as the cnspec scanner, from a mirror. The value replaces the registry: registry.example.com turns ghcr.io/mondoohq/mondoo-operator/cnspec into registry.example.com/mondoohq/mondoo-operator/cnspec.
operator.registryMirrors{}Map each source registry to its own mirror, such as ghcr.io: registry.example.com/ghcr. Takes precedence over operator.imageRegistry.
operator.imagePullSecrets[]Name Secrets in the mondoo-operator namespace that hold credentials for your registry. The operator pod and the scan workloads it creates use them to pull Mondoo images.
operator.skipContainerResolutionfalseStop the operator from looking up the latest image digests on ghcr.io. Set it to true when the cluster can't reach ghcr.io.
crdUpgrade.image.repositorybitnami/kubectlPull the image for the job that installs the custom resource definitions from your own registry. This job doesn't use operator.imagePullSecrets.
operator.httpProxy, operator.httpsProxy, operator.noProxyEmptySend the operator's outbound connections through a proxy. The scan pods use the same proxy settings unless operator.skipProxyForCnspec is true.
operator.skipProxyForCnspecfalseKeep the proxy settings away from the scan pods, for example when they reach Mondoo without a proxy. The operator itself still uses the proxy.
operator.containerProxyEmptySend connections to container registries through a proxy: the operator's image digest lookups and the images that container image scans download.
controllerManager.manager.resourcesRequests 100m CPU and 70Mi memory, limits 200m CPU and 140Mi memoryChange the CPU and memory of the operator pod.
controllerManager.serviceAccount.annotations{}Add annotations to the operator's service account.
k8SResourcesScanning.serviceAccount.annotations{}Add annotations to the service account that Kubernetes resource scans run as.

For example, to install from a private registry, mirror ghcr.io/mondoohq/mondoo-operator, ghcr.io/mondoohq/mondoo-operator/cnspec, and bitnami/kubectl with their tags to your registry. The cnspec scanner image's tag matches the cnspec major version the operator runs: 14-rootless, or 14-ubi-rootless on OpenShift. When you upgrade to an operator release that runs a new cnspec major version, mirror the new tag too. Create the pull Secret, then install with a values file:

kubectl create namespace mondoo-operator
kubectl create secret docker-registry registry-credentials \
  --namespace mondoo-operator \
  --docker-server=registry.example.com \
  --docker-username=USERNAME \
  --docker-password=PASSWORD
values.yaml
controllerManager:
  manager:
    image:
      repository: registry.example.com/mondoohq/mondoo-operator
operator:
  imageRegistry: registry.example.com
  imagePullSecrets:
    - name: registry-credentials
  skipContainerResolution: true
crdUpgrade:
  image:
    repository: registry.example.com/bitnami/kubectl
helm upgrade --install mondoo-operator mondoo/mondoo-operator \
  --namespace mondoo-operator --create-namespace \
  --values values.yaml

The chart has no values for annotations, labels, a node selector, or tolerations on pods. To set them on the scan jobs, edit the integration after you create it and use Job overrides under Advanced options. To learn more, read Edit a Kubernetes integration. The operator.imagePullSecrets value only covers Mondoo's own images. To scan your workloads' images in private registries, list their pull Secrets in the integration's Private registries pull secrets box.

operator.imageRegistry and operator.registryMirrors don't rewrite the helper images that scans using workload identity or SPIFFE run before they start: gcr.io/google.com/cloudsdktool/google-cloud-cli (GKE), amazon/aws-cli on Docker Hub (EKS), mcr.microsoft.com/azure-cli (AKS), and ghcr.io/spiffe/spiffe-helper (SPIFFE). If you use one of these methods for external clusters or container registries, the cluster must be able to pull its helper image from that registry.

Install with kubectl

kubectl apply -f https://install.mondoo.com/k8s/operator

If you already have the operator installed in this cluster, skip the installation step and proceed to applying the token and audit configuration.

Set operator-wide options with a MondooOperatorConfig

Settings that apply to the whole operator, such as a proxy or an image mirror, live in a cluster-scoped MondooOperatorConfig resource. The operator only reads the one named mondoo-operator-config. Its spec takes the same settings as the operator Helm values, with the same names: httpProxy, httpsProxy, noProxy, containerProxy, skipProxyForCnspec, imageRegistry, registryMirrors, imagePullSecrets, and skipContainerResolution.

The Helm chart creates the MondooOperatorConfig from its operator values. To manage it yourself instead, set operator.createConfig to false. The kubectl manifest doesn't create one, so after a kubectl installation, apply your own to use a proxy or a mirror:

mondoo-operator-config.yaml
apiVersion: k8s.mondoo.com/v1alpha2
kind: MondooOperatorConfig
metadata:
  name: mondoo-operator-config
spec:
  httpsProxy: http://proxy.example.com:3128
  noProxy: 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,.cluster.local,.svc,localhost,127.0.0.1
  imageRegistry: registry.example.com
  imagePullSecrets:
    - name: registry-credentials
  skipContainerResolution: true
kubectl apply -f mondoo-operator-config.yaml

Scan pods receive the proxy settings as environment variables. List the cluster's internal addresses and domains in noProxy, as in the example, so traffic inside the cluster, such as scan pods' requests to the Kubernetes API server, doesn't go through the proxy.

The kubectl manifest pulls the operator image from ghcr.io/mondoohq/mondoo-operator. The MondooOperatorConfig only changes the images the operator starts, not the operator's own image.

Apply the token and audit configuration

Under Create the token secret and apply the audit configuration, the Mondoo App generates two commands for you: one to create a Kubernetes Secret containing the integration token, and one to apply the MondooAuditConfig. Copy and run both commands against your cluster.

The Create the token secret and apply the audit configuration step for a new Kubernetes integration, with the command that creates the mondoo-token Secret and the command that applies the audit configuration

If you configured workload identity for external clusters or container registries, additional steps show the IAM bindings and target cluster RBAC commands to run. When you're done, under Finish, select DONE.

Mondoo scans workloads according to the activated policies. Learn more.

Verify the integration

  1. Check the pods in the operator namespace:

    kubectl get pods -n mondoo-operator

    A healthy installation has a mondoo-operator-controller-manager pod in the Running state with all containers ready. Scan pods appear next to it when the scan CronJobs run, and they end in the Completed state. With the default schedule, the first scans start about a minute after you apply the audit configuration. After that, Kubernetes resource and node scans run every hour and container image scans run once a day. To also scan Kubernetes resources as they change, turn on the resource watcher when you edit the integration.

  2. Check that the operator traded the token for its Mondoo credentials:

    kubectl get mondooauditconfigs,secrets -n mondoo-operator

    The output lists the audit configuration (mondoo-client by default) and a credentials Secret with the same name. If you turned on Use unique audit config name, both are named mondoo-client- followed by the integration ID.

  3. In the Mondoo App, open the integration from Integrations > Kubernetes. A new integration shows pending in the list (Not ready on the integration page) until the operator first checks in. It then changes to Active.

  4. After the first scans finish, the cluster, its namespaces, workloads, nodes, and container images appear under Inventory.

To learn what each status means, read Integration status and troubleshooting.

View a Kubernetes integration

Once you've added a Kubernetes Operator integration, you can view it by selecting Integrations in the side navigation bar and then selecting the Kubernetes card.

List of Kubernetes integrations in a space, with name, status, created, and last scan columns

To view additional status details, select its row in the list. The integration page shows the integration's status and last check-in, the Operator Configuration reported by the operator (operator version and which scan types are enabled), the Kubernetes version, and recent activity. To change the integration's configuration, select the edit (pencil) icon. To learn more, read Edit a Kubernetes integration.

Kubernetes integration page with integration details, operator configuration, and platform overview information

The operator scans on its own schedule and reports in by itself, so a Kubernetes integration page has no button to run a scan on demand.

Edit a Kubernetes integration

You need the Editor or Owner role, or another role with this permission. To see every role, read Roles and permissions.

To change an integration, open it as described in View a Kubernetes integration and select the edit (pencil) icon. The edit form has the same name, scanning options, and external clusters steps as the add form, plus more settings for the MondooAuditConfig.

Under Scanning options, Inherit namespace labels lists label keys (one per line) that Mondoo copies from each namespace onto the assets in it, so you can filter and report on them.

Expand Advanced options for these settings:

SectionSettings
SchedulingCron schedules for each scan type, a start delay for node scans, and toggles that suspend scans. Details are below the table.
Namespace & secretsThe namespace for the audit config and the names of the credentials and token Secrets.
Label selectorsScan only the namespaces, Kubernetes objects, or nodes whose labels match. Details are below the table.
Replicas & resourcesScanner replicas and CPU and memory requests and limits for the scanner, node scanning, and container scanning.
Node scan profilesGives groups of nodes their own node scanner settings: a node selector, resources, and Tolerations. For example, give a GPU pool more memory, or let the scanner run on a tainted pool.
Container repository filteringContainer repositories to include in or exclude from image scans.
Scan cache & deadlinesThe scan cache and its TTL, and active deadlines for Kubernetes resource and container scan jobs.
Resource watcherScans Kubernetes resources when they change, in addition to the scheduled scans. Off by default. Details are below the table.
Network inventoryWhich network resources Kubernetes resource scans inventory, and how they classify addresses. Details are below the table.
Job overridesTTL, annotations, labels, node selector, and Tolerations for all scan jobs or for the scanner, node scanning, and container scanning jobs.
Environment variablesExtra environment variables for the scanner, node scanning, and container scanning, set as values or read from a Secret, ConfigMap, or field. Details are below the table.
Other settingsNode priority class, node interval timer (used only by the DaemonSet node scan style), the space that receives scan results, and annotations to add to scanned assets.

The Scheduling section has these settings:

  • Scan schedule, Nodes scan schedule, and Containers scan schedule take cron schedules. Leave them empty to use the operator default. With Mondoo Operator 14.0.1 and later, scans run at most once an hour. To learn more, read Scan schedules.
  • Node scan start spread sets the longest delay before a node scan starts, as a Go duration such as 10m. Each node gets its own fixed delay within that range, based on the node's name, so scans on many nodes don't start at once.
  • Suspend Kubernetes resource scans, Suspend node scans, and Suspend container image scans keep the configuration but stop scheduled scans until you turn them off again.

The Label selectors section has these settings:

  • Namespace label selector scans only the namespaces whose labels match, together with the namespace allow and deny lists.
  • Object label selector scans only the Kubernetes objects whose labels match.
  • Node label selector scans only the nodes whose labels match.

The Resource watcher section is off by default, so the operator scans Kubernetes resources only on the Scan schedule. Turn on Enable resource watcher to have the operator run a resource watcher Deployment that scans resources when they're created or changed:

  • Debounce interval is how long the watcher collects changes before it starts a scan. The default is 10s.
  • Minimum scan interval is the shortest time between two scans, however often resources change. The default is 2m.
  • By default, the watcher watches Deployments, DaemonSets, StatefulSets, and ReplicaSets. Watch all resources adds Pods, Jobs, CronJobs, Services, Ingresses, and Namespaces.
  • With Watch all resources off, Resource types (one per line) replaces the default list. Enter resource names such as deployments or services. The watcher accepts these names, singular or plural: pods, deployments, daemonsets, statefulsets, replicasets, jobs, cronjobs, services, ingresses, namespaces, configmaps, secrets, and serviceaccounts, and skips any other entry, including group-qualified names such as deployments.apps.

The Network inventory section has these settings:

  • Host-based networking, Legacy HBN resources, and Multi-network policies each take Operator default, On, or Off. They control whether Kubernetes resource scans inventory host-based networking (HBN) resources, the legacy HBN resource types, and MultiNetworkPolicy and NetworkAttachmentDefinition resources. Operator default turns all three on.
  • Public CIDRs and Private CIDRs list address ranges to classify as public or private (one per line).
  • Trusted egress CIDRs lists destinations that egress traffic can reach without being flagged (one per line).

The operator sets MONDOO_PARALLELISM to 1 on its scan pods, so each pod scans one asset at a time to limit its memory use. To scan several assets at once, add MONDOO_PARALLELISM with a higher value in the Environment variables section for the scanner, node scanning, or container scanning, and raise that scan's memory limit under Replicas & resources to match.

Each external cluster also has its own scan settings: a scan schedule, a suspend toggle, container repository allow and deny lists, a private registries pull secret, and namespace and object label selectors.

Select SAVE CHANGES. If the operator is connected to Mondoo, it picks up the new configuration within 10 minutes. Otherwise, under Apply changes to your cluster, Mondoo shows a command that updates the audit configuration on your cluster. Run it, then select DONE.

Scan schedules

Mondoo Operator 14.0.1 and later run each scan at most once an hour. If a Kubernetes resource, external cluster, node, or container image scan schedule fires more often, the operator replaces the schedule's minute field with the first minute the schedule matches and keeps its other fields. For example, */5 * * * * runs as 0 * * * *, and */10 9-17 * * 1-5 runs as 0 9-17 * * 1-5. The operator also raises a node interval timer below 60 minutes to 60. To scan Kubernetes resources as they change, turn on the Resource watcher instead.

The Mondoo App and the MondooAuditConfig keep showing the schedule you set. To see which schedules the operator changed, check the ScanScheduleGuarded condition in the status of the MondooAuditConfig:

kubectl describe mondooauditconfigs -n mondoo-operator

The Mondoo App has no setting to turn this limit off. To let schedules run more often than once an hour, set spec.scheduleGuard.disable to true in the MondooAuditConfig with kubectl, for example:

kubectl patch mondooauditconfig mondoo-client -n mondoo-operator --type merge \
  -p '{"spec":{"scheduleGuard":{"disable":true}}}'

Replace mondoo-client with your audit configuration's name if you turned on Use unique audit config name, and mondoo-operator with its namespace if you set a Namespace override.

Remove a Kubernetes integration

You need the Editor or Owner role, or another role with this permission. To see every role, read Roles and permissions.

  1. Follow the instructions above to view your list of Kubernetes integrations.

  2. Find the integration you want to remove and check the box beside it.

  3. Select the DELETE SELECTED button, then confirm.

Kubernetes integration list with one integration selected and the Delete Selected button

You can also open the integration and select the trash can icon at the top of its page.

Update or uninstall the operator

The operator doesn't update itself. It picks up new cnspec scanner images within the cnspec major version it runs, but the operator stays on the version you installed until you update it with the same tool you installed it with: helm repo update and then helm upgrade mondoo-operator mondoo/mondoo-operator --namespace mondoo-operator, or kubectl apply -f https://install.mondoo.com/k8s/operator. Update one major version at a time. For the full steps, read Update the Mondoo Kubernetes Operator.

To remove the operator from the cluster, read Uninstall the Mondoo Kubernetes Operator.

Run multiple integrations on a single cluster

Because the operator and its integrations are decoupled, you can connect a single operator to multiple Mondoo integrations. Each integration gets its own service account Secret and MondooAuditConfig. This lets you:

  • Report different parts of the cluster to different Mondoo spaces
  • Apply different scan configurations (schedule, namespace filters) side by side

To run multiple integrations on the same cluster, enable Use unique audit config name when creating each integration. This gives each MondooAuditConfig a name based on the integration ID, preventing naming conflicts.

Node scan styles

The operator scans nodes in one of two styles:

  • CronJob (the default): on the node scan schedule, the operator starts a scan Job for each node. Nodes scan schedule, Suspend node scans, Node scan start spread, and Node scan profiles apply only to this style, and the operator only removes node assets that no longer exist in this style.
  • DaemonSet: a long-running scan pod on every node scans that node at a fixed interval, set in minutes by the node interval timer. Mondoo Operator 14.0.1 and later raise an interval shorter than 60 minutes to 60 (see Scan schedules).

The Mondoo App always uses the CronJob style. Its add and edit forms and the audit configuration commands it generates all set it, so saving an integration in the Mondoo App sets the integration's style back to CronJob, and so does applying a command the Mondoo App generates. The Nodes interval timer (minutes) field under Other settings has no effect while the style is CronJob.

To use the DaemonSet style, set it outside the Mondoo App:

  • If the MondooAuditConfig doesn't set spec.remoteManaged: true, the operator scans with the MondooAuditConfig's own settings. Set spec.nodes.style to daemonset in it, and optionally spec.nodes.intervalTimer to the number of minutes between scans. The default is 60.
  • If the MondooAuditConfig sets spec.remoteManaged: true, the operator takes its scan settings from the integration in Mondoo instead. Set the style on the integration, for example with the Terraform mondoo_integration_kubernetes resource: in its nodes attribute, set style = "daemonset" and interval_timer to the number of minutes between scans.

Reuse of container image scan results

Mondoo identifies a container image by its digest, which changes whenever the image's content changes. When the operator finds a running image whose digest Mondoo has already scanned in your organization, it doesn't pull and scan the image again. The earlier scan can come from any space in the organization, another cluster, or a CI pipeline. Mondoo copies that scan's packages and platform to the image's asset in this space and scores it as usual, so the asset shows the image's packages and vulnerabilities right away, without a registry pull.

An image reused this way has no policy or check results until the operator scans the image itself. Until then, its asset page shows Never scanned.

  • Reuse stays within one organization. Mondoo never uses another organization's scans.
  • The first time Mondoo sees a multi-architecture image (a tag that points to an image index), the operator pulls and scans it. Later sightings of the same image are reused.
  • An image that no cluster or pipeline in the organization has used for 90 days is scanned again the next time it appears.
  • Reuse requires Mondoo Operator 14 or later.

Scan images in CI so clusters can reuse the results

To have your clusters reuse an image's results from its very first deployment, scan the image in your pipeline right after you push it, using its pushed digest:

cnspec scan container image REGISTRY/REPOSITORY@sha256:DIGEST

Scan the image in the registry, by digest. A scan of the local copy in the Docker engine identifies the image differently, so clusters can't reuse it. Use cnspec 14.9.1 or later.

Removal of assets that no longer exist

The operator removes the assets of resources, nodes, and container images that have left the cluster. After each successful scheduled scan, it asks Mondoo to delete the assets it reported that haven't been updated for twice the interval of their scan schedule:

  • Kubernetes resource assets, such as namespaces and workloads, use the Kubernetes resource Scan schedule. The assets of external clusters use this schedule too, not each external cluster's own schedule. If an external cluster's scans are further apart than twice the Scan schedule's interval, the operator can remove its assets between those scans.
  • Node assets use the Nodes scan schedule. The operator only removes node assets with the CronJob node scan style.
  • Container image assets use the Containers scan schedule.

For example, with an hourly schedule, an asset is removed at the first successful scan after it has gone 2 hours without an update. With a daily schedule, the window is 2 days. If a schedule is empty or isn't a valid cron schedule, the window is 2 hours. To use a fixed window for all three instead, set the MONDOO_GC_OLDER_THAN environment variable on the operator Deployment's manager container to a Go duration, such as 72h.

The operator only removes assets that it reported. To remove any asset that stops reporting after a while, use the space's Remove inactive assets setting. To learn more, read Choose When to Automatically Remove Obsolete Assets.

Monitor the operator with Prometheus

The operator serves Prometheus metrics: the standard controller-runtime metrics and mondoo_audit_configs, the number of MondooAuditConfig resources in the cluster. A Helm installation exposes them through the mondoo-operator-controller-manager-metrics-service Service over HTTP on port 8080. To serve them over HTTPS on port 8443 with RBAC authentication and authorization instead, set the Helm value controllerManager.manager.secureMetrics to true.

If the Prometheus Operator is installed in the cluster, the operator can create a ServiceMonitor named mondoo-operator-metrics-monitor for its metrics. To turn it on, set spec.metrics.enable to true in the MondooOperatorConfig. If your Prometheus selects ServiceMonitors by label, list those labels under spec.metrics.resourceLabels:

spec:
  metrics:
    enable: true
    resourceLabels:
      release: prometheus

With Helm, setting controllerManager.manager.secureMetrics to true also turns on the ServiceMonitor. The chart has no value for resourceLabels. To set them on a Helm installation, set operator.createConfig to false and apply the MondooOperatorConfig yourself. Helm then no longer writes its operator values into the MondooOperatorConfig, so add any proxy or registry settings to it too. If you set controllerManager.manager.secureMetrics, also set spec.metrics.secureMetrics to true, so the ServiceMonitor scrapes the HTTPS port. If the Prometheus Operator isn't installed, the operator creates no ServiceMonitor and sets the PrometheusMissing condition on the MondooOperatorConfig.

Troubleshoot

No integration appears after a Helm install

Symptom: No Kubernetes integration appears in the Mondoo App after a Helm install.

The Helm chart installs only the operator. Integrations are created in the Mondoo App.

Fix: Add a Kubernetes integration, then run the token Secret and audit configuration commands it generates. You don't need to reinstall the operator.

Pods can't pull their images

Symptom: Operator or scan pods stay in ImagePullBackOff or ErrImagePull.

The cluster can't pull the images from ghcr.io (or Docker Hub, for the Helm job that installs the custom resource definitions), or the mirror lacks an image or the credentials. Scan pods that use workload identity or SPIFFE stay in Init:ImagePullBackOff when the cluster can't pull their helper image, which the operator's mirror settings don't rewrite.

Fix:

  1. Run kubectl describe pod POD_NAME -n mondoo-operator to see which image failed and why.
  2. Allow outbound access to the registry, or mirror the images and set the Helm values for a private registry.
  3. If a workload identity or SPIFFE helper image failed, allow outbound access to its registry. A mirror doesn't help for these images.

The integration stays pending

Symptom: The integration stays pending (Not ready).

The operator never checked in. The token Secret or the audit configuration wasn't applied, the token expired before the operator used it, or the cluster can't reach the Mondoo API.

Fix:

  1. Confirm that the audit configuration and the credentials Secret exist (see Verify the integration).
  2. If the credentials Secret is missing, read the operator log with kubectl logs -n mondoo-operator deployment/mondoo-operator-controller-manager.
  3. The token expires 30 minutes after you create the integration and can't be renewed. If it expired, delete the integration and create a new one.

The integration changes to Missing

Symptom: The integration changes to Missing.

The integration was active but hasn't checked in for an hour.

Fix: Check that the operator pod is running and that the cluster still has outbound access to the Mondoo API.

The integration is active, but no assets appear

Symptom: The integration is Active, but no assets appear.

The first scans haven't finished, or the scan pods failed.

Fix:

  1. List the scan CronJobs with kubectl get cronjobs -n mondoo-operator.
  2. To scan right away, create a job from one, for example kubectl create job -n mondoo-operator first-scan --from=cronjob/mondoo-client-k8s-scan, and read its pod's log.
  3. Check that your namespace filters don't exclude every namespace.

A scan pod ran out of memory

Symptom: The integration page shows a message that a pod "has been terminated because it reached its memory limit".

A scan pod ran out of memory.

Fix: Raise its memory limit. Edit the integration and set the resources under Replicas & resources, or give large nodes their own settings under Node scan profiles.

Keep a node scan's memory limit at or below 70% of the node's allocatable memory. With the default CronJob node scan style, node scan pods are bound directly to their node, so Kubernetes doesn't check the limit against the node. With a higher limit, a scan that runs out of memory can starve the node instead of being stopped. The operator writes a message to its own log (kubectl logs -n mondoo-operator deployment/mondoo-operator-controller-manager) when a node scan's memory limit is above 70% of a node's allocatable memory.

Container image scan pods are evicted on GKE Autopilot

Symptom: Container image scan pods are evicted with the message Pod ephemeral local storage usage exceeds the total limit.

Container image scans download each image into the pod's temporary storage. By default, the operator requests 2Gi of ephemeral storage for each container image scan pod and limits it to 5Gi, which leaves room for the downloaded images on GKE Autopilot too. These defaults only apply while no resources are set for container scanning. If you set Container scanning resources under Replicas & resources, the pods get only the CPU and memory values you set, with no ephemeral storage request or limit, so GKE Autopilot gives them its own default ephemeral storage, which is smaller.

Fix:

  1. If you set Container scanning resources on the integration and don't need them, clear them to restore the defaults.
  2. To give the pods more ephemeral storage, set ephemeral-storage requests and limits, together with CPU and memory, in spec.containers.resources of the MondooAuditConfig. Resources you set there replace all of the defaults. This only works if the MondooAuditConfig doesn't set spec.remoteManaged: true. With spec.remoteManaged: true, the operator takes its resources from the integration, which has no ephemeral storage setting.

Next steps

Results appear after the first scan finishes; the integration page shows its status.

To scan clusters the operator doesn't run in, read Scan External Kubernetes Clusters.

Last updated on

On this page