From bf22d4d4073526c700f24a9a96fb69f2c7b79304 Mon Sep 17 00:00:00 2001 From: Roi Vazquez Date: Tue, 21 May 2024 12:21:02 +0200 Subject: [PATCH] Rename terminationProtection to deletionProtection --- api/v1alpha1/backend_types.go | 2 +- api/v1alpha1/common_types.go | 8 ++++---- api/v1alpha1/echoapi_types.go | 2 +- api/v1alpha1/zz_generated.deepcopy.go | 4 ++-- .../saas-operator.clusterserviceversion.yaml | 14 +++++++------- bundle/manifests/saas.3scale.net_backends.yaml | 6 +++--- bundle/manifests/saas.3scale.net_echoapis.yaml | 6 +++--- config/crd/bases/saas.3scale.net_backends.yaml | 6 +++--- config/crd/bases/saas.3scale.net_echoapis.yaml | 6 +++--- .../bases/saas-operator.clusterserviceversion.yaml | 12 ++++++------ controllers/backend_controller.go | 2 +- controllers/echoapi_controller.go | 2 +- pkg/resource_builders/service/util.go | 8 +++++--- 13 files changed, 40 insertions(+), 38 deletions(-) diff --git a/api/v1alpha1/backend_types.go b/api/v1alpha1/backend_types.go index cd696354..a1e51ad2 100644 --- a/api/v1alpha1/backend_types.go +++ b/api/v1alpha1/backend_types.go @@ -48,7 +48,7 @@ var ( backendDefaultListenerNLBLoadBalancer defaultNLBLoadBalancerSpec = defaultNLBLoadBalancerSpec{ ProxyProtocol: util.Pointer(true), CrossZoneLoadBalancingEnabled: util.Pointer(true), - TerminationProtection: util.Pointer(false), + DeletionProtection: util.Pointer(false), } backendDefaultListenerReplicas int32 = 2 backendDefaultListenerResources defaultResourceRequirementsSpec = defaultResourceRequirementsSpec{ diff --git a/api/v1alpha1/common_types.go b/api/v1alpha1/common_types.go index aa340edb..8962d62e 100644 --- a/api/v1alpha1/common_types.go +++ b/api/v1alpha1/common_types.go @@ -251,21 +251,21 @@ type NLBLoadBalancerSpec struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // +optional LoadBalancerName *string `json:"loadBalancerName,omitempty"` - // Termination protection setting + // Deletion protection setting // +operator-sdk:csv:customresourcedefinitions:type=spec // +optional - TerminationProtection *bool `json:"terminationProtection,omitempty"` + DeletionProtection *bool `json:"deletionProtection,omitempty"` } type defaultNLBLoadBalancerSpec struct { - CrossZoneLoadBalancingEnabled, ProxyProtocol, TerminationProtection *bool + CrossZoneLoadBalancingEnabled, ProxyProtocol, DeletionProtection *bool } // Default sets default values for any value not specifically set in the NLBLoadBalancerSpec struct func (spec *NLBLoadBalancerSpec) Default(def defaultNLBLoadBalancerSpec) { spec.ProxyProtocol = boolOrDefault(spec.ProxyProtocol, def.ProxyProtocol) spec.CrossZoneLoadBalancingEnabled = boolOrDefault(spec.CrossZoneLoadBalancingEnabled, def.CrossZoneLoadBalancingEnabled) - spec.TerminationProtection = boolOrDefault(spec.TerminationProtection, def.TerminationProtection) + spec.DeletionProtection = boolOrDefault(spec.DeletionProtection, def.DeletionProtection) } // IsDeactivated true if the field is set with the deactivated value (empty struct) diff --git a/api/v1alpha1/echoapi_types.go b/api/v1alpha1/echoapi_types.go index 0b562e4c..4a2a3269 100644 --- a/api/v1alpha1/echoapi_types.go +++ b/api/v1alpha1/echoapi_types.go @@ -68,7 +68,7 @@ var ( echoapiDefaultNLBLoadBalancer defaultNLBLoadBalancerSpec = defaultNLBLoadBalancerSpec{ ProxyProtocol: util.Pointer(true), CrossZoneLoadBalancingEnabled: util.Pointer(true), - TerminationProtection: util.Pointer(false), + DeletionProtection: util.Pointer(false), } ) diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index b50f39eb..58e02d45 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1963,8 +1963,8 @@ func (in *NLBLoadBalancerSpec) DeepCopyInto(out *NLBLoadBalancerSpec) { *out = new(string) **out = **in } - if in.TerminationProtection != nil { - in, out := &in.TerminationProtection, &out.TerminationProtection + if in.DeletionProtection != nil { + in, out := &in.DeletionProtection, &out.DeletionProtection *out = new(bool) **out = **in } diff --git a/bundle/manifests/saas-operator.clusterserviceversion.yaml b/bundle/manifests/saas-operator.clusterserviceversion.yaml index 82005331..37c9a8c7 100644 --- a/bundle/manifests/saas-operator.clusterserviceversion.yaml +++ b/bundle/manifests/saas-operator.clusterserviceversion.yaml @@ -598,7 +598,7 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/3scale/saas-operator - createdAt: "2024-05-15T15:40:19Z" + createdAt: "2024-05-21T10:17:51Z" description: |- The 3scale SaaS Operator creates and maintains a SaaS-ready deployment of the Red Hat 3scale API Management on OpenShift. @@ -1599,6 +1599,9 @@ spec: - description: Enables/disables cross zone load balancing displayName: Cross Zone Load Balancing Enabled path: listener.loadBalancer.crossZoneLoadBalancingEnabled + - description: Deletion protection setting + displayName: Deletion Protection + path: listener.loadBalancer.deletionProtection - description: The list of optional Elastic IPs allocations displayName: EIPAllocations path: listener.loadBalancer.eipAllocations @@ -1608,9 +1611,6 @@ spec: - description: Enables/disbles use of proxy protocol in the load balancer displayName: Proxy Protocol path: listener.loadBalancer.proxyProtocol - - description: Termination protection setting - displayName: Termination Protection - path: listener.loadBalancer.terminationProtection - description: Marin3r configures the Marin3r sidecars for the component displayName: Marin3r path: listener.marin3r @@ -2182,6 +2182,9 @@ spec: - description: Enables/disables cross zone load balancing displayName: Cross Zone Load Balancing Enabled path: loadBalancer.crossZoneLoadBalancingEnabled + - description: Deletion protection setting + displayName: Deletion Protection + path: loadBalancer.deletionProtection - description: The list of optional Elastic IPs allocations displayName: EIPAllocations path: loadBalancer.eipAllocations @@ -2191,9 +2194,6 @@ spec: - description: Enables/disbles use of proxy protocol in the load balancer displayName: Proxy Protocol path: loadBalancer.proxyProtocol - - description: Termination protection setting - displayName: Termination Protection - path: loadBalancer.terminationProtection - description: Marin3r configures the Marin3r sidecars for the component displayName: Marin3r path: marin3r diff --git a/bundle/manifests/saas.3scale.net_backends.yaml b/bundle/manifests/saas.3scale.net_backends.yaml index 61d3bfed..d9cabdb4 100644 --- a/bundle/manifests/saas.3scale.net_backends.yaml +++ b/bundle/manifests/saas.3scale.net_backends.yaml @@ -822,6 +822,9 @@ spec: crossZoneLoadBalancingEnabled: description: Enables/disables cross zone load balancing type: boolean + deletionProtection: + description: Deletion protection setting + type: boolean eipAllocations: description: The list of optional Elastic IPs allocations items: @@ -834,9 +837,6 @@ spec: description: Enables/disbles use of proxy protocol in the load balancer type: boolean - terminationProtection: - description: Termination protection setting - type: boolean type: object marin3r: description: Marin3r configures the Marin3r sidecars for the component diff --git a/bundle/manifests/saas.3scale.net_echoapis.yaml b/bundle/manifests/saas.3scale.net_echoapis.yaml index 7eeca343..06c10e33 100644 --- a/bundle/manifests/saas.3scale.net_echoapis.yaml +++ b/bundle/manifests/saas.3scale.net_echoapis.yaml @@ -243,6 +243,9 @@ spec: crossZoneLoadBalancingEnabled: description: Enables/disables cross zone load balancing type: boolean + deletionProtection: + description: Deletion protection setting + type: boolean eipAllocations: description: The list of optional Elastic IPs allocations items: @@ -255,9 +258,6 @@ spec: description: Enables/disbles use of proxy protocol in the load balancer type: boolean - terminationProtection: - description: Termination protection setting - type: boolean type: object marin3r: description: Marin3r configures the Marin3r sidecars for the component diff --git a/config/crd/bases/saas.3scale.net_backends.yaml b/config/crd/bases/saas.3scale.net_backends.yaml index fcd7a602..93b18dc3 100644 --- a/config/crd/bases/saas.3scale.net_backends.yaml +++ b/config/crd/bases/saas.3scale.net_backends.yaml @@ -823,6 +823,9 @@ spec: crossZoneLoadBalancingEnabled: description: Enables/disables cross zone load balancing type: boolean + deletionProtection: + description: Deletion protection setting + type: boolean eipAllocations: description: The list of optional Elastic IPs allocations items: @@ -835,9 +838,6 @@ spec: description: Enables/disbles use of proxy protocol in the load balancer type: boolean - terminationProtection: - description: Termination protection setting - type: boolean type: object marin3r: description: Marin3r configures the Marin3r sidecars for the component diff --git a/config/crd/bases/saas.3scale.net_echoapis.yaml b/config/crd/bases/saas.3scale.net_echoapis.yaml index 8d2922f0..b6e8988b 100644 --- a/config/crd/bases/saas.3scale.net_echoapis.yaml +++ b/config/crd/bases/saas.3scale.net_echoapis.yaml @@ -244,6 +244,9 @@ spec: crossZoneLoadBalancingEnabled: description: Enables/disables cross zone load balancing type: boolean + deletionProtection: + description: Deletion protection setting + type: boolean eipAllocations: description: The list of optional Elastic IPs allocations items: @@ -256,9 +259,6 @@ spec: description: Enables/disbles use of proxy protocol in the load balancer type: boolean - terminationProtection: - description: Termination protection setting - type: boolean type: object marin3r: description: Marin3r configures the Marin3r sidecars for the component diff --git a/config/manifests/bases/saas-operator.clusterserviceversion.yaml b/config/manifests/bases/saas-operator.clusterserviceversion.yaml index 154807a9..de571f7d 100644 --- a/config/manifests/bases/saas-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/saas-operator.clusterserviceversion.yaml @@ -1140,6 +1140,9 @@ spec: - description: Enables/disables cross zone load balancing displayName: Cross Zone Load Balancing Enabled path: listener.loadBalancer.crossZoneLoadBalancingEnabled + - description: Deletion protection setting + displayName: Deletion Protection + path: listener.loadBalancer.deletionProtection - description: The list of optional Elastic IPs allocations displayName: EIPAllocations path: listener.loadBalancer.eipAllocations @@ -1149,9 +1152,6 @@ spec: - description: Enables/disbles use of proxy protocol in the load balancer displayName: Proxy Protocol path: listener.loadBalancer.proxyProtocol - - description: Termination protection setting - displayName: Termination Protection - path: listener.loadBalancer.terminationProtection - description: Marin3r configures the Marin3r sidecars for the component displayName: Marin3r path: listener.marin3r @@ -1723,6 +1723,9 @@ spec: - description: Enables/disables cross zone load balancing displayName: Cross Zone Load Balancing Enabled path: loadBalancer.crossZoneLoadBalancingEnabled + - description: Deletion protection setting + displayName: Deletion Protection + path: loadBalancer.deletionProtection - description: The list of optional Elastic IPs allocations displayName: EIPAllocations path: loadBalancer.eipAllocations @@ -1732,9 +1735,6 @@ spec: - description: Enables/disbles use of proxy protocol in the load balancer displayName: Proxy Protocol path: loadBalancer.proxyProtocol - - description: Termination protection setting - displayName: Termination Protection - path: loadBalancer.terminationProtection - description: Marin3r configures the Marin3r sidecars for the component displayName: Marin3r path: marin3r diff --git a/controllers/backend_controller.go b/controllers/backend_controller.go index bc1b2cc9..f0518e66 100644 --- a/controllers/backend_controller.go +++ b/controllers/backend_controller.go @@ -76,7 +76,7 @@ func (r *BackendReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct *instance.Spec.Listener.LoadBalancer.LoadBalancerName != nlbName { patch := client.MergeFrom(instance.DeepCopy()) instance.Spec.Listener.LoadBalancer.LoadBalancerName = &nlbName - instance.Spec.Listener.LoadBalancer.TerminationProtection = util.Pointer(true) + instance.Spec.Listener.LoadBalancer.DeletionProtection = util.Pointer(true) if err := r.Client.Patch(ctx, instance, patch); err != nil { return ctrl.Result{}, err } diff --git a/controllers/echoapi_controller.go b/controllers/echoapi_controller.go index afeb4010..fcd19000 100644 --- a/controllers/echoapi_controller.go +++ b/controllers/echoapi_controller.go @@ -70,7 +70,7 @@ func (r *EchoAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct *instance.Spec.LoadBalancer.LoadBalancerName != nlbName { patch := client.MergeFrom(instance.DeepCopy()) instance.Spec.LoadBalancer.LoadBalancerName = &nlbName - instance.Spec.LoadBalancer.TerminationProtection = util.Pointer(true) + instance.Spec.LoadBalancer.DeletionProtection = util.Pointer(true) if err := r.Client.Patch(ctx, instance, patch); err != nil { return ctrl.Result{}, err } diff --git a/pkg/resource_builders/service/util.go b/pkg/resource_builders/service/util.go index 34d19ef9..19c29f2f 100644 --- a/pkg/resource_builders/service/util.go +++ b/pkg/resource_builders/service/util.go @@ -33,8 +33,10 @@ func ELBServiceAnnotations(cfg saasv1alpha1.LoadBalancerSpec, hostnames []string // NLBServiceAnnotations returns annotations for services exposed through AWS Network LoadBalancers func NLBServiceAnnotations(cfg saasv1alpha1.NLBLoadBalancerSpec, hostnames []string) map[string]string { annotations := map[string]string{ - "external-dns.alpha.kubernetes.io/hostname": strings.Join(hostnames, ","), - "service.beta.kubernetes.io/aws-load-balancer-type": "external", + "external-dns.alpha.kubernetes.io/hostname": strings.Join(hostnames, ","), + "service.beta.kubernetes.io/aws-load-balancer-type": "external", + "service.beta.kubernetes.io/aws-load-balancer-nlb-target-type": "instance", + "service.beta.kubernetes.io/aws-load-balancer-scheme": "internet-facing", } if *cfg.ProxyProtocol { annotations["service.beta.kubernetes.io/aws-load-balancer-proxy-protocol"] = "*" @@ -52,7 +54,7 @@ func NLBServiceAnnotations(cfg saasv1alpha1.NLBLoadBalancerSpec, hostnames []str } else { attributes = append(attributes, "load_balancing.cross_zone.enabled=false") } - if *cfg.TerminationProtection { + if *cfg.DeletionProtection { attributes = append(attributes, "deletion_protection.enabled=true") } else { attributes = append(attributes, "deletion_protection.enabled=false")