Skip to content

Commit e10fd8f

Browse files
committed
feat: ALB Ingress allow http10 support
Closes:. commit_hash:8e20454fd8a53b4d80f1668a2901b47a0ae704dc
1 parent 68113f6 commit e10fd8f

File tree

9 files changed

+124
-12
lines changed

9 files changed

+124
-12
lines changed

.changes/v0.2.26.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## v0.2.26 - October 13, 2025
2+
### Added
3+
* ingress.alb.yc.io/allow-http10 annotation

.mapping.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
".changes/v0.2.23.md":"opensource/yc-alb-ingress-controller/.changes/v0.2.23.md",
1414
".changes/v0.2.24.md":"opensource/yc-alb-ingress-controller/.changes/v0.2.24.md",
1515
".changes/v0.2.25.md":"opensource/yc-alb-ingress-controller/.changes/v0.2.25.md",
16+
".changes/v0.2.26.md":"opensource/yc-alb-ingress-controller/.changes/v0.2.26.md",
1617
".changie.yaml":"opensource/yc-alb-ingress-controller/.changie.yaml",
1718
".env.example":"opensource/yc-alb-ingress-controller/.env.example",
1819
".gitignore":"opensource/yc-alb-ingress-controller/.gitignore",

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Changelog
22

33

4+
## v0.2.26 - October 13, 2025
5+
### Added
6+
* ingress.alb.yc.io/allow-http10 annotation
7+
48
## v0.2.25 - August 29, 2025
59
### Fixed
610
* GRPCBackendGroup creation triggers services reconciliation now

pkg/builders/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ type ListenerOptions struct {
1313
Addresses []*apploadbalancer.Address
1414
}
1515

16+
type HandlerOptions struct {
17+
AllowHTTP10 bool
18+
}
19+
1620
type Options struct {
1721
BalancerOptions
1822
ListenerOptions
23+
HandlerOptions
1924
}

pkg/builders/resolvers.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ func (r *Resolvers) AutoScalePolicy() *AutoScalePolicyResolver {
5050
return &AutoScalePolicyResolver{}
5151
}
5252

53+
func (r *Resolvers) AllowHTTP10() *AllowHTTP10Resolver {
54+
return &AllowHTTP10Resolver{}
55+
}
56+
5357
func (r *Resolvers) RouteOpts() RouteOptsResolver {
5458
return RouteOptsResolver{}
5559
}
@@ -482,6 +486,44 @@ func (r *AutoScalePolicyResolver) Result() *apploadbalancer.AutoScalePolicy {
482486
return p
483487
}
484488

489+
type AllowHTTP10Resolver struct {
490+
AllowHTTP10 *bool
491+
}
492+
493+
func (r *AllowHTTP10Resolver) Resolve(allowHTTP10 string) error {
494+
if allowHTTP10 == "" {
495+
return nil
496+
}
497+
498+
newAllowHTTP10 := false
499+
switch allowHTTP10 {
500+
case "true":
501+
newAllowHTTP10 = true
502+
case "false":
503+
newAllowHTTP10 = false
504+
default:
505+
return fmt.Errorf("unsupported value for allow http10: %s", allowHTTP10)
506+
}
507+
508+
if r.AllowHTTP10 == nil {
509+
r.AllowHTTP10 = &newAllowHTTP10
510+
return nil
511+
}
512+
513+
if *r.AllowHTTP10 != newAllowHTTP10 {
514+
return fmt.Errorf("different values provided for allow http10: %t, %t", *r.AllowHTTP10, newAllowHTTP10)
515+
}
516+
517+
return nil
518+
}
519+
520+
func (r *AllowHTTP10Resolver) Result() bool {
521+
if r.AllowHTTP10 == nil {
522+
return false
523+
}
524+
return *r.AllowHTTP10
525+
}
526+
485527
type RouteOptsResolver struct{}
486528

