fix: kubeconfig证书中server地址逻辑

pull/804/head
gjmzj 2020-01-31 12:37:44 +08:00
parent 4a56116b19
commit 4e07ae2a82
2 changed files with 16 additions and 20 deletions

View File

@ -49,6 +49,17 @@
when: 'BASIC_AUTH_ENABLE == "yes"'
tags: restart_master
- name: 替换 kubeconfig 的 apiserver 地址
lineinfile:
dest: "{{ item }}"
regexp: "^ server"
line: " server: https://{{ inventory_hostname }}:6443"
with_items:
- "/root/.kube/config"
- "/etc/kubernetes/kube-controller-manager.kubeconfig"
- "/etc/kubernetes/kube-scheduler.kubeconfig"
tags: upgrade_k8s, restart_master
- name: 创建 master 服务的 systemd unit 文件
template: src={{ item }}.j2 dest=/etc/systemd/system/{{ item }}
with_items:
@ -66,13 +77,6 @@
systemctl restart kube-controller-manager && systemctl restart kube-scheduler"
tags: upgrade_k8s, restart_master
- name: 替换 kubeconfig 的 apiserver 地址
lineinfile:
dest: /root/.kube/config
regexp: "^ server"
line: " server: https://{{ inventory_hostname }}:6443"
tags: upgrade_k8s, restart_master
- name: 以轮询的方式等待master服务启动完成
command: "{{ bin_dir }}/kubectl get node"
register: result

View File

@ -47,21 +47,13 @@
- block:
- name: 替换 kubeconfig 的 apiserver 地址
lineinfile:
dest: /root/.kube/config
regexp: "^ server"
line: " server: {{ KUBE_APISERVER }}"
- name: 替换 kubelet.kubeconfig 的 apiserver 地址
lineinfile:
dest: /etc/kubernetes/kubelet.kubeconfig
regexp: "^ server"
line: " server: {{ KUBE_APISERVER }}"
- name: 替换 kube-proxy.kubeconfig 的 apiserver 地址
lineinfile:
dest: /etc/kubernetes/kube-proxy.kubeconfig
dest: "{{ item }}"
regexp: "^ server"
line: " server: {{ KUBE_APISERVER }}"
with_items:
- "/root/.kube/config"
- "/etc/kubernetes/kubelet.kubeconfig"
- "/etc/kubernetes/kube-proxy.kubeconfig"
- name: restart kube-node service
service: name={{ item }} state=restarted