Skip to content

Commit

Permalink
Add subnets field to IngressClassParams (kubernetes-sigs#2945)
Browse files Browse the repository at this point in the history
* Add subnets field to IngressClassParams

* Add validating webhook for SubnetSpecs

* Update documentation

* make crds

* Update Helm chart
  • Loading branch information
johngmyers authored and Timothy-Dougherty committed Nov 9, 2023
1 parent 81afb9c commit 3842977
Show file tree
Hide file tree
Showing 17 changed files with 1,272 additions and 250 deletions.
23 changes: 23 additions & 0 deletions apis/elbv2/v1beta1/ingressclassparams_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,25 @@ const (
LoadBalancerSchemeInternetFacing LoadBalancerScheme = "internet-facing"
)

// SubnetID specifies a subnet ID.
// +kubebuilder:validation:Pattern=subnet-[0-9a-f]+
type SubnetID string

// SubnetSelector selects one or more existing subnets.
type SubnetSelector struct {
// IDs specify the resource IDs of subnets. Exactly one of this or `tags` must be specified.
// +kubebuilder:validation:MinItems=1
// +optional
IDs []SubnetID `json:"ids,omitempty"`

// Tags specifies subnets in the load balancer's VPC where each
// tag specified in the map key contains one of the values in the corresponding
// value list.
// Exactly one of this or `ids` must be specified.
// +optional
Tags map[string][]string `json:"tags,omitempty"`
}

// IngressGroup defines IngressGroup configuration.
type IngressGroup struct {
// Name is the name of IngressGroup.
Expand Down Expand Up @@ -80,6 +99,10 @@ type IngressClassParamsSpec struct {
// +optional
Scheme *LoadBalancerScheme `json:"scheme,omitempty"`

// Subnets defines the subnets for all Ingresses that belong to IngressClass with this IngressClassParams.
// +optional
Subnets *SubnetSelector `json:"subnets,omitempty"`

// IPAddressType defines the ip address type for all Ingresses that belong to IngressClass with this IngressClassParams.
// +optional
IPAddressType *IPAddressType `json:"ipAddressType,omitempty"`
Expand Down
40 changes: 40 additions & 0 deletions apis/elbv2/v1beta1/zz_generated.deepcopy.go

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

24 changes: 24 additions & 0 deletions config/crd/bases/elbv2.k8s.aws_ingressclassparams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,30 @@ spec:
- internal
- internet-facing
type: string
subnets:
description: Subnets defines the subnets for all Ingresses that belong
to IngressClass with this IngressClassParams.
properties:
ids:
description: IDs specify the resource IDs of subnets. Exactly
one of this or `tags` must be specified.
items:
description: SubnetID specifies a subnet ID.
pattern: subnet-[0-9a-f]+
type: string
minItems: 1
type: array
tags:
additionalProperties:
items:
type: string
type: array
description: Tags specifies subnets in the load balancer's VPC
where each tag specified in the map key contains one of the
values in the corresponding value list. Exactly one of this
or `ids` must be specified.
type: object
type: object
tags:
description: Tags defines list of Tags on AWS resources provisioned
for Ingresses that belong to IngressClass with this IngressClassParams.
Expand Down
21 changes: 21 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
Expand Down Expand Up @@ -50,6 +51,26 @@ metadata:
creationTimestamp: null
name: webhook
webhooks:
- admissionReviewVersions:
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-elbv2-k8s-aws-v1beta1-ingressclassparams
failurePolicy: Fail
name: vingressclassparams.elbv2.k8s.aws
rules:
- apiGroups:
- elbv2.k8s.aws
apiVersions:
- v1beta1
operations:
- CREATE
- UPDATE
resources:
- ingressclassparams
sideEffects: None
- admissionReviewVersions:
- v1beta1
clientConfig:
Expand Down
18 changes: 18 additions & 0 deletions docs/guide/ingress/ingress_class.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ Cluster administrators can use the `scheme` field to restrict the scheme for all
1. If `scheme` specified, all Ingresses with this IngressClass will have the specified scheme.
2. If `scheme` un-specified, Ingresses with this IngressClass can continue to use `alb.ingress.kubernetes.io/scheme annotation` to specify scheme.

#### spec.subnets

Cluster administrators can use the optional `subnets` field to specify the subnets for the load balancers that belong to this IngressClass.
They may specify either `ids` or `tags`. If the field is specified, LBC will ignore the `alb.ingress.kubernetes.io/subnets annotation` annotation.

##### spec.subnets.ids

If `ids` is specified, it must be a set of at least one resource ID of a subnet in the VPC. No two subnets may be in the same availability zone.

##### spec.subnets.tags

If `tags` is specified, it is a map of tag filters. The filters will match subnets in the VPC for which
each listed tag key is present and has one of the corresponding tag values.

Unless the `SubnetsClusterTagCheck` feature gate is disabled, subnets without a cluster tag and with the cluster tag for another cluster will be excluded.

Within any given availability zone, subnets with a cluster tag will be chosen over subnets without, then the subnet with the lowest-sorting resource ID will be chosen.

#### spec.ipAddressType

`ipAddressType` is an optional setting. The available options are `ipv4` or `dualstack`.
Expand Down
Loading

0 comments on commit 3842977

Please sign in to comment.