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

Allow kubelet env vars to be set in inventory #143

Open
erictcgs opened this issue Apr 26, 2019 · 1 comment
Open

Allow kubelet env vars to be set in inventory #143

erictcgs opened this issue Apr 26, 2019 · 1 comment

Comments

@erictcgs
Copy link

For private docker registries that require credentials for all pulled images, kubelet needs to have access to docker credentials to pull all images in all namespaces, including for system pods, pause image, etc. Kubelet HOME defaults to "/", so docker registries are expected in the non-standard location of "/.docker", unexpected as kubelet is running as root. One way to solve is to make sure HOME is set to "/root", so method of being able to specify env vars is desired, for this or any other requirement to set env.

Related issues:

@erictcgs
Copy link
Author

For the 1.11.x branch, the following allows a user to add kubernetes_common_kubelet_env_vars dictionary, values are added to /etc/default/kubelet. ( @craigtracey )

diff --git a/ansible/roles/kubernetes-common/defaults/main.yml b/ansible/roles/kubernetes-common/defaults/main.yml
index 27b4044..152fc73 100644
--- a/ansible/roles/kubernetes-common/defaults/main.yml
+++ b/ansible/roles/kubernetes-common/defaults/main.yml
@@ -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:
diff --git a/ansible/roles/kubernetes-common/tasks/main.yml b/ansible/roles/kubernetes-common/tasks/main.yml
index d136091..6873ad2 100644
--- a/ansible/roles/kubernetes-common/tasks/main.yml
+++ b/ansible/roles/kubernetes-common/tasks/main.yml
@@ -36,7 +36,7 @@
     src: etc/default/kubelet
   notify:
     - restart kubelet
-  when: kubernetes_common_primary_interface is defined or kubernetes_common_kubelet_extra_args is defined
+  when: kubernetes_common_primary_interface is defined or kubernetes_common_kubelet_extra_args is defined or kubernetes_common_kubelet_env_vars is defined

 - name: open kubelet ports
   firewalld:
diff --git a/ansible/roles/kubernetes-common/templates/etc/default/kubelet b/ansible/roles/kubernetes-common/templates/etc/default/kubelet
index 32821b4..1f26c58 100644
--- a/ansible/roles/kubernetes-common/templates/etc/default/kubelet
+++ b/ansible/roles/kubernetes-common/templates/etc/default/kubelet
@@ -1 +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 %}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant