From ab3832f3e76eda50ac013067652fe0c1133714db Mon Sep 17 00:00:00 2001 From: Matthew Mosesohn Date: Fri, 3 Nov 2017 10:19:37 +0000 Subject: [PATCH] Set host IP for kubelet always (#1924) * Set host IP for kubelet always Use ansible default IP if ip var is not set. * Update main.yml --- roles/kubernetes/node/defaults/main.yml | 6 ++++++ roles/kubernetes/node/templates/kubelet.kubeadm.env.j2 | 2 +- roles/kubernetes/node/templates/kubelet.standard.env.j2 | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/roles/kubernetes/node/defaults/main.yml b/roles/kubernetes/node/defaults/main.yml index 05a34cec1..8addb28f6 100644 --- a/roles/kubernetes/node/defaults/main.yml +++ b/roles/kubernetes/node/defaults/main.yml @@ -5,6 +5,12 @@ kubelet_deployment_type: host # change to 0.0.0.0 to enable insecure access from anywhere (not recommended) kube_apiserver_insecure_bind_address: 127.0.0.1 +# advertised host IP for kubelet. This affects network plugin config. Take caution +kubelet_address: "{{ ip | default(ansible_default_ipv4['address']) }}" + +# bind address for kubelet. Set to 0.0.0.0 to listen on all interfaces +kubelet_bind_address: "{{ ip | default('0.0.0.0') }}" + # resolv.conf to base dns config kube_resolv_conf: "/etc/resolv.conf" diff --git a/roles/kubernetes/node/templates/kubelet.kubeadm.env.j2 b/roles/kubernetes/node/templates/kubelet.kubeadm.env.j2 index c543a86fe..30477224d 100644 --- a/roles/kubernetes/node/templates/kubelet.kubeadm.env.j2 +++ b/roles/kubernetes/node/templates/kubelet.kubeadm.env.j2 @@ -5,7 +5,7 @@ KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v={{ kube_log_level }}" # The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) -KUBELET_ADDRESS="--address={{ ip | default("0.0.0.0") }} {% if ip is defined %} --node-ip={{ ip }}{% endif %}" +KUBELET_ADDRESS="--address={{ kubelet_bind_address }} --node-ip={{ kubelet_address }}" # The port for the info server to serve on # KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname diff --git a/roles/kubernetes/node/templates/kubelet.standard.env.j2 b/roles/kubernetes/node/templates/kubelet.standard.env.j2 index 30c07059b..fa5b44868 100644 --- a/roles/kubernetes/node/templates/kubelet.standard.env.j2 +++ b/roles/kubernetes/node/templates/kubelet.standard.env.j2 @@ -2,7 +2,7 @@ KUBE_LOGTOSTDERR="--logtostderr=true" KUBE_LOG_LEVEL="--v={{ kube_log_level }}" # The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces) -KUBELET_ADDRESS="--address={{ ip | default("0.0.0.0") }} {% if ip is defined %} --node-ip={{ ip }}{% endif %}" +KUBELET_ADDRESS="--address={{ kubelet_bind_address }} --node-ip={{ kubelet_address }}" # The port for the info server to serve on # KUBELET_PORT="--port=10250" # You may leave this blank to use the actual hostname