Skip to content

feat: add MondooOperatorConfig for proxy and image registry support#1391

Merged
chris-rock merged 9 commits intomainfrom
feat-operator-config
Feb 16, 2026
Merged

feat: add MondooOperatorConfig for proxy and image registry support#1391
chris-rock merged 9 commits intomainfrom
feat-operator-config

Conversation

@chris-rock
Copy link
Member

Summary

  • Adds MondooOperatorConfig cluster-scoped CRD for configuring HTTP/HTTPS proxy settings, no-proxy rules, and container image registry mirrors across all MondooAuditConfig resources
  • Fixes several bugs: imagePullSecrets clobbering (append instead of overwrite), --api-proxy HTTPS preference, operator config watch for live reloads, shared image cache mutex
  • Adds comprehensive unit tests for proxy/registry code paths across all resource builders (k8s_scan, container_image, nodes, resource_watcher)
  • Improves integration test reliability with dedicated CronJob retry timeout, stale cluster cleanup, and reduced test noise

Key Changes

  • New CRD: MondooOperatorConfig with proxy (httpProxy, httpsProxy, noProxy), registry mirror (registryMirrors, imageRegistry), and skipContainerResolution fields
  • Proxy support: Injects HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars and --api-proxy flag into all scan CronJobs, DaemonSets, and Deployments
  • Registry mirrors: Rewrites image references using configurable registry mappings
  • Bug fixes: imagePullSecrets append, API proxy URL HTTPS preference, operator config watch, shared cache concurrency
  • Tests: 30+ new unit tests covering proxy, registry, and imagePullSecrets across all resource builders
  • Integration test fixes: CronJob schedule timing, helm template CRDs, stale cluster cleanup, reduced AfterTest noise

Test plan

  • make lint passes
  • make lint/actions passes
  • Unit tests pass: go test ./pkg/utils/k8s/... ./controllers/k8s_scan/... ./controllers/container_image/... ./controllers/nodes/... ./controllers/resource_watcher/... ./pkg/imagecache/...
  • Integration tests validated against k3d cluster (TestReconcile_Containers, TestReconcile_KubernetesResources, TestReconcile_Nodes, TestHelmTemplate)

🤖 Generated with Claude Code

jpaodev and others added 8 commits February 13, 2026 18:10
Introduce MondooOperatorConfig CRD with support for:
- HTTP/HTTPS proxy configuration (httpProxy, httpsProxy, noProxy)
- Container proxy for image scanning
- Image pull secrets for private registries
- Image registry mirror support
- Registry mirrors mapping
- Skip proxy for cnspec option

Tested on GKE Autopilot successfully.
- Address code quality issues and extract clone() helper
- Make noProxy matching case-insensitive
- Add logging for imagePullSecret lookup failures
- Default createConfig to true in Helm values
- Remove deprecated marker from imageRegistry field
- Add tests for KeychainFromSecrets and applyImageRegistry
- Add operator config documentation
- Fix imagePullSecrets to append instead of clobber existing secrets
- Prefer HTTPS proxy for --api-proxy (Mondoo API is always HTTPS)
- Add APIProxyURL helper to centralize proxy URL selection
- Watch MondooOperatorConfig changes to trigger reconciliation
- Share image cache across keychain changes (use pointer mutex)
- Remove scaffolding comments from types
- Fix "MondooOpertorConfig" typos in log messages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive test coverage for MondooOperatorConfig proxy and
registry mirror integration across all resource builders:
- pkg/utils/k8s: ProxyEnvVars and APIProxyURL unit tests
- k8s_scan: proxy, skip-proxy, imagePullSecrets, container-proxy tests
- container_image: proxy, skip-proxy, imagePullSecrets, container-proxy tests
- nodes: CronJob and DaemonSet proxy/skip-proxy/imagePullSecrets tests
- resource_watcher: HTTPS preference, skip-proxy, env vars, imagePullSecrets tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The cron schedule only uses the minute field, so the effective buffer
between function call time and the CronJob trigger is
(targetMinuteStart - now), which could be as low as 16 seconds with
the old 75-second offset. This wasn't enough when leader election
takes ~46 seconds, causing the CronJob to miss its scheduled minute
and wait an hour for the next trigger.

Increase the offset from 1m15s to 2m30s, guaranteeing at least ~91
seconds of buffer regardless of when in the current minute the
function is called.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CRDs live in charts/mondoo-operator/crds/ (not templates/),
so helm template doesn't render them by default. Add --include-crds
to the Template helper so TestHelmTemplate can verify CRDs are present.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 2m30s buffer was too aggressive - worst-case trigger time (~150s)
exceeded the retry window (100s), causing tests to time out before
CronJobs fired. Reduce buffer to 2m (61-120s range) and double
RetryLoop from 50 to 100 (200s window) to accommodate the buffer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add CronJobRetryLoop (600s) for WaitUntilCronJobsSuccessful to handle
  variable scan durations without affecting other retry timeouts
- Clean up stale k3d target cluster before creating in external cluster tests
- Add --ignore-not-found to pod deletion in AfterTest cleanup
- Downgrade completed CronJob pod describe failure from ERROR to WARN
- Regenerate CRD and RBAC manifests for updated type docs and job delete verb
- Fix whitespace alignment in container_image_resolver_test.go

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions
Copy link

github-actions bot commented Feb 14, 2026

Test Results

  5 files  ± 0   42 suites  ±0   1h 2m 44s ⏱️ + 20m 3s
393 tests +91  393 ✅ +91  0 💤 ±0  0 ❌ ±0 
433 runs  +91  431 ✅ +91  2 💤 ±0  0 ❌ ±0 

Results for commit d8af2eb. ± Comparison against base commit 3b0a735.

♻️ This comment has been updated with latest results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chris-rock chris-rock merged commit 597d519 into main Feb 16, 2026
25 checks passed
@chris-rock chris-rock deleted the feat-operator-config branch February 16, 2026 11:29
@github-actions github-actions bot locked and limited conversation to collaborators Feb 16, 2026
@chris-rock
Copy link
Member Author

Huge thank you for @jpaodev for raising this feature request in #1337. We rebases the his change into this PR and did some additional changes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants