Skip to content

Commit

Permalink
Rename terminationProtection to deletionProtection
Browse files Browse the repository at this point in the history
  • Loading branch information
roivaz committed May 21, 2024
1 parent 80284c8 commit bf22d4d
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/backend_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/echoapi_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
echoapiDefaultNLBLoadBalancer defaultNLBLoadBalancerSpec = defaultNLBLoadBalancerSpec{
ProxyProtocol: util.Pointer(true),
CrossZoneLoadBalancingEnabled: util.Pointer(true),
TerminationProtection: util.Pointer(false),
DeletionProtection: util.Pointer(false),
}
)

Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions bundle/manifests/saas-operator.clusterserviceversion.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bundle/manifests/saas.3scale.net_backends.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions bundle/manifests/saas.3scale.net_echoapis.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/crd/bases/saas.3scale.net_backends.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions config/crd/bases/saas.3scale.net_echoapis.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions config/manifests/bases/saas-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion controllers/backend_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/echoapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/resource_builders/service/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"] = "*"
Expand All @@ -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")
Expand Down

0 comments on commit bf22d4d

Please sign in to comment.