diff --git a/test/infrastructure/docker/internal/docker/loadbalancer.go b/test/infrastructure/docker/internal/docker/loadbalancer.go index 1508ad4dfc02..2126165b1c1b 100644 --- a/test/infrastructure/docker/internal/docker/loadbalancer.go +++ b/test/infrastructure/docker/internal/docker/loadbalancer.go @@ -29,7 +29,7 @@ import ( "sigs.k8s.io/cluster-api/test/infrastructure/container" infrav1 "sigs.k8s.io/cluster-api/test/infrastructure/docker/api/v1beta1" "sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/docker/types" - "sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/third_party/forked/loadbalancer" + "sigs.k8s.io/cluster-api/test/infrastructure/docker/internal/loadbalancer" ) type lbCreator interface { diff --git a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/config.go b/test/infrastructure/docker/internal/loadbalancer/config.go similarity index 72% rename from test/infrastructure/docker/internal/third_party/forked/loadbalancer/config.go rename to test/infrastructure/docker/internal/loadbalancer/config.go index feb6ce2e9f4a..a17280f86bba 100644 --- a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/config.go +++ b/test/infrastructure/docker/internal/loadbalancer/config.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -23,19 +23,25 @@ import ( "sigs.k8s.io/kind/pkg/errors" ) -// ConfigData is supplied to the loadbalancer config template +// ConfigData is supplied to the loadbalancer config template. type ConfigData struct { ControlPlanePort int BackendServers map[string]string IPv6 bool } -// DefaultConfigTemplate is the loadbalancer config template -const DefaultConfigTemplate = `# generated by kind +// ConfigTemplate is the loadbalancer config template. +const ConfigTemplate = `# generated by kind global log /dev/log local0 log /dev/log local1 notice daemon + # limit memory usage to approximately 18 MB + maxconn 100000 + +resolvers docker + nameserver dns 127.0.0.11:53 + defaults log global mode tcp @@ -44,24 +50,27 @@ defaults timeout connect 5000 timeout client 50000 timeout server 50000 + # allow to boot despite dns don't resolve backends + default-server init-addr none + frontend control-plane bind *:{{ .ControlPlanePort }} {{ if .IPv6 -}} bind :::{{ .ControlPlanePort }}; {{- end }} default_backend kube-apiservers + backend kube-apiservers option httpchk GET /healthz # TODO: we should be verifying (!) {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }} check check-ssl verify none + server {{ $server }} {{ $address }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} ` -// Config returns a kubeadm config generated from config data, in particular -// the kubernetes version +// Config generates the loadbalancer config from the ConfigTemplate and ConfigData. func Config(data *ConfigData) (config string, err error) { - t, err := template.New("loadbalancer-config").Parse(DefaultConfigTemplate) + t, err := template.New("loadbalancer-config").Parse(ConfigTemplate) if err != nil { return "", errors.Wrap(err, "failed to parse config template") } diff --git a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/const.go b/test/infrastructure/docker/internal/loadbalancer/const.go similarity index 56% rename from test/infrastructure/docker/internal/third_party/forked/loadbalancer/const.go rename to test/infrastructure/docker/internal/loadbalancer/const.go index 82bf261452ad..924536b6f433 100644 --- a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/const.go +++ b/test/infrastructure/docker/internal/loadbalancer/const.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,14 +16,16 @@ limitations under the License. package loadbalancer -// Image defines the loadbalancer image name -const Image = "haproxy" +const ( + // Image is the loadbalancer image name. + Image = "haproxy" -// DefaultImageRepository defines the loadbalancer image repository -const DefaultImageRepository = "kindest" + // DefaultImageRepository is the loadbalancer image repository. + DefaultImageRepository = "kindest" -// DefaultImageTag defines the loadbalancer image tag -const DefaultImageTag = "v20210715-a6da3463" + // DefaultImageTag is the loadbalancer image tag. + DefaultImageTag = "v20230227-d46f45b6" -// ConfigPath defines the path to the config file in the image -const ConfigPath = "/usr/local/etc/haproxy/haproxy.cfg" + // ConfigPath is the path to the config file in the image. + ConfigPath = "/usr/local/etc/haproxy/haproxy.cfg" +) diff --git a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/doc.go b/test/infrastructure/docker/internal/loadbalancer/doc.go similarity index 73% rename from test/infrastructure/docker/internal/third_party/forked/loadbalancer/doc.go rename to test/infrastructure/docker/internal/loadbalancer/doc.go index 6e53f388d302..d9317b49d21c 100644 --- a/test/infrastructure/docker/internal/third_party/forked/loadbalancer/doc.go +++ b/test/infrastructure/docker/internal/loadbalancer/doc.go @@ -1,5 +1,5 @@ /* -Copyright 2019 The Kubernetes Authors. +Copyright 2023 The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); 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 limitations under the License. */ -// Package loadbalancer contains external loadbalancer related constants and configuration +// Package loadbalancer contains external loadbalancer related constants and configuration. +// 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 package loadbalancer diff --git a/test/infrastructure/docker/internal/third_party/forked/README.md b/test/infrastructure/docker/internal/third_party/forked/README.md deleted file mode 100644 index 8c73ad41fcbc..000000000000 --- a/test/infrastructure/docker/internal/third_party/forked/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# loadbalancer - -Repo: https://github.com/kubernetes-sigs/kind -Path: https://github.com/kubernetes-sigs/kind/tree/v0.7.0/pkg/cluster/internal/loadbalancer - -Tag: `v0.7.0` -