Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Commit

Permalink
Support kubelet environment file (#142)
Browse files Browse the repository at this point in the history
* Support kubelet environment file

With 1.11 the kubelet packages now support an external kubelet
environment file. Update the placement of this configuration from the
kubelet.d directory to the /etc/{default|sysconfig}/kubelet file.

Signed-off-by: Craig Tracey <craigtracey@gmail.com>

* Support env vars in kubelet environment file

Add the capability to add environment vars to the kubelet's systemd
environment file. This will let folks add arbitrary env vars for things
like $HOME, etc.

Signed-off-by: Craig Tracey <craigtracey@gmail.com>
  • Loading branch information
craigtracey committed May 2, 2019
1 parent f60f223 commit a068505
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions ansible/roles/kubernetes-common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ kubernetes_common_primary_interface: eth0

# kubelet_extra_args is a dict of arg:value (ie. 'node-ip: 1.1.1.1' for '--node-ip=1.1.1.1')
kubernetes_common_kubelet_extra_args: {}
kubernetes_common_kubelet_env_vars: {}
kubernetes_common_kubelet_config: {}

kubernetes_common_kubeadm_config:
Expand Down
11 changes: 9 additions & 2 deletions ansible/roles/kubernetes-common/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,18 @@
- name: drop extra args kubelet config
template:
backup: True
dest: "/etc/{{ 'default' if ansible_os_family == 'Debian' else 'sysconfig' }}/kubelet"
src: etc/default/kubelet
notify:
- restart kubelet
when: kubernetes_common_primary_interface is defined or kubernetes_common_kubelet_extra_args is defined or kubernetes_common_kubelet_env_vars is defined

- name: delete old kubelet extra args unit file
file:
dest: /etc/systemd/system/kubelet.service.d/09-extra-args.conf
src: etc/systemd/system/kubelet.service.d/09-extra-args.conf
state: absent
notify:
- restart kubelet
when: kubernetes_common_primary_interface is defined or kubernetes_common_kubelet_extra_args is defined

- name: ensure firewalld is running
systemd:
Expand Down
5 changes: 5 additions & 0 deletions ansible/roles/kubernetes-common/templates/etc/default/kubelet
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
KUBELET_EXTRA_ARGS={% if kubernetes_common_primary_interface is defined %} --node-ip={{kubernetes_node_ip}}{% endif %}{% for k, v in kubernetes_common_kubelet_extra_args.items() %} --{{k}}='{{v}}'{%- endfor %}

{% for k, v in kubernetes_common_kubelet_env_vars.items() %}
{{k}}='{{v}}'
{% endfor %}

This file was deleted.

0 comments on commit a068505

Please sign in to comment.