fix nodelocaldns 镜像推送

pull/992/head
gjmzj 2021-01-19 20:20:05 +08:00
parent 63a7e6d7ee
commit e51aa3603d
5 changed files with 29 additions and 21 deletions

View File

@ -17,7 +17,6 @@
copy: src={{ item }} dest=/opt/kube/images/
with_fileglob:
- "{{ base_dir }}/down/coredns*.tar"
- "{{ base_dir }}/down/k8s-dns-node-cache*.tar"
- "{{ base_dir }}/down/dashboard*.tar"
- "{{ base_dir }}/down/metrics-scraper*.tar"
- "{{ base_dir }}/down/metrics-server*.tar"
@ -25,11 +24,11 @@
ignore_errors: true
- name: 导入离线镜像(若执行失败,可忽略)
shell: ls /opt/kube/images/*.tar |while read n;do {{ bin_dir }}/docker load -i $n ;done
shell: "for image in $(echo /opt/kube/images/*.tar); do {{ bin_dir }}/docker load -i $image; done;"
ignore_errors: true
when: "CONTAINER_RUNTIME == 'docker'"
- name: 导入离线镜像(若执行失败,可忽略)
shell: ls /opt/kube/images/*.tar |while read n;do {{ bin_dir }}/ctr -n=k8s.io images import $n ;done
shell: "for image in $(echo /opt/kube/images/*.tar); do {{ bin_dir }}/ctr -n=k8s.io images import $image; done;"
ignore_errors: true
when: "CONTAINER_RUNTIME == 'containerd'"

View File

@ -1,19 +1,3 @@
- name: 尝试推送离线dnscache镜像若执行失败可忽略
copy: src={{ base_dir }}/down/{{ dnscache_offline }} dest=/opt/kube/images/{{ dnscache_offline }}
when: 'dnscache_offline in download_info.stdout'
- name: 获取dnscache离线镜像推送情况
command: "ls /opt/kube/images"
register: image_info
- name: 导入dnscache的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dnscache_offline }}"
when: 'dnscache_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
- name: 导入dnscache的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ dnscache_offline }}"
when: 'dnscache_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
- name: 准备dnscache的部署文件
template: src=dns/nodelocaldns-ipvs.yaml.j2 dest={{ cluster_dir }}/yml/nodelocaldns.yaml
when: "PROXY_MODE == 'ipvs'"

View File

@ -4,8 +4,6 @@ CLUSTER_DNS_SVC_IP: "{{ SERVICE_CIDR | ipaddr('net') | ipaddr(2) | ipaddr('addre
#
coredns_offline: "coredns_{{ corednsVer }}.tar"
dnscache_offline: "k8s-dns-node-cache_{{ dnsNodeCacheVer }}.tar"
metricsserver_offline: "metrics-server_{{ metricsVer }}.tar"
dashboard_offline: "dashboard_{{ dashboardVer }}.tar"

View File

@ -101,3 +101,27 @@
- name: 设置node节点role
shell: "{{ bin_dir }}/kubectl label node {{ inventory_hostname }} kubernetes.io/role=node --overwrite"
ignore_errors: true
- block:
- name: 获取已下载离线镜像信息
command: "ls {{ base_dir }}/down"
register: download_info
connection: local
run_once: true
- name: 尝试推送离线dnscache镜像若执行失败可忽略
copy: src={{ base_dir }}/down/{{ dnscache_offline }} dest=/opt/kube/images/{{ dnscache_offline }}
when: 'dnscache_offline in download_info.stdout'
- name: 获取dnscache离线镜像推送情况
command: "ls /opt/kube/images"
register: image_info
- name: 导入dnscache的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/docker load -i /opt/kube/images/{{ dnscache_offline }}"
when: 'dnscache_offline in image_info.stdout and CONTAINER_RUNTIME == "docker"'
- name: 导入dnscache的离线镜像若执行失败可忽略
shell: "{{ bin_dir }}/ctr -n=k8s.io images import /opt/kube/images/{{ dnscache_offline }}"
when: 'dnscache_offline in image_info.stdout and CONTAINER_RUNTIME == "containerd"'
when: "ENABLE_LOCAL_DNS_CACHE|bool"

View File

@ -12,5 +12,8 @@ KUBE_APISERVER: "{%- if inventory_hostname in groups['kube_master'] -%} \
{%- endif -%} \
{%- endif -%}"
# node local dns cache 离线镜像
dnscache_offline: "k8s-dns-node-cache_{{ dnsNodeCacheVer }}.tar"
# 增加/删除 master 节点时node 节点需要重新配置 haproxy
MASTER_CHG: "no"