487529
func (r RouteOptsResolver) Resolve(

pkg/builders/snimatches.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type HandlerBuilder struct {
1313
names *metadata.Names
1414
tag string
1515

16+
opts HandlerOptions
1617
// keep the order in which hosts are fed to this builder so that map randomization shouldn't cause updates
1718
hostsOrder []string
1819
// collect certificates per host and ensure no duplicated hosts
@@ -21,6 +22,10 @@ type HandlerBuilder struct {
2122
hostAndCerts map[hostAndCert]struct{}
2223
}
2324

25+
func (b *HandlerBuilder) AddHandlerOptions(opts HandlerOptions) {
26+
b.opts = opts
27+
}
28+
2429
func (b *HandlerBuilder) AddCertificate(hosts []string, certID string) {
2530
for _, host := range hosts {
2631
certsForHost, ok := b.certs[host]
@@ -43,7 +48,7 @@ func (b *HandlerBuilder) Build() []*apploadbalancer.SniMatch {
4348
sniName := b.names.SNIMatchForHost(b.tag, host)
4449
sniHandler := &apploadbalancer.TlsHandler{
4550
Handler: &apploadbalancer.TlsHandler_HttpHandler{
46-
HttpHandler: &apploadbalancer.HttpHandler{},
51+
HttpHandler: BuildHTTPHandler(b.opts),
4752
},
4853
CertificateIds: certificateIDs,
4954
}
@@ -55,3 +60,11 @@ func (b *HandlerBuilder) Build() []*apploadbalancer.SniMatch {
5560
}
5661
return ret
5762
}
63+
64+
func BuildHTTPHandler(opts HandlerOptions) *apploadbalancer.HttpHandler {
65+
handler := &apploadbalancer.HttpHandler{}
66+
if opts.AllowHTTP10 {
67+
handler.ProtocolSettings = &apploadbalancer.HttpHandler_AllowHttp10{AllowHttp10: true}
68+
}
69+
return handler
70+
}

pkg/builders/snimatches_test.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616

1717
func TestSNIMatches(t *testing.T) {
1818
testData := []struct {
19-
desc string
20-
tlsItems []*v1.IngressTLS
21-
exp []*apploadbalancer.SniMatch
19+
desc string
20+
handlerOpts HandlerOptions
21+
tlsItems []*v1.IngressTLS
22+
exp []*apploadbalancer.SniMatch
2223
}{
2324
{
2425
desc: "OK",
@@ -65,6 +66,30 @@ func TestSNIMatches(t *testing.T) {
6566
},
6667
},
6768
},
69+
{
70+
desc: "OK with allow http1.0",
71+
tlsItems: []*v1.IngressTLS{
72+
{
73+
Hosts: []string{"example1.com"},
74+
SecretName: "XXX1",
75+
},
76+
},
77+
handlerOpts: HandlerOptions{AllowHTTP10: true},
78+
exp: []*apploadbalancer.SniMatch{
79+
{
80+
Name: "sni-1954a6fc86a55a010c3c8e48f0603e956a6054ec",
81+
ServerNames: []string{"example1.com"},
82+
Handler: &apploadbalancer.TlsHandler{
83+
Handler: &apploadbalancer.TlsHandler_HttpHandler{
84+
HttpHandler: &apploadbalancer.HttpHandler{
85+
ProtocolSettings: &apploadbalancer.HttpHandler_AllowHttp10{AllowHttp10: true},
86+
},
87+
},
88+
CertificateIds: []string{"XXX1"},
89+
},
90+
},
91+
},
92+
},
6893
{
6994
desc: "duplicated host+cert pair",
7095
tlsItems: []*v1.IngressTLS{
@@ -123,6 +148,7 @@ func TestSNIMatches(t *testing.T) {
123148
f := NewFactory("my-folder", "", &metadata.Names{ClusterID: "my-cluster"}, &metadata.Labels{ClusterID: "my-cluster"}, nil, tgRepo)
124149

125150
b := f.HandlerBuilder(tag)
151+
b.AddHandlerOptions(tc.handlerOpts)
126152
for _, tls := range tc.tlsItems {
127153
b.AddCertificate(tls.Hosts, tls.SecretName)
128154
}

pkg/k8s/annotations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const (
2323
InternalIPv4Address = prefix + "/internal-ipv4-address"
2424
InternalALBSubnet = prefix + "/internal-alb-subnet"
2525

26+
AllowHTTP10 = prefix + "/allow-http10"
27+
2628
RequestTimeout = prefix + "/request-timeout"
2729
IdleTimeout = prefix + "/idle-timeout"
2830
PrefixRewrite = prefix + "/prefix-rewrite"

pkg/reconcile/ingressgroup_engine_builder.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func NewDefaultDataBuilder(
5656
}
5757

5858
// TODO: включать/выключать трафик в зоне - ?
59-
// TODO: httpHandler -> Http2Options, AllowHttp10 ?
59+
// TODO: httpHandler -> Http2Options ?
6060
func (d *DefaultEngineBuilder) Build(ctx context.Context, g *k8s.IngressGroup, settings *v1alpha1.IngressGroupSettings) (*IngressGroupEngine, error) {
6161
if len(g.Items) == 0 {
6262
return d.newIngressGroupEngine(nil), nil
@@ -75,6 +75,10 @@ func (d *DefaultEngineBuilder) Build(ctx context.Context, g *k8s.IngressGroup, s
7575
if err != nil {
7676
return nil, fmt.Errorf("failed to build auto scale policy: %w", err)
7777
}
78+
allowHTTP10, err := d.allowHTTP10(g)
79+
if err != nil {
80+
return nil, fmt.Errorf("failed to build allow http10: %w", err)
81+
}
7882

7983
opts := builders.Options{
8084
BalancerOptions: builders.BalancerOptions{
@@ -86,15 +90,18 @@ func (d *DefaultEngineBuilder) Build(ctx context.Context, g *k8s.IngressGroup, s
8690
ListenerOptions: builders.ListenerOptions{
8791
Addresses: addresses,
8892
},
93+
HandlerOptions: builders.HandlerOptions{
94+
AllowHTTP10: allowHTTP10,
95+
},
8996
}
9097

9198
b := builders.Data{}
9299
b.HTTPRouter, b.TLSRouter, err = d.buildVirtualHosts(g)
93100
if err != nil {
94101
return nil, fmt.Errorf("failed to build virtual hosts: %w", err)
95102
}
96-
b.Handler = d.buildHTTPHandler(g)
97-
b.SNIMatches, err = d.buildSNIMatches(ctx, g)
103+
b.Handler = builders.BuildHTTPHandler(opts.HandlerOptions)
104+
b.SNIMatches, err = d.buildSNIMatches(ctx, g, opts.HandlerOptions)
98105
if err != nil {
99106
return nil, fmt.Errorf("failed to build sni matches: %w", err)
100107
}
@@ -149,6 +156,17 @@ func (d *DefaultEngineBuilder) autoScalePolicy(g *k8s.IngressGroup) (*apploadbal
149156
return resolver.Result(), nil
150157
}
151158

159+
func (d *DefaultEngineBuilder) allowHTTP10(g *k8s.IngressGroup) (bool, error) {
160+
resolver := d.resolvers.AllowHTTP10()
161+
for _, ing := range g.Items {
162+
err := resolver.Resolve(ing.GetAnnotations()[k8s.AllowHTTP10])
163+
if err != nil {
164+
return false, fmt.Errorf("failed to resolve allow http10: %w", err)
165+
}
166+
}
167+
return resolver.Result(), nil
168+
}
169+
152170
func (d *DefaultEngineBuilder) routeOpts(ing networking.Ingress) (builders.RouteResolveOpts, error) {
153171
r := d.resolvers.RouteOpts()
154172
annotations := ing.GetAnnotations()
@@ -475,8 +493,10 @@ func (d *DefaultEngineBuilder) buildVirtualHosts(g *k8s.IngressGroup) (*builders
475493
return httpVHBuilder.Build(), tlsVHBuilder.Build(), nil
476494
}
477495

478-
func (d *DefaultEngineBuilder) buildSNIMatches(ctx context.Context, g *k8s.IngressGroup) ([]*apploadbalancer.SniMatch, error) {
496+
func (d *DefaultEngineBuilder) buildSNIMatches(ctx context.Context, g *k8s.IngressGroup, opts builders.HandlerOptions) ([]*apploadbalancer.SniMatch, error) {
479497
b := d.factory.HandlerBuilder(g.Tag)
498+
b.AddHandlerOptions(opts)
499+
480500
for _, ing := range g.Items {
481501
for _, tls := range ing.Spec.TLS {
482502
if strings.HasPrefix(tls.SecretName, k8s.CertIDPrefix) {
@@ -506,10 +526,6 @@ func (d *DefaultEngineBuilder) buildSNIMatches(ctx context.Context, g *k8s.Ingre
506526
return b.Build(), nil
507527
}
508528

509-
func (d *DefaultEngineBuilder) buildHTTPHandler(_ *k8s.IngressGroup) *apploadbalancer.HttpHandler {
510-
return &apploadbalancer.HttpHandler{}
511-
}
512-
513529
func (d *DefaultEngineBuilder) buildBalancer(handler *apploadbalancer.HttpHandler, matches []*apploadbalancer.SniMatch, logOpts *apploadbalancer.LogOptions,
514530
tag string, opts builders.Options,
515531
) *apploadbalancer.LoadBalancer {

0 commit comments

Comments
 (0)