From 2ea579378262fb6c9b12c9531ec951e31d6da059 Mon Sep 17 00:00:00 2001 From: Kenichi Omichi Date: Tue, 23 Feb 2021 10:00:03 -0800 Subject: [PATCH] Replace KUBE_MASTERS with KUBE_CONTROL_HOSTS (#7257) This replaces KUBE_MASTERS with KUBE_CONTROL_HOSTS because of [1]: ``` The Kubernetes project is moving away from wording that is considered offensive. A new working group WG Naming was created to track this work, and the word "master" was declared as offensive. A proposal was formalized for replacing the word "master" with "control plane". This means it should be removed from source code, documentation, and user-facing configuration from Kubernetes and its sub-projects. ``` [1]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-cluster-lifecycle/kubeadm/2067-rename-master-label-taint/README.md#motivation --- contrib/inventory_builder/inventory.py | 17 ++++++++++------- .../inventory_builder/tests/test_inventory.py | 8 ++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/contrib/inventory_builder/inventory.py b/contrib/inventory_builder/inventory.py index 0563bda74..66d618474 100644 --- a/contrib/inventory_builder/inventory.py +++ b/contrib/inventory_builder/inventory.py @@ -63,7 +63,9 @@ def get_var_as_bool(name, default): CONFIG_FILE = os.environ.get("CONFIG_FILE", "./inventory/sample/hosts.yaml") -KUBE_MASTERS = int(os.environ.get("KUBE_MASTERS", 2)) +# Remove the reference of KUBE_MASTERS after some deprecation cycles. +KUBE_CONTROL_HOSTS = int(os.environ.get("KUBE_CONTROL_HOSTS", + os.environ.get("KUBE_MASTERS", 2))) # Reconfigures cluster distribution at scale SCALE_THRESHOLD = int(os.environ.get("SCALE_THRESHOLD", 50)) MASSIVE_SCALE_THRESHOLD = int(os.environ.get("MASSIVE_SCALE_THRESHOLD", 200)) @@ -102,10 +104,11 @@ class KubesprayInventory(object): etcd_hosts_count = 3 if len(self.hosts.keys()) >= 3 else 1 self.set_etcd(list(self.hosts.keys())[:etcd_hosts_count]) if len(self.hosts) >= SCALE_THRESHOLD: - self.set_kube_master(list(self.hosts.keys())[ - etcd_hosts_count:(etcd_hosts_count + KUBE_MASTERS)]) + self.set_kube_control_plane(list(self.hosts.keys())[ + etcd_hosts_count:(etcd_hosts_count + KUBE_CONTROL_HOSTS)]) else: - self.set_kube_master(list(self.hosts.keys())[:KUBE_MASTERS]) + self.set_kube_control_plane( + list(self.hosts.keys())[:KUBE_CONTROL_HOSTS]) self.set_kube_node(self.hosts.keys()) if len(self.hosts) >= SCALE_THRESHOLD: self.set_calico_rr(list(self.hosts.keys())[:etcd_hosts_count]) @@ -294,7 +297,7 @@ class KubesprayInventory(object): else: self.yaml_config['all']['children'][group]['hosts'][host] = None # noqa - def set_kube_master(self, hosts): + def set_kube_control_plane(self, hosts): for host in hosts: self.add_host_to_group('kube-master', host) @@ -402,9 +405,9 @@ Configurable env vars: DEBUG Enable debug printing. Default: True CONFIG_FILE File to write config to Default: ./inventory/sample/hosts.yaml HOST_PREFIX Host prefix for generated hosts. Default: node -KUBE_MASTERS Set the number of kube-masters. Default: 2 +KUBE_CONTROL_HOSTS Set the number of kube-control-planes. Default: 2 SCALE_THRESHOLD Separate ETCD role if # of nodes >= 50 -MASSIVE_SCALE_THRESHOLD Separate K8s master and ETCD if # of nodes >= 200 +MASSIVE_SCALE_THRESHOLD Separate K8s control-plane and ETCD if # of nodes >= 200 ''' # noqa print(help_text) diff --git a/contrib/inventory_builder/tests/test_inventory.py b/contrib/inventory_builder/tests/test_inventory.py index d76bb5474..afcbe7500 100644 --- a/contrib/inventory_builder/tests/test_inventory.py +++ b/contrib/inventory_builder/tests/test_inventory.py @@ -222,11 +222,11 @@ class TestInventory(unittest.TestCase): self.inv.yaml_config['all']['children'][group]['hosts'].get(host), None) - def test_set_kube_master(self): + def test_set_kube_control_plane(self): group = 'kube-master' host = 'node1' - self.inv.set_kube_master([host]) + self.inv.set_kube_control_plane([host]) self.assertIn( host, self.inv.yaml_config['all']['children'][group]['hosts']) @@ -275,7 +275,7 @@ class TestInventory(unittest.TestCase): self.inv.set_all(hosts) self.inv.set_etcd(list(hosts.keys())[0:3]) - self.inv.set_kube_master(list(hosts.keys())[0:2]) + self.inv.set_kube_control_plane(list(hosts.keys())[0:2]) self.inv.set_kube_node(hosts.keys()) for h in range(3): self.assertFalse( @@ -291,7 +291,7 @@ class TestInventory(unittest.TestCase): self.inv.set_all(hosts) self.inv.set_etcd(list(hosts.keys())[0:3]) - self.inv.set_kube_master(list(hosts.keys())[3:5]) + self.inv.set_kube_control_plane(list(hosts.keys())[3:5]) self.inv.set_kube_node(hosts.keys()) for h in range(5): self.assertFalse(