Skip to content

Commit 25b648f

Browse files
authored
Merge pull request #1969 from M00nF1sh/lb_attrs
enforce LB attributes according to IngressClassParams
2 parents 1dc9d88 + 1c4dc21 commit 25b648f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

config/webhook/manifests.v1beta1.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ webhooks:
7474
namespace: system
7575
path: /validate-networking-v1beta1-ingress
7676
failurePolicy: Fail
77+
matchPolicy: Equivalent
7778
name: vingress.elbv2.k8s.aws
7879
rules:
7980
- apiGroups:

pkg/ingress/model_build_load_balancer.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func (t *defaultModelBuildTask) buildLoadBalancerName(_ context.Context, scheme
117117
func (t *defaultModelBuildTask) buildLoadBalancerScheme(_ context.Context) (elbv2model.LoadBalancerScheme, error) {
118118
explicitSchemes := sets.String{}
119119
for _, member := range t.ingGroup.Members {
120+
if member.IngClassConfig.IngClassParams != nil && member.IngClassConfig.IngClassParams.Spec.Scheme != nil {
121+
scheme := string(*member.IngClassConfig.IngClassParams.Spec.Scheme)
122+
explicitSchemes.Insert(scheme)
123+
continue
124+
}
120125
rawSchema := ""
121126
if exists := t.annotationParser.ParseStringAnnotation(annotations.IngressSuffixScheme, &rawSchema, member.Ing.Annotations); !exists {
122127
continue
@@ -144,6 +149,11 @@ func (t *defaultModelBuildTask) buildLoadBalancerScheme(_ context.Context) (elbv
144149
func (t *defaultModelBuildTask) buildLoadBalancerIPAddressType(_ context.Context) (elbv2model.IPAddressType, error) {
145150
explicitIPAddressTypes := sets.NewString()
146151
for _, member := range t.ingGroup.Members {
152+
if member.IngClassConfig.IngClassParams != nil && member.IngClassConfig.IngClassParams.Spec.IPAddressType != nil {
153+
ipAddressType := string(*member.IngClassConfig.IngClassParams.Spec.IPAddressType)
154+
explicitIPAddressTypes.Insert(ipAddressType)
155+
continue
156+
}
147157
rawIPAddressType := ""
148158
if exists := t.annotationParser.ParseStringAnnotation(annotations.IngressSuffixIPAddressType, &rawIPAddressType, member.Ing.Annotations); !exists {
149159
continue

webhooks/networking/ingress_validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (v *ingressValidator) checkIngressClassUsage(ctx context.Context, ing *netw
144144
return nil
145145
}
146146

147-
// +kubebuilder:webhook:path=/validate-networking-v1beta1-ingress,mutating=false,failurePolicy=fail,groups=networking.k8s.io,resources=ingresses,verbs=create;update,versions=v1beta1,name=vingress.elbv2.k8s.aws,sideEffects=None,webhookVersions=v1beta1
147+
// +kubebuilder:webhook:path=/validate-networking-v1beta1-ingress,mutating=false,failurePolicy=fail,groups=networking.k8s.io,resources=ingresses,verbs=create;update,versions=v1beta1,name=vingress.elbv2.k8s.aws,sideEffects=None,webhookVersions=v1beta1,matchPolicy=Equivalent
148148

149149
func (v *ingressValidator) SetupWithManager(mgr ctrl.Manager) {
150150
mgr.GetWebhookServer().Register(apiPathValidateNetworkingIngress, webhook.ValidatingWebhookForValidator(v))

0 commit comments

Comments
 (0)