-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load docker images only on image_registry host
- Loading branch information
Showing
11 changed files
with
121 additions
and
123 deletions.
There are no files selected for viewing
6 changes: 1 addition & 5 deletions
6
core/src/epicli/data/common/ansible/playbooks/image_registry.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
core/src/epicli/data/common/ansible/playbooks/roles/image_registry/tasks/load-image.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
- name: Set tag name with local image registry | ||
set_fact: | ||
new_image_tag: "{{ image_registry_address }}/{{ docker_image.name }}" | ||
changed_when: false | ||
when: | ||
- docker_image.name != specification.registry_image.name | ||
|
||
- name: Check if image is already loaded | ||
shell: >- | ||
docker images {{ new_image_tag if (docker_image.name != specification.registry_image.name) else docker_image.name }} | ||
--format {{ '{{' }}.ID{{ '}}' }} | ||
register: image_check | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
- name: Load image if does not exists | ||
block: | ||
- name: Download image file | ||
include_role: | ||
name: download | ||
tasks_from: download_image | ||
vars: | ||
file_name: "{{ docker_image.file_name }}" | ||
|
||
- name: Load image {{ docker_image.name }} | ||
become: yes | ||
shell: "docker load --input {{ download_directory }}/{{ docker_image.file_name }}" | ||
|
||
- name: Tag image {{ docker_image.name }} with {{ new_image_tag }} | ||
become: yes | ||
shell: "docker tag {{ docker_image.name }} {{ new_image_tag }}" | ||
when: | ||
- docker_image.name != specification.registry_image.name | ||
|
||
- name: Push image to registry {{ docker_image.name }} | ||
become: yes | ||
shell: "docker push {{ new_image_tag }}" | ||
when: | ||
- docker_image.name != specification.registry_image.name | ||
|
||
when: | ||
- image_check.stdout | length == 0 |
49 changes: 22 additions & 27 deletions
49
core/src/epicli/data/common/ansible/playbooks/roles/image_registry/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
--- | ||
- name: Check if image is already loaded | ||
shell: "docker images {{ specification.repository_image.name }} --format {{ '{{' }}.ID{{ '}}' }}" | ||
register: image_check | ||
ignore_errors: true | ||
changed_when: false | ||
|
||
- name: Load image if does not exists | ||
- name: Load docker images and run local registry | ||
block: | ||
- name: Download file | ||
include_role: | ||
name: download | ||
tasks_from: download_image | ||
vars: | ||
file_name: "{{ specification.repository_image.file_name }}" | ||
- name: Load registry image | ||
include_tasks: "load-image.yml" | ||
vars: | ||
docker_image: "{{ specification.registry_image }}" | ||
|
||
- name: Check if registry is running | ||
become: yes | ||
shell: docker ps | grep registry:2 | cat | ||
register: regitry_up_check | ||
check_mode: no | ||
|
||
- name: Load image {{ specification.repository_image.name }} | ||
become: yes | ||
shell: "docker load --input {{ download_directory }}/{{ specification.repository_image.file_name }}" | ||
when: image_check.stdout | length == 0 | ||
# todo run registry with SSL - generate/copy certs, mount it to registry container | ||
- name: Run registry | ||
become: yes | ||
shell: "docker run -d -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 -p 5000:5000 --restart=always --name epiphany-registry {{ specification.registry_image.name }}" | ||
when: regitry_up_check.stdout | length == 0 | ||
|
||
- name: Check if registry is running | ||
become: yes | ||
shell: docker ps | grep registry:2 | cat | ||
register: regitry_up_check | ||
check_mode: no | ||
- name: Include load-image.yml | ||
include_tasks: "load-image.yml" | ||
vars: | ||
docker_image: "{{ item }}" | ||
loop: "{{ specification.images_to_load }}" | ||
|
||
# todo run registry with SSL - generate/copy certs, mount it to registry container | ||
- name: Run registry | ||
become: yes | ||
shell: "docker run -d -e REGISTRY_HTTP_ADDR=0.0.0.0:5000 -p 5000:5000 --restart=always --name epiphany-registry {{ specification.repository_image.name }}" | ||
when: regitry_up_check.stdout | length == 0 | ||
when: not custom_image_registry_address |
35 changes: 0 additions & 35 deletions
35
core/src/epicli/data/common/ansible/playbooks/roles/kubernetes_common/tasks/load-image.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters