@@ -52,7 +52,6 @@ import (
5252 "github.com/tigera/operator/pkg/render"
5353 rcertificatemanagement "github.com/tigera/operator/pkg/render/certificatemanagement"
5454 "github.com/tigera/operator/pkg/render/common/authentication"
55- rmeta "github.com/tigera/operator/pkg/render/common/meta"
5655 "github.com/tigera/operator/pkg/render/common/networkpolicy"
5756 "github.com/tigera/operator/pkg/render/monitor"
5857 "github.com/tigera/operator/pkg/tls/certificatemanagement"
@@ -78,7 +77,7 @@ func Add(mgr manager.Manager, opts options.AddOptions) error {
7877 go utils .WaitToAddTierWatch (networkpolicy .TigeraComponentTierName , c , opts .K8sClientset , log , r .tierWatchReady )
7978
8079 go utils .WaitToAddNetworkPolicyWatches (c , opts .K8sClientset , log , []types.NamespacedName {
81- {Name : render .APIServerPolicyName , Namespace : rmeta .APIServerNamespace ( operatorv1 . TigeraSecureEnterprise ) },
80+ {Name : render .APIServerPolicyName , Namespace : render .APIServerNamespace },
8281 })
8382 }
8483
@@ -139,7 +138,7 @@ func add(c ctrlruntime.Controller, r *ReconcileAPIServer) error {
139138 return fmt .Errorf ("apiserver-controller failed to watch primary resource: %v" , err )
140139 }
141140
142- for _ , namespace := range []string {common .OperatorNamespace (), rmeta .APIServerNamespace ( operatorv1 . TigeraSecureEnterprise ) } {
141+ for _ , namespace := range []string {common .OperatorNamespace (), render .APIServerNamespace } {
143142 for _ , secretName := range []string {render .VoltronTunnelSecretName , render .ManagerTLSSecretName } {
144143 if err = utils .AddSecretsWatch (c , secretName , namespace ); err != nil {
145144 return fmt .Errorf ("apiserver-controller failed to watch the Secret resource: %v" , err )
@@ -156,10 +155,10 @@ func add(c ctrlruntime.Controller, r *ReconcileAPIServer) error {
156155 }
157156
158157 // Watch for the namespace(s) managed by this controller.
159- if err = c .WatchObject (& corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : rmeta .APIServerNamespace ( operatorv1 . Calico ) }}, & handler.EnqueueRequestForObject {}); err != nil {
158+ if err = c .WatchObject (& corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : render .APIServerNamespace }}, & handler.EnqueueRequestForObject {}); err != nil {
160159 return fmt .Errorf ("apiserver-controller failed to watch resource: %w" , err )
161160 }
162- if err = c .WatchObject (& corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : rmeta .APIServerNamespace ( operatorv1 . TigeraSecureEnterprise ) }}, & handler.EnqueueRequestForObject {}); err != nil {
161+ if err = c .WatchObject (& corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : render .APIServerNamespace }}, & handler.EnqueueRequestForObject {}); err != nil {
163162 return fmt .Errorf ("apiserver-controller failed to watch resource: %w" , err )
164163 }
165164
@@ -261,7 +260,6 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
261260 r .status .SetDegraded (operatorv1 .ResourceNotReady , "Waiting for Installation Variant to be set" , nil , reqLogger )
262261 return reconcile.Result {}, nil
263262 }
264- ns := rmeta .APIServerNamespace (installationSpec .Variant )
265263
266264 certificateManager , err := certificatemanager .Create (r .client , installationSpec , r .clusterDomain , common .OperatorNamespace ())
267265 if err != nil {
@@ -271,13 +269,13 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
271269
272270 // We need separate certificates for OSS vs Enterprise.
273271 secretName := render .ProjectCalicoAPIServerTLSSecretName (installationSpec .Variant )
274- tlsSecret , err := certificateManager .GetOrCreateKeyPair (r .client , secretName , common .OperatorNamespace (), dns .GetServiceDNSNames (render .ProjectCalicoAPIServerServiceName (installationSpec .Variant ), rmeta .APIServerNamespace ( installationSpec . Variant ) , r .clusterDomain ))
272+ tlsSecret , err := certificateManager .GetOrCreateKeyPair (r .client , secretName , common .OperatorNamespace (), dns .GetServiceDNSNames (render .ProjectCalicoAPIServerServiceName (installationSpec .Variant ), render .APIServerNamespace , r .clusterDomain ))
275273 if err != nil {
276274 r .status .SetDegraded (operatorv1 .ResourceCreateError , "Unable to get or create tls key pair" , err , reqLogger )
277275 return reconcile.Result {}, err
278276 }
279277
280- certificateManager .AddToStatusManager (r .status , ns )
278+ certificateManager .AddToStatusManager (r .status , render . APIServerNamespace )
281279
282280 pullSecrets , err := utils .GetNetworkingPullSecrets (installationSpec , r .client )
283281 if err != nil {
@@ -439,7 +437,7 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
439437 MultiTenant : r .multiTenant ,
440438 KeyValidatorConfig : keyValidatorConfig ,
441439 KubernetesVersion : r .kubernetesVersion ,
442- CanCleanupOlderResources : r .canCleanupLegacyNamespace (ctx , reqLogger ),
440+ CanCleanupOlderResources : r .canCleanupLegacyNamespace (ctx , installationSpec . Variant , reqLogger ),
443441 }
444442
445443 var components []render.Component
@@ -460,7 +458,7 @@ func (r *ReconcileAPIServer) Reconcile(ctx context.Context, request reconcile.Re
460458 components = append (components ,
461459 component ,
462460 rcertificatemanagement .CertificateManagement (& rcertificatemanagement.Config {
463- Namespace : rmeta .APIServerNamespace ( installationSpec . Variant ) ,
461+ Namespace : render .APIServerNamespace ,
464462 ServiceAccounts : []string {render .APIServerServiceAccountName (installationSpec .Variant )},
465463 KeyPairOptions : []rcertificatemanagement.KeyPairOption {
466464 rcertificatemanagement .NewKeyPairOption (tlsSecret , true , true ),
@@ -515,11 +513,7 @@ func validateAPIServerResource(instance *operatorv1.APIServer) error {
515513// prior to the CNI plugin being removed.
516514func (r * ReconcileAPIServer ) maintainFinalizer (ctx context.Context , apiserver client.Object ) error {
517515 // These objects require graceful termination before the CNI plugin is torn down.
518- _ , spec , err := utils .GetInstallation (context .Background (), r .client )
519- if err != nil {
520- return err
521- }
522- apiServerNamespace := & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : rmeta .APIServerNamespace (spec .Variant )}}
516+ apiServerNamespace := & corev1.Namespace {ObjectMeta : metav1.ObjectMeta {Name : render .APIServerNamespace }}
523517 return utils .MaintainInstallationFinalizer (ctx , r .client , apiserver , render .APIServerFinalizer , apiServerNamespace )
524518}
525519
@@ -529,12 +523,16 @@ func (r *ReconcileAPIServer) maintainFinalizer(ctx context.Context, apiserver cl
529523// - The new API server deployment in "calico-system" exists and is available.
530524// - The old API server deployment in "tigera-system" is either removed or inactive.
531525// - Both the APIServer custom resource and the TigeraStatus for 'apiserver' are in the Ready state
532- func (r * ReconcileAPIServer ) canCleanupLegacyNamespace (ctx context.Context , logger logr.Logger ) bool {
533- const (
534- newNamespace = "calico-system"
535- oldNamespace = "tigera-system"
536- deploymentName = "tigera-apiserver"
537- )
526+ func (r * ReconcileAPIServer ) canCleanupLegacyNamespace (ctx context.Context , variant operatorv1.ProductVariant , logger logr.Logger ) bool {
527+
528+ newNamespace := "calico-system"
529+ oldNamespace := "tigera-system"
530+ deploymentName := "tigera-apiserver"
531+
532+ if variant == operatorv1 .Calico {
533+ oldNamespace = "calico-apiserver"
534+ deploymentName = "calico-apiserver"
535+ }
538536
539537 // Fetch the new API server deployment in calico-system
540538 newDeploy := & appsv1.Deployment {}
0 commit comments