Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated backport of #3307: Change loadbalancer type for HCP deployments #3335

Merged
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
13 changes: 11 additions & 2 deletions api/v1alpha1/submariner_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ type SubmarinerSpec struct {
// Enable NAT between clusters.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Enable NAT"
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
NatEnabled bool `json:"natEnabled"`

NatEnabled bool `json:"natEnabled"`
AirGappedDeployment bool `json:"airGappedDeployment,omitempty"`

// Is the cluster a hosted cluster.
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Hosted Cluster"
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
HostedCluster bool `json:"hostedCluster,omitempty"`

// Enable automatic Load Balancer in front of the gateways.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Enable Load Balancer"
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
Expand Down Expand Up @@ -228,6 +232,11 @@ type SubmarinerStatus struct {

AirGappedDeployment bool `json:"airGappedDeployment,omitempty"`

// Is the cluster a hosted cluster.
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Hosted Cluster"
// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
HostedCluster bool `json:"hostedCluster,omitempty"`

ColorCodes string `json:"colorCodes,omitempty"`

// The current cluster ID.
Expand Down
2 changes: 2 additions & 0 deletions config/crd/bases/submariner.io_submariners.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ spec:
haltOnCertificateError:
description: Halt on certificate error (so the pod gets restarted).
type: boolean
hostedCluster:
type: boolean
imageOverrides:
additionalProperties:
type: string
Expand Down
8 changes: 7 additions & 1 deletion controllers/submariner/loadbalancer_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ func (r *Reconciler) getOCPPlatformType(ctx context.Context) (string, error) {
}

func newLoadBalancerService(instance *v1alpha1.Submariner, platformTypeOCP string) *corev1.Service {
externalTrafficPolicy := corev1.ServiceExternalTrafficPolicyTypeLocal

var svcAnnotations map[string]string

switch platformTypeOCP {
Expand All @@ -104,6 +106,10 @@ func newLoadBalancerService(instance *v1alpha1.Submariner, platformTypeOCP strin
"service.kubernetes.io/ibm-load-balancer-cloud-provider-ip-type": "public",
"service.kubernetes.io/ibm-load-balancer-cloud-provider-vpc-health-check-protocol": "http",
}
case string(configv1.KubevirtPlatformType):
if instance.Spec.HostedCluster {
externalTrafficPolicy = corev1.ServiceExternalTrafficPolicyTypeCluster
}
default:
svcAnnotations = map[string]string{}
}
Expand All @@ -115,7 +121,7 @@ func newLoadBalancerService(instance *v1alpha1.Submariner, platformTypeOCP strin
Annotations: svcAnnotations,
},
Spec: corev1.ServiceSpec{
ExternalTrafficPolicy: corev1.ServiceExternalTrafficPolicyTypeLocal,
ExternalTrafficPolicy: externalTrafficPolicy,
Type: corev1.ServiceTypeLoadBalancer,
Selector: map[string]string{
// Traffic is directed to the active gateway
Expand Down
1 change: 1 addition & 0 deletions controllers/submariner/submariner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
instance.Status.Version = instance.Spec.Version
instance.Status.NatEnabled = instance.Spec.NatEnabled
instance.Status.AirGappedDeployment = instance.Spec.AirGappedDeployment
instance.Status.HostedCluster = instance.Spec.HostedCluster
instance.Status.ColorCodes = instance.Spec.ColorCodes
instance.Status.ClusterID = instance.Spec.ClusterID
instance.Status.GlobalCIDR = instance.Spec.GlobalCIDR
Expand Down
2 changes: 2 additions & 0 deletions controllers/submariner/submariner_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func testReconciliation() {
BeforeEach(func() {
t.submariner.Spec.NatEnabled = true
t.submariner.Spec.AirGappedDeployment = true
t.submariner.Spec.HostedCluster = true
})

It("should populate general Submariner resource Status fields from the Spec", func(ctx SpecContext) {
Expand All @@ -86,6 +87,7 @@ func testReconciliation() {
updated := t.getSubmariner(ctx)
Expect(updated.Status.NatEnabled).To(BeTrue())
Expect(updated.Status.AirGappedDeployment).To(BeTrue())
Expect(updated.Status.HostedCluster).To(BeTrue())
Expect(updated.Status.ClusterID).To(Equal(t.submariner.Spec.ClusterID))
Expect(updated.Status.GlobalCIDR).To(Equal(t.submariner.Spec.GlobalCIDR))
Expect(updated.Status.NetworkPlugin).To(Equal(t.clusterNetwork.NetworkPlugin))
Expand Down
6 changes: 6 additions & 0 deletions pkg/embeddedyamls/yamls.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ spec:
haltOnCertificateError:
description: Halt on certificate error (so the pod gets restarted).
type: boolean
hostedCluster:
description: Is the cluster a hosted cluster.
type: boolean
imageOverrides:
additionalProperties:
type: string
Expand Down Expand Up @@ -840,6 +843,9 @@ spec:
required:
- mismatchedContainerImages
type: object
hostedCluster:
description: Is the cluster a hosted cluster.
type: boolean
loadBalancerStatus:
description: The status of the load balancer DaemonSet.
properties:
Expand Down
Loading