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.
|
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
|
```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)
|
### 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
|
### Additional variables
|
||||||
|
|
||||||
```yaml
|
```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
|
```yaml
|
||||||
kubernetes_pod_network:
|
kubernetes_pod_network:
|
||||||
@ -137,7 +137,7 @@ kubernetes_version_kubeadm: 'stable-{{ kubernetes_version }}'`
|
|||||||
kubernetes_ignore_preflight_errors: 'all'
|
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
|
```yaml
|
||||||
kubernetes_apt_release_channel: main
|
kubernetes_apt_release_channel: main
|
||||||
@ -177,25 +177,25 @@ None.
|
|||||||
|
|
||||||
## Example Playbooks
|
## Example Playbooks
|
||||||
|
|
||||||
### Single node (master-only) cluster
|
### Single node (control-plane-only) cluster
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- hosts: all
|
- hosts: all
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
kubernetes_allow_pods_on_master: true
|
kubernetes_allow_pods_on_control_plane: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- geerlingguy.docker
|
- geerlingguy.docker
|
||||||
- geerlingguy.kubernetes
|
- 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
|
```yaml
|
||||||
kubernetes_role: "master"
|
kubernetes_role: "control_plane"
|
||||||
```
|
```
|
||||||
|
|
||||||
Node(s) inventory vars:
|
Node(s) inventory vars:
|
||||||
@ -210,14 +210,14 @@ Playbook:
|
|||||||
- hosts: all
|
- hosts: all
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
kubernetes_allow_pods_on_master: true
|
kubernetes_allow_pods_on_control_plane: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- geerlingguy.docker
|
- geerlingguy.docker
|
||||||
- geerlingguy.kubernetes
|
- 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
|
## License
|
||||||
|
|
||||||
|
@ -12,14 +12,14 @@ kubernetes_packages:
|
|||||||
kubernetes_version: '1.25'
|
kubernetes_version: '1.25'
|
||||||
kubernetes_version_rhel_package: '1.25.0'
|
kubernetes_version_rhel_package: '1.25.0'
|
||||||
|
|
||||||
kubernetes_role: master
|
kubernetes_role: control_plane
|
||||||
|
|
||||||
# This is deprecated. Please use kubernetes_config_kubelet_configuration instead.
|
# This is deprecated. Please use kubernetes_config_kubelet_configuration instead.
|
||||||
kubernetes_kubelet_extra_args: ""
|
kubernetes_kubelet_extra_args: ""
|
||||||
|
|
||||||
kubernetes_kubeadm_init_extra_opts: ""
|
kubernetes_kubeadm_init_extra_opts: ""
|
||||||
kubernetes_join_command_extra_opts: ""
|
kubernetes_join_command_extra_opts: ""
|
||||||
kubernetes_allow_pods_on_master: true
|
kubernetes_allow_pods_on_control_plane: true
|
||||||
kubernetes_pod_network:
|
kubernetes_pod_network:
|
||||||
# Flannel CNI.
|
# Flannel CNI.
|
||||||
cni: 'flannel'
|
cni: 'flannel'
|
||||||
|
@ -9,7 +9,11 @@
|
|||||||
cidr: '192.168.0.0/16'
|
cidr: '192.168.0.0/16'
|
||||||
|
|
||||||
# Allow swap in test environments (hard to control in some envs).
|
# 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
|
docker_install_compose: false
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
|
|
||||||
vars:
|
vars:
|
||||||
# Allow swap in test environments (hard to control in some envs).
|
# 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
|
docker_install_compose: false
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
|
@ -10,7 +10,7 @@ platforms:
|
|||||||
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
command: ${MOLECULE_DOCKER_COMMAND:-""}
|
||||||
volumes:
|
volumes:
|
||||||
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
- /sys/fs/cgroup:/sys/fs/cgroup:ro
|
||||||
- /var/lib/docker
|
- /var/lib/containerd
|
||||||
privileged: true
|
privileged: true
|
||||||
pre_build_image: true
|
pre_build_image: true
|
||||||
provisioner:
|
provisioner:
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
src: "kubeadm-kubelet-config.j2"
|
src: "kubeadm-kubelet-config.j2"
|
||||||
dest: "{{ kubernetes_kubeadm_kubelet_config_file_path }}"
|
dest: "{{ kubernetes_kubeadm_kubelet_config_file_path }}"
|
||||||
|
|
||||||
- name: Initialize Kubernetes master with kubeadm init
|
- name: Initialize Kubernetes control plane with kubeadm init
|
||||||
command: >
|
command: >
|
||||||
kubeadm init
|
kubeadm init
|
||||||
--config {{ kubernetes_kubeadm_kubelet_config_file_path }}
|
--config {{ kubernetes_kubeadm_kubelet_config_file_path }}
|
||||||
@ -17,7 +17,7 @@
|
|||||||
register: kubeadmin_init
|
register: kubeadmin_init
|
||||||
when: (not kubernetes_init_stat.stat.exists) and (kubernetes_ignore_preflight_errors is not defined)
|
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: >
|
command: >
|
||||||
kubeadm init
|
kubeadm init
|
||||||
--config {{ kubernetes_kubeadm_kubelet_config_file_path }}
|
--config {{ kubernetes_kubeadm_kubelet_config_file_path }}
|
||||||
@ -73,8 +73,8 @@
|
|||||||
|
|
||||||
# TODO: Check if taint exists with something like `kubectl describe nodes`
|
# TODO: Check if taint exists with something like `kubectl describe nodes`
|
||||||
# instead of using kubernetes_init_stat.stat.exists check.
|
# instead of using kubernetes_init_stat.stat.exists check.
|
||||||
- name: Allow pods on master node (if configured).
|
- name: Allow pods on control plane (if configured).
|
||||||
command: "kubectl taint nodes --all node-role.kubernetes.io/master-"
|
command: "kubectl taint nodes --all node-role.kubernetes.io/control-plane-"
|
||||||
when:
|
when:
|
||||||
- kubernetes_allow_pods_on_master | bool
|
- kubernetes_allow_pods_on_control_plane | bool
|
||||||
- not kubernetes_init_stat.stat.exists
|
- not kubernetes_init_stat.stat.exists
|
@ -34,15 +34,15 @@
|
|||||||
path: /etc/kubernetes/admin.conf
|
path: /etc/kubernetes/admin.conf
|
||||||
register: kubernetes_init_stat
|
register: kubernetes_init_stat
|
||||||
|
|
||||||
# Set up master.
|
# Set up control plane.
|
||||||
- include_tasks: master-setup.yml
|
- include_tasks: control-plane-setup.yml
|
||||||
when: kubernetes_role == 'master'
|
when: kubernetes_role == 'control_plane'
|
||||||
|
|
||||||
# Set up nodes.
|
# 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
|
command: kubeadm token create --print-join-command
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when: kubernetes_role == 'master'
|
when: kubernetes_role == 'control_plane'
|
||||||
register: kubernetes_join_command_result
|
register: kubernetes_join_command_result
|
||||||
|
|
||||||
- name: Set the kubeadm join command globally.
|
- 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: >
|
shell: >
|
||||||
{{ kubernetes_join_command }}
|
{{ kubernetes_join_command }}
|
||||||
creates=/etc/kubernetes/kubelet.conf
|
creates=/etc/kubernetes/kubelet.conf
|
||||||
|
Loading…
Reference in New Issue
Block a user