更新containerd离线镜像导入脚本

pull/626/head
gjmzj 2019-05-21 23:47:49 +08:00
parent bdc49299de
commit 9b1ba6e5b5
6 changed files with 72 additions and 22 deletions

View File

@ -63,12 +63,19 @@
# 如果目录下有离线镜像就把它导入到node节点上 # 如果目录下有离线镜像就把它导入到node节点上
- name: 导入 calico的离线镜像若执行失败可忽略 - name: 导入 calico的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}"
when: 'item in image_info.stdout'
with_items: with_items:
- "pause_3.1.tar" - "pause_3.1.tar"
- "{{ calico_offline }}" - "{{ calico_offline }}"
ignore_errors: true ignore_errors: true
when: CONTAINER_RUNTIME == 'docker' when: "item in image_info.stdout and CONTAINER_RUNTIME == 'docker'"
- name: 导入 calico的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ item }}"
with_items:
- "pause_3.1.tar"
- "{{ calico_offline }}"
ignore_errors: true
when: "item in image_info.stdout and CONTAINER_RUNTIME == 'containerd'"
# 只需单节点执行一次 # 只需单节点执行一次
- name: 运行 calico网络 - name: 运行 calico网络

View File

@ -54,12 +54,19 @@
# 如果目录下有离线镜像就把它导入到node节点上 # 如果目录下有离线镜像就把它导入到node节点上
- name: 导入 cilium的离线镜像若执行失败可忽略 - name: 导入 cilium的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}"
when: 'item in image_info.stdout'
with_items: with_items:
- "pause_3.1.tar" - "pause_3.1.tar"
- "{{ cilium_offline }}" - "{{ cilium_offline }}"
ignore_errors: true ignore_errors: true
when: CONTAINER_RUNTIME == 'docker' when: "item in image_info.stdout and CONTAINER_RUNTIME == 'docker'"
- name: 导入 cilium的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ item }}"
with_items:
- "pause_3.1.tar"
- "{{ cilium_offline }}"
ignore_errors: true
when: "item in image_info.stdout and CONTAINER_RUNTIME == 'containerd'"
# 只需单节点执行一次 # 只需单节点执行一次
- name: 运行 cilium网络 - name: 运行 cilium网络

View File

@ -10,8 +10,11 @@
- 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: 'traefik_offline in image_info.stdout' when: 'traefik_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入 traefik的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ traefik_offline }}"
when: 'traefik_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建 traefik部署 - name: 创建 traefik部署
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik/traefik-ingress.yaml" shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/traefik/traefik-ingress.yaml"
@ -32,8 +35,11 @@
- name: 导入 nginx_ingress的离线镜像若执行失败可忽略 - name: 导入 nginx_ingress的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ nginx_ingress_offline }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ nginx_ingress_offline }}"
when: 'nginx_ingress_offline in image_info.stdout' when: 'nginx_ingress_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入 nginx_ingress的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ nginx_ingress_offline }}"
when: 'nginx_ingress_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建 nginx_ingress部署 - name: 创建 nginx_ingress部署
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/nginx-ingress/nginx-ingress.yaml" shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/ingress/nginx-ingress/nginx-ingress.yaml"

View File

@ -36,8 +36,11 @@
- 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: 'dns_offline in image_info.stdout' when: 'dns_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入{{ dns_backend }}的离线镜像(若执行失败,可忽略)
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ dns_offline }}"
when: 'dns_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建{{ dns_backend }}部署 - name: 创建{{ dns_backend }}部署
shell: "{{ bin_dir }}/kubectl apply -f /opt/kube/kube-system/{{ dns_backend }}" shell: "{{ bin_dir }}/kubectl apply -f /opt/kube/kube-system/{{ dns_backend }}"
@ -61,8 +64,11 @@
- 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: 'metricsserver_offline in image_info.stdout' when: 'metricsserver_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入 metrics-server的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ metricsserver_offline }}"
when: 'metricsserver_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建 metrics-server部署 - name: 创建 metrics-server部署
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server" shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/metrics-server"
@ -84,8 +90,11 @@
- 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: 'dashboard_offline in image_info.stdout' when: 'dashboard_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入 dashboard的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ dashboard_offline }}"
when: 'dashboard_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建 dashboard部署 - name: 创建 dashboard部署
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard && \ shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/dashboard && \
@ -110,8 +119,11 @@
- 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: 'heapster_offline in image_info.stdout' when: 'heapster_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: CONTAINER_RUNTIME == 'docker'
- name: 导入 heapster的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ heapster_offline }}"
when: 'heapster_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 创建 heapster部署 - name: 创建 heapster部署
shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster/heapster.yaml" shell: "{{ bin_dir }}/kubectl apply -f {{ base_dir }}/manifests/heapster/heapster.yaml"
@ -132,8 +144,11 @@
- name: 导入 metallb的离线镜像若执行失败可忽略 - name: 导入 metallb的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metallb_offline }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ metallb_offline }}"
when: 'metallb_offline in image_info.stdout' when: 'metallb_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
when: 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 - name: 生成 metallb 相关 manifests
template: src=metallb/{{ item }}.j2 dest=/opt/kube/kube-system/{{ item }} template: src=metallb/{{ item }}.j2 dest=/opt/kube/kube-system/{{ item }}

View File

@ -45,12 +45,19 @@
# 如果目录下有离线镜像就把它导入到node节点上 # 如果目录下有离线镜像就把它导入到node节点上
- name: 导入 flannel的离线镜像若执行失败可忽略 - name: 导入 flannel的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}"
when: 'item in image_info.stdout'
with_items: with_items:
- "pause_3.1.tar" - "pause_3.1.tar"
- "{{ flannel_offline }}" - "{{ flannel_offline }}"
ignore_errors: true ignore_errors: true
when: CONTAINER_RUNTIME == 'docker' when: "item in image_info.stdout and CONTAINER_RUNTIME == 'docker'"
- name: 导入 flannel的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ item }}"
with_items:
- "pause_3.1.tar"
- "{{ flannel_offline }}"
ignore_errors: true
when: "item in image_info.stdout and CONTAINER_RUNTIME == 'containerd'"
# 只需单节点执行一次 # 只需单节点执行一次
- name: 运行 flannel网络 - name: 运行 flannel网络

View File

@ -61,13 +61,21 @@
# 如果目录下有离线镜像就把它导入到node节点上 # 如果目录下有离线镜像就把它导入到node节点上
- name: 导入 kube-router的离线镜像若执行失败可忽略 - name: 导入 kube-router的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}" shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ item }}"
when: 'item in image_info.stdout'
with_items: with_items:
- "pause_3.1.tar" - "pause_3.1.tar"
- "{{ kuberouter_offline }}" - "{{ kuberouter_offline }}"
- "{{ busybox_offline }}" - "{{ busybox_offline }}"
ignore_errors: true ignore_errors: true
when: CONTAINER_RUNTIME == 'docker' when: "item in image_info.stdout and CONTAINER_RUNTIME == 'docker'"
- name: 导入 kube-router的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ item }}"
with_items:
- "pause_3.1.tar"
- "{{ kuberouter_offline }}"
- "{{ busybox_offline }}"
ignore_errors: true
when: "item in image_info.stdout and CONTAINER_RUNTIME == 'containerd'"
# 只需单节点执行一次 # 只需单节点执行一次
- name: 运行 kube-router DaemonSet - name: 运行 kube-router DaemonSet