From ccb5686e822128ed5e8ca07e8f202577c4edfc8f Mon Sep 17 00:00:00 2001 From: gjmzj Date: Sun, 30 Jun 2019 21:23:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20kubelet=201.15=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8F=82=E6=95=B0--allow-privileged?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- roles/kube-node/tasks/main.yml | 16 ++++++++++++++++ roles/kube-node/templates/kubelet.service.j2 | 2 ++ 2 files changed, 18 insertions(+) diff --git a/roles/kube-node/tasks/main.yml b/roles/kube-node/tasks/main.yml index 8f18448..ba23a35 100644 --- a/roles/kube-node/tasks/main.yml +++ b/roles/kube-node/tasks/main.yml @@ -76,6 +76,22 @@ set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }} tags: restart_node +# 判断 kubernetes 版本 +- name: 注册变量 TMP_VER + shell: "{{ base_dir }}/bin/kubelet --version|cut -d' ' -f2|cut -d'v' -f2" + register: TMP_VER + connection: local + run_once: true + tags: restart_node + +- name: 获取 kubernetes 主版本号 + set_fact: + KUBE_VER: "{{ TMP_VER.stdout.split('.')[0]|int + TMP_VER.stdout.split('.')[1]|int/100 }}" + tags: restart_node + +- name: debug info + debug: var="KUBE_VER" + - name: 创建kubelet的systemd unit文件 template: src=kubelet.service.j2 dest=/etc/systemd/system/kubelet.service tags: restart_node diff --git a/roles/kube-node/templates/kubelet.service.j2 b/roles/kube-node/templates/kubelet.service.j2 index e324b3b..4684ca1 100644 --- a/roles/kube-node/templates/kubelet.service.j2 +++ b/roles/kube-node/templates/kubelet.service.j2 @@ -12,7 +12,9 @@ ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/pids/system.slice/kubelet.service {% endif %} ExecStart={{ bin_dir }}/kubelet \ --address={{ inventory_hostname }} \ +{% if KUBE_VER|float < 1.15 %} --allow-privileged=true \ +{% endif %} --anonymous-auth=false \ --authentication-token-webhook \ --authorization-mode=Webhook \