From ab0ee3257c591369f4a38ad917c90eacc369ffe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20L=C3=BCke?= Date: Wed, 7 Apr 2021 15:51:45 +0200 Subject: [PATCH 1/2] baremetal: sets hostname controller_names/worker_names Sets the hostname from the `-worker-` which is set when `set_standard_hostname` is true, to `controller_names` for controllers and `worker_names` for workers The hostname change got introduced by #1477 where it was set from the template variable `domain_name` coming from var.controller_domains[count.index] --- .../flatcar-linux/kubernetes/controller.tf | 15 +++++++++++++-- .../bare-metal/flatcar-linux/kubernetes/worker.tf | 15 +++++++++++++-- pkg/assets/generated_assets.go | 8 ++++---- 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/controller.tf b/assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/controller.tf index 1b56b20d7..305103c21 100644 --- a/assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/controller.tf +++ b/assets/terraform-modules/bare-metal/flatcar-linux/kubernetes/controller.tf @@ -10,6 +10,17 @@ module "controller" { apiserver = format("%s.%s", var.cluster_name, var.k8s_domain_name) ca_cert = module.bootkube.ca_cert kubelet_labels = lookup(var.node_specific_labels, var.controller_names[count.index], {}) - clc_snippets = lookup(var.clc_snippets, var.controller_names[count.index], []) - set_standard_hostname = true + set_standard_hostname = false + clc_snippets = concat(lookup(var.clc_snippets, var.controller_names[count.index], []), [ + < Date: Thu, 17 Jun 2021 16:45:21 +0530 Subject: [PATCH 2/2] test: update expected node names in test Signed-off-by: Imran Pochi --- .../kubernetes/baremetal_kubelet_labels_test.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/components/kubernetes/baremetal_kubelet_labels_test.go b/test/components/kubernetes/baremetal_kubelet_labels_test.go index 9166ac860..a41278ddc 100644 --- a/test/components/kubernetes/baremetal_kubelet_labels_test.go +++ b/test/components/kubernetes/baremetal_kubelet_labels_test.go @@ -34,17 +34,17 @@ func Test_Baremetal_NodeSpecificLabels(t *testing.T) { // The labels include the labels common to every worker node derived from `labels` and // labels specific to the node. nodeNamesAndExpectedLabelsInCI := map[string]map[string]string{ - "mercury-controller-0": { + "node1": { "testkey": "testvalue", "node.kubernetes.io/master": "", "node.kubernetes.io/controller": "true", }, - "mercury-worker-0": { + "node2": { "ingressnode": "yes", "testing.io": "yes", "roleofnode": "testing", }, - "mercury-worker-1": { + "node3": { "storagenode": "yes", "testing.io": "yes", "roleofnode": "testing", @@ -72,11 +72,15 @@ func Test_Baremetal_NodeSpecificLabels(t *testing.T) { t.Errorf("expected node with name %q not found: %v", nodeName, err) } + if len(nodes.Items) != 1 { + t.Fatalf("expected a single node, got %d", len(nodes.Items)) + } + // Currently we assume that the labels added to the node in CI are unique to the worker node. // This check confirms that the expected set of labels as per CI configuration were // present on the correct node. - if len(nodes.Items) == 1 && nodes.Items[0].Name != nodeName { - t.Errorf("expected node %q to have the labels %s", nodes.Items[0].Name, labels) + if nodes.Items[0].Name != nodeName { + t.Fatalf("expected node %q but found %q to have the labels %s", nodeName, nodes.Items[0].Name, labels) } } }