优化等待kubelet启动bootstrap机制

pull/164/head
gjmzj 2018-03-22 22:41:43 +08:00
parent e215f1edd5
commit b33ab0eea2
1 changed files with 18 additions and 5 deletions

View File

@ -55,9 +55,22 @@
tags: reload-kube-proxy
shell: systemctl daemon-reload && systemctl enable kube-proxy && systemctl restart kube-proxy
# 批准 node 节点
- name: approve-kubelet-csr
shell: "sleep 10 && {{ bin_dir }}/kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| \
xargs {{ bin_dir }}/kubectl certificate approve"
# 批准 node 节点首先轮询等待kubelet启动完成
- name: 轮询等待kubelet启动
shell: "systemctl status kubelet.service|grep Active"
register: kubelet_status
until: '"running" in kubelet_status.stdout'
retries: 3
delay: 2
- name: 获取csr 请求信息
shell: "sleep 3 && {{ bin_dir }}/kubectl get csr"
register: csr_info
run_once: true
ignore_errors: true
- name: approve-kubelet-csr
shell: "{{ bin_dir }}/kubectl get csr|grep 'Pending' | awk 'NR>0{print $1}'| \
xargs {{ bin_dir }}/kubectl certificate approve"
when: '"Pending" in csr_info.stdout'
run_once: true