Skip to content

Commit 9232ca7

Browse files
authored
Merge pull request #8246 from killianmuldoon/pr-docker-lb
🌱 Make load balancer first-party package in CAPD
2 parents 714048e + f78afa6 commit 9232ca7

File tree

6 files changed

+35
-28
lines changed

6 files changed

+35
-28
lines changed

docs/book/src/developer/providers/v1.3-to-v1.4.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ maintainers of providers and consumers of our Go API.
7070
For more information, please see: https://github.com/kubernetes/enhancements/issues/2845
7171
- A new `KCPRemediationSpec` test has been added providing better test coverage for KCP remediation most common use cases. As a consequence `MachineRemediationSpec` now only tests remediation of
7272
worker machines (NOTE: we plan to improve this test as well in a future iteration).
73-
73+
- Package `test/infrastructure/docker/internal/third_party/forked/loadbalancer` has been moved to `test/infrastructure/docker/internal/loadbalancer` to allow it to diverge from the upstream Kind package.
74+
-
7475
### Suggested changes for providers
7576

7677
- Providers should add an explicit security context to their controllers deployment, see [#7831](https://github.com/kubernetes-sigs/cluster-api/pull/7831) for reference.

test/infrastructure/docker/internal/docker/loadbalancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929
"sigs.k8s.io/cluster-api/test/infrastructure/container"
3030
infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1"
3131
"sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/docker/types"
32-
"sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/third_party/forked/loadbalancer"
32+
"sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/loadbalancer"
3333
)
3434

3535
type lbCreator interface {

test/infrastructure/docker/internal/third_party/forked/loadbalancer/config.go renamed to test/infrastructure/docker/internal/loadbalancer/config.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 The Kubernetes Authors.
2+
Copyright 2023 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -23,19 +23,26 @@ import (
2323
"sigs.k8s.io/kind/pkg/errors"
2424
)
2525

26-
// ConfigData is supplied to the loadbalancer config template
26+
// ConfigData is supplied to the loadbalancer config template.
2727
type ConfigData struct {
2828
ControlPlanePort int
2929
BackendServers map[string]string
3030
IPv6 bool
3131
}
3232

33-
// DefaultConfigTemplate is the loadbalancer config template
34-
const DefaultConfigTemplate = `# generated by kind
33+
// ConfigTemplate is the loadbalancer config template.
34+
const ConfigTemplate = `# generated by kind
3535
global
3636
log /dev/log local0
3737
log /dev/log local1 notice
3838
daemon
39+
# limit memory usage to approximately 18 MB
40+
# (see https://github.com/kubernetes-sigs/kind/pull/3115)
41+
maxconn 100000
42+
43+
resolvers docker
44+
nameserver dns 127.0.0.11:53
45+
3946
defaults
4047
log global
4148
mode tcp
@@ -44,24 +51,27 @@ defaults
4451
timeout connect 5000
4552
timeout client 50000
4653
timeout server 50000
54+
# allow to boot despite dns don't resolve backends
55+
default-server init-addr none
56+
4757
frontend control-plane
4858
bind *:{{ .ControlPlanePort }}
4959
{{ if .IPv6 -}}
5060
bind :::{{ .ControlPlanePort }};
5161
{{- end }}
5262
default_backend kube-apiservers
63+
5364
backend kube-apiservers
5465
option httpchk GET /healthz
5566
# TODO: we should be verifying (!)
5667
{{range $server, $address := .BackendServers}}
57-
server {{ $server }} {{ $address }} check check-ssl verify none
68+
server {{ $server }} {{ $address }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }}
5869
{{- end}}
5970
`
6071

61-
// Config returns a kubeadm config generated from config data, in particular
62-
// the kubernetes version
72+
// Config generates the loadbalancer config from the ConfigTemplate and ConfigData.
6373
func Config(data *ConfigData) (config string, err error) {
64-
t, err := template.New("loadbalancer-config").Parse(DefaultConfigTemplate)
74+
t, err := template.New("loadbalancer-config").Parse(ConfigTemplate)
6575
if err != nil {
6676
return "", errors.Wrap(err, "failed to parse config template")
6777
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 The Kubernetes Authors.
2+
Copyright 2023 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,14 +16,16 @@ limitations under the License.
1616

1717
package loadbalancer
1818

19-
// Image defines the loadbalancer image name
20-
const Image = "haproxy"
19+
const (
20+
// Image is the loadbalancer image name.
21+
Image = "haproxy"
2122

22-
// DefaultImageRepository defines the loadbalancer image repository
23-
const DefaultImageRepository = "kindest"
23+
// DefaultImageRepository is the loadbalancer image repository.
24+
DefaultImageRepository = "kindest"
2425

25-
// DefaultImageTag defines the loadbalancer image tag
26-
const DefaultImageTag = "v20210715-a6da3463"
26+
// DefaultImageTag is the loadbalancer image tag.
27+
DefaultImageTag = "v20230227-d46f45b6"
2728

28-
// ConfigPath defines the path to the config file in the image
29-
const ConfigPath = "/usr/local/etc/haproxy/haproxy.cfg"
29+
// ConfigPath is the path to the config file in the image.
30+
ConfigPath = "/usr/local/etc/haproxy/haproxy.cfg"
31+
)

test/infrastructure/docker/internal/third_party/forked/loadbalancer/doc.go renamed to test/infrastructure/docker/internal/loadbalancer/doc.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2019 The Kubernetes Authors.
2+
Copyright 2023 The Kubernetes Authors.
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -14,5 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package loadbalancer contains external loadbalancer related constants and configuration
17+
// Package loadbalancer contains external loadbalancer related constants and configuration.
18+
// This package was originally forked from the kind load balancer at https://github.com/kubernetes-sigs/kind/tree/v0.7.0/pkg/cluster/internal/loadbalancer
1819
package loadbalancer

test/infrastructure/docker/internal/third_party/forked/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)