Skip to content
Open
16 changes: 11 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/tigera/operator/pkg/apis"
"github.com/tigera/operator/pkg/awssgsetup"
"github.com/tigera/operator/pkg/common"
"github.com/tigera/operator/pkg/common/discovery"
"github.com/tigera/operator/pkg/components"
"github.com/tigera/operator/pkg/controller/metrics"
"github.com/tigera/operator/pkg/controller/migration/datastoremigration"
Expand Down Expand Up @@ -335,6 +336,10 @@ If a value other than 'all' is specified, the first CRD with a prefix of the spe
os.Exit(1)
}

// Snapshot the served versions for the Kubernetes APIs the operator branches on. Discovery
// happens once here so reconcile loops can do plain map lookups.
apiDiscovery := discovery.DiscoverAPIs(mgr.GetRESTMapper())

// If configured to manage CRDs, do a preliminary install of them here. The Installation controller
// will reconcile them as well, but we need to make sure they are installed before we start the rest of the controllers.
if bootstrapCRDs || manageCRDs {
Expand All @@ -345,7 +350,7 @@ If a value other than 'all' is specified, the first CRD with a prefix of the spe
os.Exit(1)
}

if err := admission.Ensure(mgr.GetClient(), variant, v3CRDs, setupLog); err != nil {
if err := admission.Ensure(mgr.GetClient(), variant, v3CRDs, apiDiscovery.ServedVersion(admission.APIGroup, admission.KindPolicy), setupLog); err != nil {
setupLog.Error(err, "Failed to ensure MutatingAdmissionPolicies are created")
os.Exit(1)
}
Expand Down Expand Up @@ -425,23 +430,23 @@ If a value other than 'all' is specified, the first CRD with a prefix of the spe
}

// Attempt to auto discover the provider
provider, err := utils.AutoDiscoverProvider(ctx, clientset)
provider, err := discovery.AutoDiscoverProvider(ctx, clientset)
if err != nil {
setupLog.Error(err, "Auto discovery of Provider failed")
os.Exit(1)
}
setupLog.WithValues("provider", provider).Info("Checking type of cluster")

// Determine if we're running in single or multi-tenant mode.
multiTenant, err := utils.MultiTenant(ctx, clientset)
multiTenant, err := discovery.MultiTenant(ctx, clientset)
if err != nil {
log.Error(err, "Failed to discovery tenancy mode")
os.Exit(1)
}
setupLog.WithValues("tenancy", multiTenant).Info("Checking tenancy mode")

// Determine if we need to start the Enterprise specific controllers.
enterpriseCRDExists, err := utils.RequiresTigeraSecure(clientset)
enterpriseCRDExists, err := discovery.RequiresTigeraSecure(clientset)
if err != nil {
setupLog.Error(err, "Failed to determine if Enterprise controllers are required")
os.Exit(1)
Expand Down Expand Up @@ -507,8 +512,9 @@ If a value other than 'all' is specified, the first CRD with a prefix of the spe
ShutdownContext: ctx,
K8sClientset: clientset,
MultiTenant: multiTenant,
ElasticExternal: utils.UseExternalElastic(bootConfig),
ElasticExternal: discovery.UseExternalElastic(bootConfig),
UseV3CRDs: v3CRDs,
APIDiscovery: apiDiscovery,
}

// Before we start any controllers, make sure our options are valid.
Expand Down
29 changes: 14 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ require (
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.20.2
k8s.io/api v0.35.4
k8s.io/apiextensions-apiserver v0.35.4
k8s.io/apimachinery v0.35.4
k8s.io/apiserver v0.35.4
k8s.io/client-go v0.35.4
k8s.io/kube-aggregator v0.35.4
k8s.io/api v0.36.1
k8s.io/apiextensions-apiserver v0.36.1
k8s.io/apimachinery v0.36.1
k8s.io/apiserver v0.36.1
k8s.io/client-go v0.36.1
k8s.io/kube-aggregator v0.36.1
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
sigs.k8s.io/controller-runtime v0.23.3
sigs.k8s.io/controller-runtime v0.24.1
sigs.k8s.io/gateway-api v1.4.1
sigs.k8s.io/kind v0.31.0 // Do not remove, not used by code but used by build
sigs.k8s.io/secrets-store-csi-driver v1.6.0
Expand Down Expand Up @@ -120,7 +120,6 @@ require (
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/huandu/xstrings v1.5.0 // indirect
Expand Down Expand Up @@ -186,22 +185,22 @@ require (
golang.org/x/tools v0.44.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
google.golang.org/grpc v1.79.3 // indirect
google.golang.org/protobuf v1.36.11 // indirect
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
howett.net/plist v1.0.1 // indirect
k8s.io/cli-runtime v0.35.3 // indirect
k8s.io/component-base v0.35.4 // indirect
k8s.io/cli-runtime v0.36.1 // indirect
k8s.io/component-base v0.36.1 // indirect
k8s.io/klog/v2 v2.140.0 // indirect
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
k8s.io/kubectl v0.35.3 // indirect
k8s.io/kubectl v0.36.1 // indirect
oras.land/oras-go/v2 v2.6.0 // indirect
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
sigs.k8s.io/kustomize/api v0.20.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
sigs.k8s.io/kustomize/api v0.21.1 // indirect
sigs.k8s.io/kustomize/kyaml v0.21.1 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
)
Expand Down
Loading
Loading