2018-08-12 19:27:16 +08:00
|
|
|
|
- name: 创建相关目录
|
|
|
|
|
file: path={{ item }} state=directory
|
2018-08-05 19:30:57 +08:00
|
|
|
|
with_items:
|
2018-08-12 19:27:16 +08:00
|
|
|
|
- /opt/kube/kube-system/kubedns
|
|
|
|
|
- /opt/kube/kube-system/coredns
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2018-08-12 19:27:16 +08:00
|
|
|
|
# DNS文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
|
|
|
|
- name: 准备 DNS的部署文件
|
|
|
|
|
template: src={{ item }}.yaml.j2 dest=/opt/kube/kube-system/{{ item }}/{{ item }}.yaml
|
|
|
|
|
with_items:
|
|
|
|
|
- kubedns
|
|
|
|
|
- coredns
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
|
|
|
|
- name: 获取所有已经创建的POD信息
|
|
|
|
|
command: "{{ bin_dir }}/kubectl get pod -n kube-system"
|
|
|
|
|
register: pod_info
|
2018-06-29 15:26:01 +08:00
|
|
|
|
run_once: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 尝试推送离线{{ dns_backend }}镜像(若执行失败,可忽略)
|
|
|
|
|
copy: src={{ base_dir }}/down/{{ dns_offline }} dest=/opt/kube/images/{{ dns_offline }}
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 导入{{ dns_backend }}的离线镜像(若执行失败,可忽略)
|
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dns_offline }}"
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 创建{{ dns_backend }}部署
|
2018-08-12 19:27:16 +08:00
|
|
|
|
shell: "{{ bin_dir }}/kubectl apply -f /opt/kube/kube-system/{{ dns_backend }}"
|
|
|
|
|
run_once: true
|
|
|
|
|
when:
|
|
|
|
|
- '"kube-dns" not in pod_info.stdout'
|
|
|
|
|
- '"coredns" not in pod_info.stdout'
|
|
|
|
|
- 'dns_install == "yes"'
|
2018-06-19 21:45:17 +08:00
|
|
|
|
ignore_errors: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 尝试推送离线 metrics-server镜像(若执行失败,可忽略)
|
|
|
|
|
copy: src={{ base_dir }}/down/{{ metricsserver_offline }} dest=/opt/kube/images/{{ metricsserver_offline }}
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 导入 metrics-server的离线镜像(若执行失败,可忽略)
|
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metricsserver_offline }}"
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 创建 metrics-server部署
|
2018-08-12 19:27:16 +08:00
|
|
|
|
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server"
|
|
|
|
|
delegate_to: "{{ groups.deploy[0] }}"
|
|
|
|
|
run_once: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"'
|
2018-06-19 21:45:17 +08:00
|
|
|
|
ignore_errors: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 尝试推送离线 dashboard镜像(若执行失败,可忽略)
|
|
|
|
|
copy: src={{ base_dir }}/down/{{ dashboard_offline }} dest=/opt/kube/images/{{ dashboard_offline }}
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 导入 dashboard的离线镜像(若执行失败,可忽略)
|
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dashboard_offline }}"
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 创建 dashboard部署
|
2018-08-12 19:27:16 +08:00
|
|
|
|
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard"
|
|
|
|
|
delegate_to: "{{ groups.deploy[0] }}"
|
|
|
|
|
run_once: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'
|
2018-06-19 21:45:17 +08:00
|
|
|
|
ignore_errors: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 尝试推送离线 traefik镜像(若执行失败,可忽略)
|
|
|
|
|
copy: src={{ base_dir }}/down/{{ traefik_offline }} dest=/opt/kube/images/{{ traefik_offline }}
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 导入 traefik的离线镜像(若执行失败,可忽略)
|
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ traefik_offline }}"
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 创建 traefik部署
|
2018-08-12 19:27:16 +08:00
|
|
|
|
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik-ingress.yaml"
|
|
|
|
|
delegate_to: "{{ groups.deploy[0] }}"
|
|
|
|
|
run_once: true
|
2018-06-23 12:42:02 +08:00
|
|
|
|
when: '"traefik-ingress-controller" not in pod_info.stdout and ingress_install == "yes"'
|
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- block:
|
|
|
|
|
- name: 尝试推送离线 heapster镜像(若执行失败,可忽略)
|
|
|
|
|
copy: src={{ base_dir }}/down/{{ heapster_offline }} dest=/opt/kube/images/{{ heapster_offline }}
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 导入 heapster的离线镜像(若执行失败,可忽略)
|
|
|
|
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ heapster_offline }}"
|
2018-08-12 19:27:16 +08:00
|
|
|
|
|
2018-06-28 10:52:20 +08:00
|
|
|
|
- name: 创建 heapster部署
|
2018-08-12 19:27:16 +08:00
|
|
|
|
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster/heapster.yaml"
|
|
|
|
|
delegate_to: "{{ groups.deploy[0] }}"
|
|
|
|
|
run_once: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
when: '"heapster" not in pod_info.stdout and heapster_install == "yes"'
|
2018-06-19 21:45:17 +08:00
|
|
|
|
ignore_errors: true
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|