Skip to content

Commit

Permalink
NE-1516: Adds a field in the cluster ingress config object and Ingres…
Browse files Browse the repository at this point in the history
…s Controller to set EIP via installer and Ingress Controller

`config/v1/types_ingress.go` - Adds an API field `eip-allocations` in the cluster ingress config object whose value is set by the installer using install-config.yaml
`operator/v1/types_ingress.go` - Adds an API field `eip-allocations` in the Ingress Controller CR object using which the Ingress Operator scales an Ingress Controller
with service type balancer whose annotation `service.beta.kubernetes.io/aws-load-balancer-eip-allocations` is set by the value of the field `eip-allocations` of the Ingress Controller.
Epic: https://issues.redhat.com/browse/NE-1274
Story: https://issues.redhat.com/browse/NE-1516
  • Loading branch information
miheer committed Apr 25, 2024
1 parent bec9f0f commit 7be17c6
Show file tree
Hide file tree
Showing 36 changed files with 13,523 additions and 24 deletions.
@@ -0,0 +1,54 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Ingress"
crdName: ingresses.config.openshift.io
featureGate: SetEIPForNLBIngressController
tests:
onCreate:
- name: Should not allow to set NLB parameters when LBType is Classic.
initial: |
apiVersion: config.openshift.io/v1
kind: Ingress
metadata:
name: cluster
spec:
loadBalancer:
platform:
type: AWS
aws:
type: Classic
nlbParameters:
eipAllocations:
- eipalloc-12345
- eipalloc-12346
expectedError: "Network load balancer parameters are allowed only when load balancer type is NLB."
- name: Should allow to set NLB parameters when LBType is NLB.
initial: |
apiVersion: config.openshift.io/v1
kind: Ingress
metadata:
name: cluster
spec:
loadBalancer:
platform:
type: AWS
aws:
type: NLB
nlbParameters:
eipAllocations:
- eipalloc-12345
- eipalloc-12346
expected: |
apiVersion: config.openshift.io/v1
kind: Ingress
metadata:
name: cluster
spec:
loadBalancer:
platform:
type: AWS
aws:
type: NLB
nlbParameters:
eipAllocations:
- eipalloc-12345
- eipalloc-12346
21 changes: 21 additions & 0 deletions config/v1/types_ingress.go
Expand Up @@ -130,6 +130,7 @@ type LoadBalancer struct {

// AWSIngressSpec holds the desired state of the Ingress for Amazon Web Services infrastructure provider.
// This only includes fields that can be modified in the cluster.
// +kubebuilder:validation:XValidation:rule="self.type != 'Classic' || !has(self.nlbParameters)",message="Network load balancer parameters are allowed only when load balancer type is NLB."
// +union
type AWSIngressSpec struct {
// type allows user to set a load balancer type.
Expand All @@ -151,8 +152,28 @@ type AWSIngressSpec struct {
// +kubebuilder:validation:Enum:=NLB;Classic
// +kubebuilder:validation:Required
Type AWSLBType `json:"type,omitempty"`

// networkLoadBalancerParameters holds configuration parameters for an AWS
// network load balancer. Present only if type is NLB.
//
// +optional
NetworkLoadBalancerParameters *AWSNetworkLoadBalancerParameters `json:"nlbParameters,omitempty"`
}

// AWSNetworkLoadBalancerParameters holds configuration parameters for an
// AWS Network load balancer. For Example: Setting AWS EIPs https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
type AWSNetworkLoadBalancerParameters struct {
// You can assign Elastic IP addresses to the Network Load Balancer by adding the following annotation.
// The number of Allocation IDs must match the number of subnets that are used for the load balancer.
// service.beta.kubernetes.io/aws-load-balancer-eip-allocations: eipalloc-xxxxxxxxxxxxxxxxx,eipalloc-yyyyyyyyyyyyyyyyy
// https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
// https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.7/guide/service/annotations/#eip-allocations
// +openshift:enable:FeatureGate=SetEIPForNLBIngressController
EIPAllocations []EIPAllocations `json:"eipAllocations"`
}

type EIPAllocations string

type AWSLBType string

const (
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -6,6 +6,7 @@ metadata:
api.openshift.io/merged-by-featuregates: "true"
include.release.openshift.io/ibm-cloud-managed: "true"
include.release.openshift.io/self-managed-high-availability: "true"
release.openshift.io/feature-set: Default
name: ingresses.config.openshift.io
spec:
group: config.openshift.io
Expand Down Expand Up @@ -133,6 +134,11 @@ spec:
description: aws contains settings specific to the Amazon
Web Services infrastructure provider.
properties:
nlbParameters:
description: networkLoadBalancerParameters holds configuration
parameters for an AWS network load balancer. Present
only if type is NLB.
type: object
type:
description: "type allows user to set a load balancer
type. When this field is set the default ingresscontroller
Expand All @@ -153,6 +159,10 @@ spec:
required:
- type
type: object
x-kubernetes-validations:
- message: Network load balancer parameters are allowed only
when load balancer type is NLB.
rule: self.type != 'Classic' || !has(self.nlbParameters)
type:
description: type is the underlying infrastructure provider
for the cluster. Allowed values are "AWS", "Azure", "BareMetal",
Expand Down

0 comments on commit 7be17c6

Please sign in to comment.