Browse Source
Refactor download role (#5697)
Refactor download role (#5697)
* download file * download containers * fix push image to nodes * pull if none image on host * fix * improve docker image tag checks. do not pull already cached images * rebase fix merge conflict * add support download_run_once when upgrade and scale cluster add some test with download_run_once * set default values to temp flag for every download cycle * add save,load abilty for containerd and crio when download_run_once=true * return redefine image save/load command to set_docker_image_facts.yml * move set command to set_container_facts * ctr in containerd_bin_dir * fix order of ctr image export arguments * temporary disable download_run_once for containerd and crio due https://github.com/containerd/containerd/issues/4075 * remove unused files * fix strict yaml linter warning and errors * refactor logical conditions to pull and cache container images * remove comment due lint check * document role * remove image_load_on_localhost, because cached images are always loaded to docker on remote sites * remove XXX from debug outputpull/5697/merge
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 269 additions and 330 deletions
Split View
Diff Options
-
17.gitlab-ci/packet.yml
-
6docs/downloads.md
-
8roles/download/defaults/main.yml
-
4roles/download/tasks/check_pull_required.yml
-
127roles/download/tasks/download_container.yml
-
95roles/download/tasks/download_file.yml
-
14roles/download/tasks/main.yml
-
78roles/download/tasks/prep_download.yml
-
10roles/download/tasks/prep_kubeadm_images.yml
-
11roles/download/tasks/set_container_facts.yml
-
54roles/download/tasks/set_docker_image_facts.yml
-
37roles/download/tasks/sync_container.yml
-
45roles/download/tasks/sync_file.yml
-
18roles/kubernetes/preinstall/tasks/0020-verify-settings.yml
-
3roles/kubespray-defaults/defaults/main.yaml
-
8scale.yml
-
14tests/files/packet_centos7-calico-ha-once-localhost.yml
-
2tests/files/packet_centos7-calico-ha.yml
-
10tests/files/packet_debian9-calico-upgrade-once.yml
-
29tests/files/packet_ubuntu18-flannel-containerd-once.yml
-
9upgrade-cluster.yml
@ -1,54 +0,0 @@ |
|||
--- |
|||
- name: Set if containers should be pulled by digest |
|||
set_fact: |
|||
pull_by_digest: >- |
|||
{%- if download.sha256 is defined and download.sha256 -%}true{%- else -%}false{%- endif -%} |
|||
|
|||
- name: Set pull_args |
|||
set_fact: |
|||
pull_args: >- |
|||
{%- if pull_by_digest %}{{ download.repo }}@sha256:{{ download.sha256 }}{%- else -%}{{ download.repo }}:{{ download.tag }}{%- endif -%} |
|||
|
|||
- name: Set image pull command for containerd |
|||
set_fact: |
|||
image_pull_command: "{{ bin_dir }}/crictl pull" |
|||
when: container_manager in ['crio' ,'containerd'] |
|||
|
|||
- name: Register docker images info |
|||
shell: "{{ image_info_command }}" |
|||
no_log: true |
|||
register: docker_images |
|||
failed_when: false |
|||
changed_when: false |
|||
check_mode: no |
|||
when: |
|||
- not download_always_pull |
|||
- group_names | intersect(download.groups) | length |
|||
|
|||
- name: Set if pull is required per container |
|||
set_fact: |
|||
pull_required: >- |
|||
{%- if pull_args in docker_images.stdout.split(',') %}false{%- else -%}true{%- endif -%} |
|||
when: |
|||
- not download_always_pull |
|||
- group_names | intersect(download.groups) | length |
|||
|
|||
- name: Does any host require container pull? |
|||
vars: |
|||
hosts_pull_required: "{{ hostvars.values() | map(attribute='pull_required') | select('defined') | list }}" |
|||
set_fact: |
|||
any_pull_required: "{{ True in hosts_pull_required }}" |
|||
run_once: true |
|||
changed_when: false |
|||
when: not download_always_pull |
|||
|
|||
- name: Check the local digest sha256 corresponds to the given image tag |
|||
assert: |
|||
that: "{{ download.repo }}:{{ download.tag }} in docker_images.stdout.split(',')" |
|||
when: |
|||
- group_names | intersect(download.groups) | length |
|||
- not download_always_pull |
|||
- not pull_required |
|||
- pull_by_digest |
|||
tags: |
|||
- asserts |
@ -1,37 +0,0 @@ |
|||
--- |
|||
- block: |
|||
- name: sync_container | Gather information about the current image (how to download, is it cached etc.) |
|||
import_tasks: set_container_facts.yml |
|||
tags: |
|||
- facts |
|||
|
|||
- name: sync_container | Upload container image to node |
|||
synchronize: |
|||
src: "{{ image_path_cached }}" |
|||
dest: "{{ image_path_final }}" |
|||
use_ssh_args: "{{ has_bastion | default(false) }}" |
|||
mode: push |
|||
delegate_facts: no |
|||
register: get_task |
|||
become: true |
|||
until: get_task is succeeded |
|||
retries: 4 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
when: |
|||
- ansible_os_family not in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] |
|||
|
|||
- name: sync_container | Load container image into docker |
|||
shell: "{{ docker_bin_dir }}/docker load < {{ image_path_final }}" |
|||
when: |
|||
- ansible_os_family not in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] |
|||
|
|||
- name: sync_container | Remove container image from cache |
|||
file: |
|||
state: absent |
|||
path: "{{ image_path_final }}" |
|||
when: |
|||
- not download_keep_remote_cache |
|||
- ansible_os_family not in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] |
|||
|
|||
tags: |
|||
- upload |
@ -1,45 +0,0 @@ |
|||
--- |
|||
- block: |
|||
- name: sync_file | Starting file sync of file |
|||
debug: |
|||
msg: "Starting file sync of file: {{ download.dest }}" |
|||
|
|||
- name: download_file | Set pathname of cached file |
|||
set_fact: |
|||
file_path_cached: "{{ download_cache_dir }}/{{ download.dest | basename }}" |
|||
tags: |
|||
- facts |
|||
|
|||
- name: sync_file | Create dest directory on node |
|||
file: |
|||
path: "{{ download.dest | dirname }}" |
|||
owner: "{{ download.owner | default(omit) }}" |
|||
mode: 0755 |
|||
state: directory |
|||
recurse: yes |
|||
|
|||
- name: sync_file | Upload file images to node |
|||
synchronize: |
|||
src: "{{ file_path_cached }}" |
|||
dest: "{{ download.dest }}" |
|||
use_ssh_args: "{{ has_bastion | default(false) }}" |
|||
mode: push |
|||
become: true |
|||
register: get_task |
|||
until: get_task is succeeded |
|||
retries: 4 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
when: |
|||
- ansible_os_family not in ["CoreOS", "Coreos", "Container Linux by CoreOS", "Flatcar", "Flatcar Container Linux by Kinvolk"] |
|||
|
|||
- name: sync_file | Set mode and owner |
|||
file: |
|||
path: "{{ download.dest }}" |
|||
mode: "{{ download.mode | default(omit) }}" |
|||
owner: "{{ download.owner | default(omit) }}" |
|||
|
|||
- name: sync_file | Extract file archives |
|||
include_tasks: "extract_file.yml" |
|||
|
|||
tags: |
|||
- upload |
@ -0,0 +1,14 @@ |
|||
--- |
|||
# Instance settings |
|||
cloud_image: centos-7 |
|||
mode: ha |
|||
|
|||
# Kubespray settings |
|||
kube_network_plugin: calico |
|||
download_localhost: true |
|||
download_run_once: true |
|||
deploy_netchecker: true |
|||
dns_min_replicas: 1 |
|||
typha_enabled: true |
|||
calico_backend: kdd |
|||
typha_secure: true |
@ -0,0 +1,10 @@ |
|||
--- |
|||
# Instance settings |
|||
cloud_image: debian-9 |
|||
mode: default |
|||
|
|||
# Kubespray settings |
|||
kube_network_plugin: calico |
|||
deploy_netchecker: true |
|||
dns_min_replicas: 1 |
|||
download_run_once: true |
@ -0,0 +1,29 @@ |
|||
--- |
|||
# Instance settings |
|||
cloud_image: ubuntu-1804 |
|||
mode: ha |
|||
vm_memory: 1600Mi |
|||
|
|||
# Kubespray settings |
|||
kubeadm_control_plane: true |
|||
kubeadm_certificate_key: 3998c58db6497dd17d909394e62d515368c06ec617710d02edea31c06d741085 |
|||
kube_proxy_mode: iptables |
|||
kube_network_plugin: flannel |
|||
helm_enabled: true |
|||
kubernetes_audit: true |
|||
container_manager: containerd |
|||
etcd_events_cluster_enabled: true |
|||
local_volume_provisioner_enabled: true |
|||
etcd_deployment_type: host |
|||
deploy_netchecker: true |
|||
dns_min_replicas: 1 |
|||
kube_encrypt_secret_data: true |
|||
ingress_nginx_enabled: true |
|||
cert_manager_enabled: true |
|||
# Disable as health checks are still unstable and slow to respond. |
|||
metrics_server_enabled: false |
|||
metrics_server_kubelet_insecure_tls: true |
|||
kube_token_auth: true |
|||
kube_basic_auth: true |
|||
enable_nodelocaldns: false |
|||
download_run_once: true |
Write
Preview
Loading…
Cancel
Save