From 24c70b8715ca3966d0d9b64e77da42c96c3cda7f Mon Sep 17 00:00:00 2001 From: Danil-Grigorev Date: Sun, 15 Dec 2024 16:29:15 +0100 Subject: [PATCH] Update LB templates to use new structure - Breakind change: https://github.com/kubernetes-sigs/cluster-api/pull/11430 Signed-off-by: Danil-Grigorev --- controlplane/internal/controllers/scale.go | 3 +++ examples/docker/air-gapped/rke2-sample.yaml | 14 ++++++++------ examples/docker/cis-profile/rke2-sample.yaml | 14 ++++++++------ .../clusterclass/clusterclass-quick-start.yaml | 14 ++++++++------ .../docker/disable-components/rke2-sample.yaml | 14 ++++++++------ examples/docker/enable-multus/rke2-sample.yaml | 14 ++++++++------ examples/docker/kube-vip/rke2-sample.yaml | 14 ++++++++------ .../docker/online-default/cluster-template.yaml | 14 ++++++++------ examples/docker/priv-registries/rke2-sample.yaml | 14 ++++++++------ pkg/rke2/workload_cluster.go | 4 ++++ .../cluster-template-docker-updated.yaml | 14 ++++++++------ .../infrastructure/cluster-template-docker.yaml | 14 ++++++++------ .../clusterclass-template-docker.yaml | 14 ++++++++------ 13 files changed, 95 insertions(+), 66 deletions(-) diff --git a/controlplane/internal/controllers/scale.go b/controlplane/internal/controllers/scale.go index c0a2fa9e..5f27516b 100644 --- a/controlplane/internal/controllers/scale.go +++ b/controlplane/internal/controllers/scale.go @@ -17,6 +17,7 @@ limitations under the License. package controllers import ( + "cmp" "context" "encoding/json" "strings" @@ -324,6 +325,8 @@ func (r *RKE2ControlPlaneReconciler) cloneConfigsAndGenerateMachine( UID: rcp.UID, } + rcp.Spec.InfrastructureRef.Namespace = cmp.Or(rcp.Spec.InfrastructureRef.Namespace, rcp.Namespace) + // Clone the infrastructure template infraRef, err := external.CreateFromTemplate(ctx, &external.CreateFromTemplateInput{ Client: r.Client, diff --git a/examples/docker/air-gapped/rke2-sample.yaml b/examples/docker/air-gapped/rke2-sample.yaml index 40f0fa74..10e08872 100644 --- a/examples/docker/air-gapped/rke2-sample.yaml +++ b/examples/docker/air-gapped/rke2-sample.yaml @@ -149,10 +149,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -165,8 +167,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -179,6 +181,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} diff --git a/examples/docker/cis-profile/rke2-sample.yaml b/examples/docker/cis-profile/rke2-sample.yaml index ab4a6d45..67f01fca 100644 --- a/examples/docker/cis-profile/rke2-sample.yaml +++ b/examples/docker/cis-profile/rke2-sample.yaml @@ -139,10 +139,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -155,8 +157,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -169,6 +171,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} diff --git a/examples/docker/clusterclass/clusterclass-quick-start.yaml b/examples/docker/clusterclass/clusterclass-quick-start.yaml index ab665f11..a4ed05ea 100644 --- a/examples/docker/clusterclass/clusterclass-quick-start.yaml +++ b/examples/docker/clusterclass/clusterclass-quick-start.yaml @@ -94,10 +94,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -110,8 +112,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -124,8 +126,8 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} kind: ConfigMap metadata: diff --git a/examples/docker/disable-components/rke2-sample.yaml b/examples/docker/disable-components/rke2-sample.yaml index 708d3844..3d0871f6 100644 --- a/examples/docker/disable-components/rke2-sample.yaml +++ b/examples/docker/disable-components/rke2-sample.yaml @@ -141,10 +141,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -157,8 +159,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -171,6 +173,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} diff --git a/examples/docker/enable-multus/rke2-sample.yaml b/examples/docker/enable-multus/rke2-sample.yaml index ecc3628d..2b0e427b 100644 --- a/examples/docker/enable-multus/rke2-sample.yaml +++ b/examples/docker/enable-multus/rke2-sample.yaml @@ -140,10 +140,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -156,8 +158,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -170,6 +172,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} diff --git a/examples/docker/kube-vip/rke2-sample.yaml b/examples/docker/kube-vip/rke2-sample.yaml index a491607d..348bf23c 100644 --- a/examples/docker/kube-vip/rke2-sample.yaml +++ b/examples/docker/kube-vip/rke2-sample.yaml @@ -181,10 +181,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -197,8 +199,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -211,6 +213,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} diff --git a/examples/docker/online-default/cluster-template.yaml b/examples/docker/online-default/cluster-template.yaml index e48918ed..07ea6541 100644 --- a/examples/docker/online-default/cluster-template.yaml +++ b/examples/docker/online-default/cluster-template.yaml @@ -150,10 +150,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -166,8 +168,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -180,6 +182,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} \ No newline at end of file diff --git a/examples/docker/priv-registries/rke2-sample.yaml b/examples/docker/priv-registries/rke2-sample.yaml index 5cc2e8d8..a9611b81 100644 --- a/examples/docker/priv-registries/rke2-sample.yaml +++ b/examples/docker/priv-registries/rke2-sample.yaml @@ -193,10 +193,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -209,8 +211,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -223,6 +225,6 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} \ No newline at end of file diff --git a/pkg/rke2/workload_cluster.go b/pkg/rke2/workload_cluster.go index 01422dc5..5a878bae 100644 --- a/pkg/rke2/workload_cluster.go +++ b/pkg/rke2/workload_cluster.go @@ -131,6 +131,10 @@ func (m *Management) NewWorkload( return nil, err } + if clientKey == nil { + return nil, fmt.Errorf("client key is not populated yet, requeuing") + } + clientCert, err = generateClientCert(etcdKeyPair.Cert, etcdKeyPair.Key, clientKey) if err != nil { return nil, err diff --git a/test/e2e/data/infrastructure/cluster-template-docker-updated.yaml b/test/e2e/data/infrastructure/cluster-template-docker-updated.yaml index 6057cf91..226962a0 100644 --- a/test/e2e/data/infrastructure/cluster-template-docker-updated.yaml +++ b/test/e2e/data/infrastructure/cluster-template-docker-updated.yaml @@ -25,10 +25,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -41,8 +43,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -55,8 +57,8 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} kind: ConfigMap metadata: diff --git a/test/e2e/data/infrastructure/cluster-template-docker.yaml b/test/e2e/data/infrastructure/cluster-template-docker.yaml index 2545c916..f3ad6028 100644 --- a/test/e2e/data/infrastructure/cluster-template-docker.yaml +++ b/test/e2e/data/infrastructure/cluster-template-docker.yaml @@ -25,10 +25,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -41,8 +43,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -55,8 +57,8 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} kind: ConfigMap metadata: diff --git a/test/e2e/data/infrastructure/clusterclass-template-docker.yaml b/test/e2e/data/infrastructure/clusterclass-template-docker.yaml index 96e11eca..7cda1df9 100644 --- a/test/e2e/data/infrastructure/clusterclass-template-docker.yaml +++ b/test/e2e/data/infrastructure/clusterclass-template-docker.yaml @@ -95,10 +95,12 @@ data: default-server init-addr none frontend stats + mode http bind *:8404 stats enable - stats uri / - stats refresh 10s + stats uri /stats + stats refresh 1s + stats admin if TRUE frontend control-plane bind *:{{ .FrontendControlPlanePort }} @@ -111,8 +113,8 @@ data: option httpchk GET /healthz http-check expect status 401 # TODO: we should be verifying (!) - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ JoinHostPort $address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ JoinHostPort $backend.Address $.BackendControlPlanePort }} check check-ssl verify none resolvers docker resolve-prefer {{ if $.IPv6 -}} ipv6 {{- else -}} ipv4 {{- end }} {{- end}} frontend rke2-join @@ -125,8 +127,8 @@ data: backend rke2-servers option httpchk GET /v1-rke2/readyz http-check expect status 403 - {{range $server, $address := .BackendServers}} - server {{ $server }} {{ $address }}:9345 check check-ssl verify none + {{range $server, $backend := .BackendServers}} + server {{ $server }} {{ $backend.Address }}:9345 check check-ssl verify none {{- end}} kind: ConfigMap metadata: