mirror of https://github.com/easzlab/kubeasz.git
63 lines
3.5 KiB
YAML
63 lines
3.5 KiB
YAML
# kubedns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
||
- name: 准备 kubedns的部署文件 kubedns.yaml
|
||
template: src=kubedns.yaml.j2 dest={{ base_dir }}/manifests/kubedns/kubedns.yaml
|
||
|
||
# coredns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
||
- name: 准备 coredns的部署文件 coredns.yaml
|
||
template: src=coredns.yaml.j2 dest={{ base_dir }}/manifests/coredns/coredns.yaml
|
||
|
||
- name: 获取所有已经创建的POD信息
|
||
command: "{{ bin_dir }}/kubectl get pod -n kube-system"
|
||
register: pod_info
|
||
|
||
- block:
|
||
- name: 尝试推送离线{{ dns_backend }}镜像(若执行失败,可忽略)
|
||
copy: src={{ base_dir }}/down/{{ dns_offline }} dest=/opt/kube/images/{{ dns_offline }}
|
||
- name: 导入{{ dns_backend }}的离线镜像(若执行失败,可忽略)
|
||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dns_offline }}"
|
||
- name: 创建{{ dns_backend }}部署
|
||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/{{ dns_backend }}"
|
||
when: '"kube-dns" not in pod_info.stdout and "coredns" not in pod_info.stdout and dns_install == "yes"'
|
||
ignore_errors: true
|
||
|
||
- block:
|
||
- name: 尝试推送离线 metrics-server镜像(若执行失败,可忽略)
|
||
copy: src={{ base_dir }}/down/{{ metricsserver_offline }} dest=/opt/kube/images/{{ metricsserver_offline }}
|
||
- name: 导入 metrics-server的离线镜像(若执行失败,可忽略)
|
||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metricsserver_offline }}"
|
||
- name: 创建 metrics-server部署
|
||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server"
|
||
when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"'
|
||
ignore_errors: true
|
||
|
||
- block:
|
||
- name: 尝试推送离线 dashboard镜像(若执行失败,可忽略)
|
||
copy: src={{ base_dir }}/down/{{ dashboard_offline }} dest=/opt/kube/images/{{ dashboard_offline }}
|
||
- name: 导入 dashboard的离线镜像(若执行失败,可忽略)
|
||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dashboard_offline }}"
|
||
- name: 创建 dashboard部署
|
||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard"
|
||
when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'
|
||
ignore_errors: true
|
||
|
||
- block:
|
||
- name: 尝试推送离线 traefik镜像(若执行失败,可忽略)
|
||
copy: src={{ base_dir }}/down/{{ traefik_offline }} dest=/opt/kube/images/{{ traefik_offline }}
|
||
- name: 导入 traefik的离线镜像(若执行失败,可忽略)
|
||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ traefik_offline }}"
|
||
- name: 创建 traefik部署
|
||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik-ingress.yaml"
|
||
when: '"traefik-ingress-controller" not in pod_info.stdout and ingress_install == "yes"'
|
||
ignore_errors: true
|
||
|
||
- block:
|
||
- name: 尝试推送离线 heapster镜像(若执行失败,可忽略)
|
||
copy: src={{ base_dir }}/down/{{ heapster_offline }} dest=/opt/kube/images/{{ heapster_offline }}
|
||
- name: 导入 heapster的离线镜像(若执行失败,可忽略)
|
||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ heapster_offline }}"
|
||
- name: 创建 heapster部署
|
||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster"
|
||
when: '"heapster" not in pod_info.stdout and heapster_install == "yes"'
|
||
ignore_errors: true
|
||
|