Skip to content

Commit 597d519

Browse files
chris-rockjpaodevclaude
authored
feat: add MondooOperatorConfig for proxy and image registry support (#1391)
* feat: add MondooOperatorConfig for proxy and image registry support 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. * refactor: improve MondooOperatorConfig quality and documentation - 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: address review issues in MondooOperatorConfig integration - 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> * test: add proxy and registry integration tests for resource builders 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> * fix: increase CronJob schedule buffer in integration tests 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> * fix: include CRDs in helm template test output 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> * fix: correct CronJob schedule buffer and increase retry window 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> * fix: improve integration test reliability and cleanup - 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> * fix: add expected words for spell checker Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: jpaodev <jpaodev@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent af62f04 commit 597d519

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4318
-1483
lines changed

.github/actions/spelling/expect.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
AADSTS
2+
artifactory
23
bak
34
bitnami
45
curlimages
56
deepcopy
67
deletecollection
8+
dockerconfigjson
79
eksctl
810
fullname
911
iamidentitymapping
1012
irsa
1113
kustomization
1214
mcr
15+
mondoooperatorconfig
1316
oidc
1417
openssl
1518
psat
1619
rolearn
1720
selfsigned
21+
servicemonitor
1822
servicemonitors
1923
SResources
2024
spiffe

api/v1alpha2/mondoooperatorconfig_types.go

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,43 @@ const (
1414
MondooOperatorConfigName = "mondoo-operator-config"
1515
)
1616

17-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
18-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
19-
2017
// MondooOperatorConfigSpec defines the desired state of MondooOperatorConfig
2118
type MondooOperatorConfigSpec struct {
22-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
23-
// Important: Run "make" to regenerate code after modifying this file
24-
2519
// Metrics controls the enabling/disabling of metrics report of mondoo-operator
2620
Metrics Metrics `json:"metrics,omitempty"`
2721
// Allows skipping Image resolution from upstream repository
2822
SkipContainerResolution bool `json:"skipContainerResolution,omitempty"`
2923
// HttpProxy specifies a proxy to use for HTTP requests to the Mondoo Platform.
3024
HttpProxy *string `json:"httpProxy,omitempty"`
25+
// HttpsProxy specifies a proxy to use for HTTPS requests to the Mondoo Platform.
26+
HttpsProxy *string `json:"httpsProxy,omitempty"`
27+
// NoProxy specifies a comma-separated list of hosts that should not use the proxy.
28+
NoProxy *string `json:"noProxy,omitempty"`
3129
// ContainerProxy specifies a proxy to use for container images.
3230
ContainerProxy *string `json:"containerProxy,omitempty"`
31+
// ImagePullSecrets specifies the name of the Secret to use for pulling images for all Mondoo components.
32+
// The secret must be of type kubernetes.io/dockerconfigjson.
33+
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
34+
// ImageRegistry specifies a custom container image registry prefix for all Mondoo images.
35+
// Use this for simple registry mirrors where all images go to the same mirror.
36+
// Example: "artifactory.example.com/ghcr.io.docker"
37+
// For more complex setups with multiple source registries, use RegistryMirrors instead.
38+
ImageRegistry *string `json:"imageRegistry,omitempty"`
39+
// RegistryMirrors specifies a mapping of public registries to private mirrors.
40+
// Use this when you need to map different source registries to different mirrors.
41+
// The key is the public registry (e.g., "ghcr.io", "docker.io", "quay.io")
42+
// and the value is the private mirror (e.g., "artifactory.example.com/ghcr.io.docker").
43+
// Example:
44+
// registryMirrors:
45+
// ghcr.io: artifactory.example.com/ghcr.io.docker
46+
// docker.io: artifactory.example.com/hub.docker.com
47+
// Note: If both ImageRegistry and RegistryMirrors are set, RegistryMirrors takes precedence.
48+
RegistryMirrors map[string]string `json:"registryMirrors,omitempty"`
49+
// SkipProxyForCnspec disables proxy environment variables for cnspec-based components
50+
// (scan-api, container scanning). Use this when the Mondoo API is accessible directly
51+
// without proxy (e.g., internal mirror) but other components need proxy for external access.
52+
// Default: false (proxy settings are applied to all components)
53+
SkipProxyForCnspec bool `json:"skipProxyForCnspec,omitempty"`
3354
}
3455

3556
type Metrics struct {
@@ -41,9 +62,6 @@ type Metrics struct {
4162

4263
// MondooOperatorConfigStatus defines the observed state of MondooOperatorConfig
4364
type MondooOperatorConfigStatus struct {
44-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
45-
// Important: Run "make" to regenerate code after modifying this file
46-
4765
// Conditions includes more detailed status for the mondoo config
4866
// +optional
4967
Conditions []MondooOperatorConfigCondition `json:"conditions,omitempty"`

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)