From 926a8c909e71ab71c8581c28828ac010929bc6e3 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Wed, 14 Sep 2022 15:46:44 -0500 Subject: [PATCH] PR #107: Co-authored commit to change master naming to control plane. Co-authored-by: ra-rau --- README.md | 24 +++++++++---------- defaults/main.yml | 4 ++-- molecule/default/calico.yml | 6 ++++- molecule/default/converge.yml | 6 ++++- molecule/default/molecule.yml | 2 +- ...ster-setup.yml => control-plane-setup.yml} | 10 ++++---- tasks/main.yml | 10 ++++---- tasks/node-setup.yml | 2 +- 8 files changed, 36 insertions(+), 28 deletions(-) rename tasks/{master-setup.yml => control-plane-setup.yml} (88%) diff --git a/README.md b/README.md index 26a43f0..6e79a3d 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ kubernetes_version_rhel_package: '1.25.0' The minor version of Kubernetes to install. The plain `kubernetes_version` is used to pin an apt package version on Debian, and as the Kubernetes version passed into the `kubeadm init` command (see `kubernetes_version_kubeadm`). The `kubernetes_version_rhel_package` variable must be a specific Kubernetes release, and is used to pin the version on Red Hat / CentOS servers. ```yaml -kubernetes_role: master +kubernetes_role: control_plane ``` -Whether the particular server will serve as a Kubernetes `master` (default) or `node`. The master will have `kubeadm init` run on it to intialize the entire K8s control plane, while `node`s will have `kubeadm join` run on them to join them to the `master`. +Whether the particular server will serve as a Kubernetes `control_plane` (default) or `node`. The control plane will have `kubeadm init` run on it to intialize the entire K8s control plane, while `node`s will have `kubeadm join` run on them to join them to the `control_plane`. ### Variables to configure kubeadm and kubelet with `kubeadm init` through a config file (recommended) @@ -109,10 +109,10 @@ Extra args to pass to the generated `kubeadm join` command during K8s node initi ### Additional variables ```yaml -kubernetes_allow_pods_on_master: true +kubernetes_allow_pods_on_control_plane: true ``` -Whether to remove the taint that denies pods from being deployed to the Kubernetes master. If you have a single-node cluster, this should definitely be `True`. Otherwise, set to `False` if you want a dedicated Kubernetes master which doesn't run any other pods. +Whether to remove the taint that denies pods from being deployed to the Kubernetes control plane. If you have a single-node cluster, this should definitely be `True`. Otherwise, set to `False` if you want a dedicated Kubernetes control plane which doesn't run any other pods. ```yaml kubernetes_pod_network: @@ -137,7 +137,7 @@ kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}'` kubernetes_ignore_preflight_errors: 'all' ``` -Options passed to `kubeadm init` when initializing the Kubernetes master. The `kubernetes_apiserver_advertise_address` defaults to `ansible_default_ipv4.address` if it's left empty. +Options passed to `kubeadm init` when initializing the Kubernetes control plane. The `kubernetes_apiserver_advertise_address` defaults to `ansible_default_ipv4.address` if it's left empty. ```yaml kubernetes_apt_release_channel: main @@ -177,25 +177,25 @@ None. ## Example Playbooks -### Single node (master-only) cluster +### Single node (control-plane-only) cluster ```yaml - hosts: all vars: - kubernetes_allow_pods_on_master: true + kubernetes_allow_pods_on_control_plane: true roles: - geerlingguy.docker - geerlingguy.kubernetes ``` -### Two or more nodes (single master) cluster +### Two or more nodes (single control-plane) cluster -Master inventory vars: +Control plane inventory vars: ```yaml -kubernetes_role: "master" +kubernetes_role: "control_plane" ``` Node(s) inventory vars: @@ -210,14 +210,14 @@ Playbook: - hosts: all vars: - kubernetes_allow_pods_on_master: true + kubernetes_allow_pods_on_control_plane: true roles: - geerlingguy.docker - geerlingguy.kubernetes ``` -Then, log into the Kubernetes master, and run `kubectl get nodes` as root, and you should see a list of all the servers. +Then, log into the Kubernetes control plane, and run `kubectl get nodes` as root, and you should see a list of all the servers. ## License diff --git a/defaults/main.yml b/defaults/main.yml index 2fc763e..a1ca4b1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,14 +12,14 @@ kubernetes_packages: kubernetes_version: '1.25' kubernetes_version_rhel_package: '1.25.0' -kubernetes_role: master +kubernetes_role: control_plane # This is deprecated. Please use kubernetes_config_kubelet_configuration instead. kubernetes_kubelet_extra_args: "" kubernetes_kubeadm_init_extra_opts: "" kubernetes_join_command_extra_opts: "" -kubernetes_allow_pods_on_master: true +kubernetes_allow_pods_on_control_plane: true kubernetes_pod_network: # Flannel CNI. cni: 'flannel' diff --git a/molecule/default/calico.yml b/molecule/default/calico.yml index 1fd035c..b8c9a70 100644 --- a/molecule/default/calico.yml +++ b/molecule/default/calico.yml @@ -9,7 +9,11 @@ cidr: '192.168.0.0/16' # Allow swap in test environments (hard to control in some envs). - kubernetes_kubelet_extra_args: "--fail-swap-on=false --cgroup-driver=systemd" + kubernetes_kubelet_extra_args: >- + --fail-swap-on=false + --cgroup-driver=systemd + --cgroups-per-qos=false + --enforce-node-allocatable="" docker_install_compose: false pre_tasks: diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 46c5610..f89c518 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -5,7 +5,11 @@ vars: # Allow swap in test environments (hard to control in some envs). - kubernetes_kubelet_extra_args: "--fail-swap-on=false --cgroup-driver=systemd" + kubernetes_kubelet_extra_args: >- + --fail-swap-on=false + --cgroup-driver=systemd + --cgroups-per-qos=false + --enforce-node-allocatable="" docker_install_compose: false pre_tasks: diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 3f1b2b5..cc47e45 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -10,7 +10,7 @@ platforms: command: ${MOLECULE_DOCKER_COMMAND:-""} volumes: - /sys/fs/cgroup:/sys/fs/cgroup:ro - - /var/lib/docker + - /var/lib/containerd privileged: true pre_build_image: true provisioner: diff --git a/tasks/master-setup.yml b/tasks/control-plane-setup.yml similarity index 88% rename from tasks/master-setup.yml rename to tasks/control-plane-setup.yml index 49feb78..347e5cc 100644 --- a/tasks/master-setup.yml +++ b/tasks/control-plane-setup.yml @@ -9,7 +9,7 @@ src: "kubeadm-kubelet-config.j2" dest: "{{ kubernetes_kubeadm_kubelet_config_file_path }}" -- name: Initialize Kubernetes master with kubeadm init +- name: Initialize Kubernetes control plane with kubeadm init command: > kubeadm init --config {{ kubernetes_kubeadm_kubelet_config_file_path }} @@ -17,7 +17,7 @@ register: kubeadmin_init when: (not kubernetes_init_stat.stat.exists) and (kubernetes_ignore_preflight_errors is not defined) -- name: Initialize Kubernetes master with kubeadm init and ignore_preflight_errors +- name: Initialize Kubernetes control plane with kubeadm init and ignore_preflight_errors command: > kubeadm init --config {{ kubernetes_kubeadm_kubelet_config_file_path }} @@ -73,8 +73,8 @@ # TODO: Check if taint exists with something like `kubectl describe nodes` # instead of using kubernetes_init_stat.stat.exists check. -- name: Allow pods on master node (if configured). - command: "kubectl taint nodes --all node-role.kubernetes.io/master-" +- name: Allow pods on control plane (if configured). + command: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-" when: - - kubernetes_allow_pods_on_master | bool + - kubernetes_allow_pods_on_control_plane | bool - not kubernetes_init_stat.stat.exists diff --git a/tasks/main.yml b/tasks/main.yml index 1b57179..3fa409a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -34,15 +34,15 @@ path: /etc/kubernetes/admin.conf register: kubernetes_init_stat -# Set up master. -- include_tasks: master-setup.yml - when: kubernetes_role == 'master' +# Set up control plane. +- include_tasks: control-plane-setup.yml + when: kubernetes_role == 'control_plane' # Set up nodes. -- name: Get the kubeadm join command from the Kubernetes master. +- name: Get the kubeadm join command from the Kubernetes control plane. command: kubeadm token create --print-join-command changed_when: false - when: kubernetes_role == 'master' + when: kubernetes_role == 'control_plane' register: kubernetes_join_command_result - name: Set the kubeadm join command globally. diff --git a/tasks/node-setup.yml b/tasks/node-setup.yml index 304cbf1..be684ee 100644 --- a/tasks/node-setup.yml +++ b/tasks/node-setup.yml @@ -1,5 +1,5 @@ --- -- name: Join node to Kubernetes master +- name: Join node to Kubernetes control plane. shell: > {{ kubernetes_join_command }} creates=/etc/kubernetes/kubelet.conf