mirror of https://github.com/easzlab/kubeasz.git
fix集成离线镜像安装脚本
parent
62162c3802
commit
ae0f5b242f
|
@ -1,4 +1,5 @@
|
||||||
- hosts:
|
- hosts:
|
||||||
- deploy
|
- deploy
|
||||||
|
- kube-node
|
||||||
roles:
|
roles:
|
||||||
- cluster-addon
|
- cluster-addon
|
||||||
|
|
|
@ -61,7 +61,9 @@
|
||||||
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
|
- { role: kube-router, when: "CLUSTER_NETWORK == 'kube-router'" }
|
||||||
|
|
||||||
# 集群插件安装
|
# 集群插件安装
|
||||||
- hosts: deploy
|
- hosts:
|
||||||
|
- deploy
|
||||||
|
- kube-node
|
||||||
roles:
|
roles:
|
||||||
- cluster-addon
|
- cluster-addon
|
||||||
|
|
||||||
|
|
|
@ -36,4 +36,13 @@ mirrorgooglecontainers/fluentd-elasticsearch:v2.0.2
|
||||||
jmgao1983/kibana:5.6.4
|
jmgao1983/kibana:5.6.4
|
||||||
# nfs 动态PV
|
# nfs 动态PV
|
||||||
jmgao1983/nfs-client-provisioner:latest
|
jmgao1983/nfs-client-provisioner:latest
|
||||||
|
# prometheus
|
||||||
|
busybox:latest
|
||||||
|
grafana/grafana:5.1.2
|
||||||
|
mirrorgooglecontainers/kube-state-metrics:v1.3.1
|
||||||
|
appropriate/curl:latest
|
||||||
|
prom/prometheus:v2.2.1
|
||||||
|
prom/alertmanager:v0.14.0
|
||||||
|
prom/node-exporter:v0.15.2
|
||||||
|
jimmidyson/configmap-reload:v0.1
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ traefik_offline: "traefik_v1.6.tar"
|
||||||
|
|
||||||
# heapster 自动安装
|
# heapster 自动安装
|
||||||
heapster_install: "no"
|
heapster_install: "no"
|
||||||
|
heapster_offline: "heapster_v1.5.1.tar"
|
||||||
|
|
||||||
# efk 自动安装
|
# efk 自动安装
|
||||||
#efk_install: "no"
|
#efk_install: "no"
|
||||||
|
|
|
@ -1,62 +1,81 @@
|
||||||
|
#-------------kube-dns 插件参数初始化
|
||||||
# kubedns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
# kubedns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
||||||
- name: 准备 kubedns的部署文件 kubedns.yaml
|
- name: 准备 kubedns的部署文件 kubedns.yaml
|
||||||
template: src=kubedns.yaml.j2 dest={{ base_dir }}/manifests/kubedns/kubedns.yaml
|
template: src=kubedns.yaml.j2 dest={{ base_dir }}/manifests/kubedns/kubedns.yaml
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
|
|
||||||
# coredns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
# coredns.yaml文件中部分参数根据hosts文件设置而定,因此需要用template模块替换参数
|
||||||
- name: 准备 coredns的部署文件 coredns.yaml
|
- name: 准备 coredns的部署文件 coredns.yaml
|
||||||
template: src=coredns.yaml.j2 dest={{ base_dir }}/manifests/coredns/coredns.yaml
|
template: src=coredns.yaml.j2 dest={{ base_dir }}/manifests/coredns/coredns.yaml
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
|
|
||||||
- name: 获取所有已经创建的POD信息
|
- name: 获取所有已经创建的POD信息
|
||||||
command: "{{ bin_dir }}/kubectl get pod -n kube-system"
|
command: "{{ bin_dir }}/kubectl get pod -n kube-system"
|
||||||
register: pod_info
|
register: pod_info
|
||||||
|
run_once: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: 尝试推送离线{{ dns_backend }}镜像(若执行失败,可忽略)
|
- name: 尝试推送离线{{ dns_backend }}镜像(若执行失败,可忽略)
|
||||||
copy: src={{ base_dir }}/down/{{ dns_offline }} dest=/opt/kube/images/{{ dns_offline }}
|
copy: src={{ base_dir }}/down/{{ dns_offline }} dest=/opt/kube/images/{{ dns_offline }}
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 导入{{ dns_backend }}的离线镜像(若执行失败,可忽略)
|
- name: 导入{{ dns_backend }}的离线镜像(若执行失败,可忽略)
|
||||||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dns_offline }}"
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dns_offline }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 创建{{ dns_backend }}部署
|
- name: 创建{{ dns_backend }}部署
|
||||||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/{{ dns_backend }}"
|
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/{{ dns_backend }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
when: '"kube-dns" not in pod_info.stdout and "coredns" not in pod_info.stdout and dns_install == "yes"'
|
when: '"kube-dns" not in pod_info.stdout and "coredns" not in pod_info.stdout and dns_install == "yes"'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: 尝试推送离线 metrics-server镜像(若执行失败,可忽略)
|
- name: 尝试推送离线 metrics-server镜像(若执行失败,可忽略)
|
||||||
copy: src={{ base_dir }}/down/{{ metricsserver_offline }} dest=/opt/kube/images/{{ metricsserver_offline }}
|
copy: src={{ base_dir }}/down/{{ metricsserver_offline }} dest=/opt/kube/images/{{ metricsserver_offline }}
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 导入 metrics-server的离线镜像(若执行失败,可忽略)
|
- name: 导入 metrics-server的离线镜像(若执行失败,可忽略)
|
||||||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metricsserver_offline }}"
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metricsserver_offline }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 创建 metrics-server部署
|
- name: 创建 metrics-server部署
|
||||||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server"
|
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"'
|
when: '"metrics-server" not in pod_info.stdout and metricsserver_install == "yes"'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: 尝试推送离线 dashboard镜像(若执行失败,可忽略)
|
- name: 尝试推送离线 dashboard镜像(若执行失败,可忽略)
|
||||||
copy: src={{ base_dir }}/down/{{ dashboard_offline }} dest=/opt/kube/images/{{ dashboard_offline }}
|
copy: src={{ base_dir }}/down/{{ dashboard_offline }} dest=/opt/kube/images/{{ dashboard_offline }}
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 导入 dashboard的离线镜像(若执行失败,可忽略)
|
- name: 导入 dashboard的离线镜像(若执行失败,可忽略)
|
||||||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dashboard_offline }}"
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dashboard_offline }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 创建 dashboard部署
|
- name: 创建 dashboard部署
|
||||||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard"
|
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'
|
when: '"kubernetes-dashboard" not in pod_info.stdout and dashboard_install == "yes"'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: 尝试推送离线 traefik镜像(若执行失败,可忽略)
|
- name: 尝试推送离线 traefik镜像(若执行失败,可忽略)
|
||||||
copy: src={{ base_dir }}/down/{{ traefik_offline }} dest=/opt/kube/images/{{ traefik_offline }}
|
copy: src={{ base_dir }}/down/{{ traefik_offline }} dest=/opt/kube/images/{{ traefik_offline }}
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 导入 traefik的离线镜像(若执行失败,可忽略)
|
- name: 导入 traefik的离线镜像(若执行失败,可忽略)
|
||||||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ traefik_offline }}"
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ traefik_offline }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 创建 traefik部署
|
- name: 创建 traefik部署
|
||||||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik-ingress.yaml"
|
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik-ingress.yaml"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
when: '"traefik-ingress-controller" not in pod_info.stdout and ingress_install == "yes"'
|
when: '"traefik-ingress-controller" not in pod_info.stdout and ingress_install == "yes"'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- name: 尝试推送离线 heapster镜像(若执行失败,可忽略)
|
- name: 尝试推送离线 heapster镜像(若执行失败,可忽略)
|
||||||
copy: src={{ base_dir }}/down/{{ heapster_offline }} dest=/opt/kube/images/{{ heapster_offline }}
|
copy: src={{ base_dir }}/down/{{ heapster_offline }} dest=/opt/kube/images/{{ heapster_offline }}
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 导入 heapster的离线镜像(若执行失败,可忽略)
|
- name: 导入 heapster的离线镜像(若执行失败,可忽略)
|
||||||
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ heapster_offline }}"
|
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ heapster_offline }}"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('kube-node') == 1"
|
||||||
- name: 创建 heapster部署
|
- name: 创建 heapster部署
|
||||||
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster"
|
shell: "sleep 5; {{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster"
|
||||||
|
when: "hostvars[inventory_hostname]['group_names'].count('deploy') == 1"
|
||||||
when: '"heapster" not in pod_info.stdout and heapster_install == "yes"'
|
when: '"heapster" not in pod_info.stdout and heapster_install == "yes"'
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue