Skip to content

Commit

Permalink
调整安装步骤中kubectl的执行以适合公有云部署
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmzj committed Sep 15, 2018
1 parent c3bac29 commit 6b21f30
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions 04.kube-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
tasks:
- name: 禁止业务 pod调度到 master节点
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
delegate_to: "{{ groups.deploy[0] }}"
when: DEPLOY_MODE != "allinone"
ignore_errors: true

- name: 设置master节点role
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"
2 changes: 2 additions & 0 deletions 21.addmaster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
tasks:
- name: 禁止业务 pod调度到 master节点
shell: "{{ bin_dir }}/kubectl cordon {{ inventory_hostname }} "
delegate_to: "{{ groups.deploy[0] }}"
when: DEPLOY_MODE != "allinone"
ignore_errors: true

- name: 设置master节点role
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=master --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"
1 change: 1 addition & 0 deletions roles/kube-master/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@
until: result.rc == 0
retries: 5
delay: 6
delegate_to: "{{ groups.deploy[0] }}"
run_once: True
tags: upgrade_k8s, restart_master
4 changes: 4 additions & 0 deletions roles/kube-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,21 @@

- name: 获取csr 请求信息
shell: "sleep 3 && {{ bin_dir }}/kubectl get csr"
delegate_to: "{{ groups.deploy[0] }}"
register: csr_info
run_once: 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'
delegate_to: "{{ groups.deploy[0] }}"
run_once: true

- name: 轮询等待node达到Ready状态
shell: "{{ bin_dir }}/kubectl get node {{ inventory_hostname }}|awk 'NR>1{print $2}'"
register: node_status
delegate_to: "{{ groups.deploy[0] }}"
until: node_status.stdout == "Ready" or node_status.stdout == "Ready,SchedulingDisabled"
retries: 8
delay: 8
Expand All @@ -117,3 +120,4 @@
- name: 设置node节点role
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=node --overwrite"
ignore_errors: true
delegate_to: "{{ groups.deploy[0] }}"

0 comments on commit 6b21f30

Please sign in to comment.