mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2024-11-23 19:06:33 +01:00
PR #107: Co-authored commit to change master naming to control plane.
Co-authored-by: ra-rau <mafe2.0@freenet.de>
This commit is contained in:
parent
3a236239a7
commit
926a8c909e
24
README.md
24
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
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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:
|
||||
|
@ -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
|
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user