Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 41 additions & 8 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
argocdcommon "github.com/argoproj-labs/argocd-operator/common"
argocdprovisioner "github.com/argoproj-labs/argocd-operator/controllers/argocd"
notificationsprovisioner "github.com/argoproj-labs/argocd-operator/controllers/notificationsconfiguration"
"github.com/argoproj-labs/argocd-operator/pkg/cacheutils"
cw "github.com/argoproj-labs/argocd-operator/pkg/clientwrapper"
appsv1 "github.com/openshift/api/apps/v1"
configv1 "github.com/openshift/api/config/v1"
console "github.com/openshift/api/console/v1"
Expand All @@ -46,11 +48,14 @@ import (
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
corev1 "k8s.io/api/core/v1"
crdv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/labels"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
crclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
controllerconfig "sigs.k8s.io/controller-runtime/pkg/config"
"sigs.k8s.io/controller-runtime/pkg/healthz"
Expand Down Expand Up @@ -146,7 +151,8 @@ func main() {
TLSOpts: []func(*tls.Config){disableHTTP2},
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
// Set default manager options
options := ctrl.Options{
Scheme: scheme,
Metrics: metricsServerOptions,
WebhookServer: webhookServer,
Expand All @@ -156,12 +162,39 @@ func main() {
Controller: controllerconfig.Controller{
SkipNameValidation: &skipControllerNameValidation,
},
})
}

// Use transformers to strip data from Secrets and ConfigMaps
// that are not tracked by the operator to reduce memory usage.
if strings.ToLower(os.Getenv("MEMORY_OPTIMIZATION_ENABLED")) != "false" {
setupLog.Info("memory optimization is enabled")
options.Cache = cache.Options{
Scheme: scheme,
ByObject: map[crclient.Object]cache.ByObject{
&corev1.Secret{}: {Transform: cacheutils.StripDataFromSecretOrConfigMapTransform()},
&corev1.ConfigMap{}: {Transform: cacheutils.StripDataFromSecretOrConfigMapTransform()},
},
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), options)
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
}

var client crclient.Client
if strings.ToLower(os.Getenv("MEMORY_OPTIMIZATION_ENABLED")) != "false" {
liveClient, err := crclient.New(ctrl.GetConfigOrDie(), crclient.Options{Scheme: mgr.GetScheme()})
if err != nil {
setupLog.Error(err, "unable to create live client")
os.Exit(1)
}
client = cw.NewClientWrapper(mgr.GetClient(), liveClient)
} else {
client = mgr.GetClient()
}

registerComponentOrExit(mgr, console.AddToScheme)
registerComponentOrExit(mgr, routev1.AddToScheme) // Adding the routev1 api
registerComponentOrExit(mgr, operatorsv1.AddToScheme)
Expand All @@ -185,7 +218,7 @@ func main() {
}

if err = (&controllers.ReconcileGitopsService{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
DisableDefaultInstall: strings.ToLower(os.Getenv(common.DisableDefaultInstallEnvVar)) == "true",
}).SetupWithManager(mgr); err != nil {
Expand All @@ -194,15 +227,15 @@ func main() {
}

if err = (&controllers.ReconcileArgoCDRoute{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Argo CD route")
os.Exit(1)
}

if err = (&controllers.ArgoCDMetricsReconciler{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Argo CD metrics")
Expand All @@ -224,7 +257,7 @@ func main() {
argocdprovisioner.Register(openshift.ReconcilerHook, openshift.BuilderHook)

if err = (&argocdprovisioner.ReconcileArgoCD{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
LabelSelector: labelSelectorFlag,
K8sClient: k8sClient,
Expand All @@ -245,7 +278,7 @@ func main() {
}

if err = (&rolloutManagerProvisioner.RolloutManagerReconciler{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
OpenShiftRoutePluginLocation: getArgoRolloutsOpenshiftRouteTrafficManagerPath(),
NamespaceScopedArgoRolloutsController: isNamespaceScoped,
Expand All @@ -255,7 +288,7 @@ func main() {
}

if err = (&notificationsprovisioner.NotificationsConfigurationReconciler{
Client: mgr.GetClient(),
Client: client,
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Notifications Configuration")
Expand Down
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/redhat-developer/gitops-operator

go 1.24.4
go 1.24.6

require (
github.com/argoproj-labs/argo-rollouts-manager v0.0.6-0.20250731075119-a100fc1d88b8
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20250825094300-73f08c092df7
github.com/argoproj/argo-cd/v3 v3.1.0-rc2
github.com/argoproj/gitops-engine v0.7.1-0.20250617174952-093aef0dad58
github.com/argoproj-labs/argocd-operator v0.14.0-rc1.0.20251105033011-e979a3f5f471
github.com/argoproj/argo-cd/v3 v3.1.8
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec
github.com/go-logr/logr v1.4.3
github.com/google/go-cmp v0.7.0
github.com/hashicorp/go-version v1.7.0
Expand All @@ -15,9 +15,9 @@ require (
github.com/openshift/api v0.0.0-20240906151052-5d963dce87aa
github.com/operator-framework/api v0.17.5
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.73.2
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
go.uber.org/zap v1.27.0
golang.org/x/mod v0.25.0
golang.org/x/mod v0.28.0
gotest.tools v2.2.0+incompatible
k8s.io/api v0.33.2
k8s.io/apiextensions-apiserver v0.33.1
Expand Down Expand Up @@ -49,7 +49,7 @@ require (
github.com/bradleyfalzon/ghinstallation/v2 v2.16.0 // indirect
github.com/casbin/casbin/v2 v2.107.0 // indirect
github.com/casbin/govaluate v1.7.0 // indirect
github.com/cert-manager/cert-manager v1.14.4 // indirect
github.com/cert-manager/cert-manager v1.15.4 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chai2010/gettext-go v1.0.3 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
Expand Down Expand Up @@ -139,15 +139,15 @@ require (
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.39.0 // indirect
golang.org/x/net v0.41.0 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/oauth2 v0.30.0 // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.26.0 // indirect
golang.org/x/sync v0.16.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/term v0.34.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/time v0.12.0 // indirect
golang.org/x/tools v0.33.0 // indirect
golang.org/x/tools v0.36.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250519155744-55703ea1f237 // indirect
google.golang.org/grpc v1.73.0 // indirect
Expand All @@ -168,7 +168,7 @@ require (
k8s.io/kubectl v0.33.1 // indirect
k8s.io/kubernetes v1.33.1 // indirect
oras.land/oras-go/v2 v2.6.0 // indirect
sigs.k8s.io/gateway-api v1.0.0 // indirect
sigs.k8s.io/gateway-api v1.1.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/kustomize/api v0.19.0 // indirect
sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect
Expand Down
Loading