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 194ad66
Show file tree
Hide file tree
Showing 32 changed files with 129,543 additions and 14 deletions.
@@ -0,0 +1,53 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Ingress"
crdName: ingresses.config.openshift.io
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
networkLoadBalancer:
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
networkLoadBalancer:
eipAllocations:
- eipalloc-12345
- eipalloc-12346
expected: |
apiVersion: config.openshift.io/v1
kind: Ingress
metadata:
name: cluster
spec:
loadBalancer:
platform:
type: AWS
aws:
type: NLB
networkLoadBalancer:
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.networkLoadBalancer)",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:"networkLoadBalancer,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
Expand Up @@ -133,6 +133,24 @@ spec:
description: aws contains settings specific to the Amazon
Web Services infrastructure provider.
properties:
networkLoadBalancer:
description: networkLoadBalancerParameters holds configuration
parameters for an AWS network load balancer. Present
only if type is NLB.
properties:
eipAllocations:
description: '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'
items:
type: string
type: array
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 +171,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.networkLoadBalancer)
type:
description: type is the underlying infrastructure provider
for the cluster. Allowed values are "AWS", "Azure", "BareMetal",
Expand Down
28 changes: 27 additions & 1 deletion config/v1/zz_generated.deepcopy.go

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

3 changes: 2 additions & 1 deletion config/v1/zz_generated.featuregated-crd-manifests.yaml
Expand Up @@ -323,7 +323,8 @@ ingresses.config.openshift.io:
CRDName: ingresses.config.openshift.io
Capability: ""
Category: ""
FeatureGates: []
FeatureGates:
- SetEIPForNLBIngressController
FilenameOperatorName: config-operator
FilenameOperatorOrdering: "01"
FilenameRunLevel: "0000_10"
Expand Down
Expand Up @@ -134,6 +134,24 @@ spec:
description: aws contains settings specific to the Amazon
Web Services infrastructure provider.
properties:
networkLoadBalancer:
description: networkLoadBalancerParameters holds configuration
parameters for an AWS network load balancer. Present
only if type is NLB.
properties:
eipAllocations:
description: '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'
items:
type: string
type: array
type: object
type:
description: "type allows user to set a load balancer
type. When this field is set the default ingresscontroller
Expand All @@ -154,6 +172,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.networkLoadBalancer)
type:
description: type is the underlying infrastructure provider
for the cluster. Allowed values are "AWS", "Azure", "BareMetal",
Expand Down

0 comments on commit 194ad66

Please sign in to comment.