mirror of
https://github.com/geerlingguy/ansible-role-kubernetes.git
synced 2024-11-18 19:10:39 +01:00
Fixes #16: CentOS 7 configuration of KUBELET_EXTRA_ARGS was broken.
This commit is contained in:
parent
dcea1bfe57
commit
8fb27abcc8
@ -11,7 +11,6 @@ kubernetes_packages:
|
|||||||
|
|
||||||
kubernetes_role: master
|
kubernetes_role: master
|
||||||
|
|
||||||
kubernetes_kubelet_extra_args_config_file: /etc/default/kubelet
|
|
||||||
kubernetes_kubelet_extra_args: ""
|
kubernetes_kubelet_extra_args: ""
|
||||||
|
|
||||||
kubernetes_allow_pods_on_master: True
|
kubernetes_allow_pods_on_master: True
|
||||||
|
34
tasks/kubelet-setup.yml
Normal file
34
tasks/kubelet-setup.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- name: Check for existence of kubelet environment file.
|
||||||
|
stat:
|
||||||
|
path: '{{ kubelet_environment_file_path }}'
|
||||||
|
register: kubelet_environment_file
|
||||||
|
|
||||||
|
- name: Set facts for KUBELET_EXTRA_ARGS task if environment file exists.
|
||||||
|
set_fact:
|
||||||
|
kubelet_args_path: '{{ kubelet_environment_file_path }}'
|
||||||
|
kubelet_args_line: "{{ 'KUBELET_EXTRA_ARGS=' + kubernetes_kubelet_extra_args }}"
|
||||||
|
kubelet_args_regexp: '^KUBELET_EXTRA_ARGS='
|
||||||
|
when: kubelet_environment_file.stat.exists
|
||||||
|
|
||||||
|
- name: Set facts for KUBELET_EXTRA_ARGS task if environment file doesn't exist.
|
||||||
|
set_fact:
|
||||||
|
kubelet_args_path: '/etc/systemd/system/kubelet.service.d/10-kubeadm.conf'
|
||||||
|
kubelet_args_line: "{{ 'Environment=\"KUBELET_EXTRA_ARGS=' + kubernetes_kubelet_extra_args + '\"' }}"
|
||||||
|
kubelet_args_regexp: '^Environment='
|
||||||
|
when: kubelet_environment_file.stat.exists == False
|
||||||
|
|
||||||
|
- name: Configure KUBELET_EXTRA_ARGS.
|
||||||
|
lineinfile:
|
||||||
|
path: '{{ kubelet_args_path }}'
|
||||||
|
line: '{{ kubelet_args_line }}'
|
||||||
|
regexp: '{{ kubelet_args_regexp }}'
|
||||||
|
state: present
|
||||||
|
register: kubelet_config_file
|
||||||
|
|
||||||
|
- name: Reload systemd unit if args were changed.
|
||||||
|
systemd:
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: yes
|
||||||
|
name: kubelet
|
||||||
|
when: kubelet_config_file is changed
|
@ -1,4 +1,7 @@
|
|||||||
---
|
---
|
||||||
|
- name: Include OS-specific variables.
|
||||||
|
include_vars: "{{ ansible_os_family }}.yml"
|
||||||
|
|
||||||
- include_tasks: setup-RedHat.yml
|
- include_tasks: setup-RedHat.yml
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
@ -15,20 +18,7 @@
|
|||||||
notify: restart kubelet
|
notify: restart kubelet
|
||||||
with_items: "{{ kubernetes_packages }}"
|
with_items: "{{ kubernetes_packages }}"
|
||||||
|
|
||||||
- name: Configure KUBELET_EXTRA_ARGS.
|
- include_tasks: kubelet-setup.yml
|
||||||
lineinfile:
|
|
||||||
path: '{{ kubernetes_kubelet_extra_args_config_file }}'
|
|
||||||
line: 'KUBELET_EXTRA_ARGS={{ kubernetes_kubelet_extra_args }}'
|
|
||||||
regexp: 'KUBELET_EXTRA_ARGS='
|
|
||||||
state: present
|
|
||||||
register: kubelet_unit_file
|
|
||||||
|
|
||||||
- name: Reload systemd unit if args were changed.
|
|
||||||
systemd:
|
|
||||||
state: restarted
|
|
||||||
daemon_reload: yes
|
|
||||||
name: kubelet
|
|
||||||
when: kubelet_unit_file is changed
|
|
||||||
|
|
||||||
- name: Ensure kubelet is started and enabled at boot.
|
- name: Ensure kubelet is started and enabled at boot.
|
||||||
service:
|
service:
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
vars:
|
vars:
|
||||||
# Allow swap in test environments (hard to control in some Docker envs).
|
# Allow swap in test environments (hard to control in some Docker envs).
|
||||||
kubernetes_kubelet_extra_args: "--fail-swap-on=false"
|
kubernetes_kubelet_extra_args: "--fail-swap-on=false"
|
||||||
|
docker_install_compose: False
|
||||||
|
|
||||||
pre_tasks:
|
pre_tasks:
|
||||||
- name: Update apt cache.
|
- name: Update apt cache.
|
||||||
@ -17,7 +18,7 @@
|
|||||||
|
|
||||||
- name: Use cgroupfs cgroup driver instead of systemd (Red Hat).
|
- name: Use cgroupfs cgroup driver instead of systemd (Red Hat).
|
||||||
set_fact:
|
set_fact:
|
||||||
kubernetes_kubelet_extra_args: "--fail-swap-on=false --cgroup-driver=cgroupfs"
|
kubernetes_kubelet_extra_args: '"--fail-swap-on=false --cgroup-driver=cgroupfs"'
|
||||||
when: ansible_os_family == 'RedHat'
|
when: ansible_os_family == 'RedHat'
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
|
2
vars/Debian.yml
Normal file
2
vars/Debian.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
kubelet_environment_file_path: /etc/default/kubelet
|
2
vars/RedHat.yml
Normal file
2
vars/RedHat.yml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
kubelet_environment_file_path: /etc/sysconfig/kubelet
|
Loading…
Reference in New Issue
Block a user