2019-05-29 20:45:25 +08:00
|
|
|
|
- name: 获取所有已经创建的POD信息
|
2021-01-11 19:02:34 +08:00
|
|
|
|
command: "{{ base_dir }}/bin/kubectl get pod --all-namespaces"
|
2019-05-29 20:45:25 +08:00
|
|
|
|
register: pod_info
|
2021-01-11 19:02:34 +08:00
|
|
|
|
connection: local
|
2018-08-31 22:58:44 +08:00
|
|
|
|
run_once: true
|
|
|
|
|
|
2018-10-14 10:17:20 +08:00
|
|
|
|
- name: 获取已下载离线镜像信息
|
|
|
|
|
command: "ls {{ base_dir }}/down"
|
|
|
|
|
register: download_info
|
|
|
|
|
connection: local
|
|
|
|
|
run_once: true
|
|
|
|
|
|
2021-01-22 23:54:12 +08:00
|
|
|
|
- name: 注册变量 DNS_SVC_IP
|
|
|
|
|
shell: echo {{ SERVICE_CIDR }}|cut -d/ -f1|awk -F. '{print $1"."$2"."$3"."$4+2}'
|
|
|
|
|
register: DNS_SVC_IP
|
|
|
|
|
|
|
|
|
|
- name: 设置变量 CLUSTER_DNS_SVC_IP
|
|
|
|
|
set_fact: CLUSTER_DNS_SVC_IP={{ DNS_SVC_IP.stdout }}
|
|
|
|
|
|
|
|
|
|
- debug: var="CLUSTER_DNS_SVC_IP"
|
|
|
|
|
|
2021-01-11 19:02:34 +08:00
|
|
|
|
- import_tasks: coredns.yml
|
|
|
|
|
when: '"coredns" not in pod_info.stdout and dns_install == "yes"'
|
2018-06-17 23:19:04 +08:00
|
|
|
|
|
2021-01-13 21:27:18 +08:00
|
|
|
|
- import_tasks: nodelocaldns.yml
|
|
|
|
|
when: '"node-local-dns" not in pod_info.stdout and ENABLE_LOCAL_DNS_CACHE|bool'
|
|
|
|
|
|
2021-01-11 19:02:34 +08:00
|
|
|
|
- import_tasks: metrics-server.yml
|
2018-06-17 23:19:04 +08:00
|
|
|
|
when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"'
|
2019-06-13 17:16:52 +08:00
|
|
|
|
|
2021-01-11 19:02:34 +08:00
|
|
|
|
- import_tasks: dashboard.yml
|
2018-06-17 23:19:04 +08:00
|
|
|
|
when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'
|
|
|
|
|
|
2021-01-11 19:02:34 +08:00
|
|
|
|
- import_tasks: ingress.yml
|
|
|
|
|
when: '"traefik" not in pod_info.stdout and ingress_install == "yes"'
|
2018-06-23 12:42:02 +08:00
|
|
|
|
|
2021-01-11 11:12:14 +08:00
|
|
|
|
- import_tasks: prometheus.yml
|
|
|
|
|
when: '"kube-prometheus-operator" not in pod_info.stdout and prom_install == "yes"'
|
|
|
|
|
|
2021-03-27 00:09:42 +08:00
|
|
|
|
- import_tasks: nfs-provisioner.yml
|
|
|
|
|
when: '"nfs-client-provisioner" not in pod_info.stdout and nfs_provisioner_install == "yes"'
|
|
|
|
|
|
2020-05-21 10:41:59 +08:00
|
|
|
|
#- block:
|
|
|
|
|
# - block:
|
|
|
|
|
# - name: 尝试推送离线 metallb镜像(若执行失败,可忽略)
|
|
|
|
|
# copy: src={{ base_dir }}/down/{{ metallb_offline }} dest=/opt/kube/images/{{ metallb_offline }}
|
|
|
|
|
# when: 'metallb_offline in download_info.stdout'
|
|
|
|
|
#
|
|
|
|
|
# - name: 获取metallb离线镜像推送情况
|
|
|
|
|
# command: "ls /opt/kube/images"
|
|
|
|
|
# register: image_info
|
|
|
|
|
#
|
|
|
|
|
# - name: 导入 metallb的离线镜像(若执行失败,可忽略)
|
|
|
|
|
# shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metallb_offline }}"
|
|
|
|
|
# when: 'metallb_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
|
|
|
|
|
#
|
|
|
|
|
# - name: 导入 metallb的离线镜像(若执行失败,可忽略)
|
|
|
|
|
# shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ metallb_offline }}"
|
|
|
|
|
# when: 'metallb_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
|
|
|
|
|
#
|
|
|
|
|
# - name: 生成 metallb 相关 manifests
|
|
|
|
|
# template: src=metallb/{{ item }}.j2 dest=/opt/kube/kube-system/{{ item }}
|
|
|
|
|
# with_items:
|
|
|
|
|
# - "metallb.yaml"
|
|
|
|
|
# - "{{ metallb_protocol }}.yaml"
|
|
|
|
|
#
|
|
|
|
|
# - name: 创建 metallb controller 部署
|
|
|
|
|
# shell: "{{ bin_dir }}/kubectl apply -f /opt/kube/kube-system/metallb.yaml && \
|
|
|
|
|
# {{ bin_dir }}/kubectl apply -f /opt/kube/kube-system/{{ metallb_protocol }}.yaml"
|
|
|
|
|
# run_once: true
|
|
|
|
|
# when: '"metallb" not in pod_info.stdout and metallb_install == "yes"'
|
|
|
|
|
# ignore_errors: true
|