Skip to content

Commit

Permalink
PR #107: Co-authored commit to change master naming to control plane.
Browse files Browse the repository at this point in the history
Co-authored-by: ra-rau <[email protected]>
  • Loading branch information
geerlingguy and ra-beer committed Sep 14, 2022
1 parent 054303a commit 10493ad
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 28 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ Kubernetes packages to be installed on the server. You can either provide a list

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.

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)

Expand Down Expand Up @@ -86,9 +86,9 @@ Extra args to pass to the generated `kubeadm join` command during K8s node initi

### Additional variables

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.

kubernetes_pod_network:
# Flannel CNI.
Expand All @@ -109,7 +109,7 @@ This role currently supports `flannel` (default), `calico` or `weave` for cluste
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.

kubernetes_apt_release_channel: main
kubernetes_apt_repository: "deb http://apt.kubernetes.io/ kubernetes-xenial {{ kubernetes_apt_release_channel }}"
Expand Down Expand Up @@ -138,25 +138,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:
Expand All @@ -171,14 +171,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

Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 5 additions & 1 deletion molecule/default/calico.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions tasks/master-setup.yml → tasks/control-plane-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
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 }}
{{ kubernetes_kubeadm_init_extra_opts }}
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 }}
Expand Down Expand Up @@ -78,8 +78,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
10 changes: 5 additions & 5 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tasks/node-setup.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 10493ad

Please sign in to comment.