forked from gluster/gluster-kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This introduces the ability to configure an nginx proxy that will redirect traffic destined for gcr.io to a custom registry. This allows the user to push copies of the container images from gcr.io to their custom registry and then pull them in subsequent deployments. Signed-off-by: Jose A. Rivera <[email protected]>
- Loading branch information
Showing
12 changed files
with
154 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [[ "${1}" != "present" ]] && [[ "${1}" != "absent" ]]; then | ||
echo "Error: must supply state, either 'present' or 'absent'" | ||
echo " Example: ./${0} absent" | ||
exit 1 | ||
fi | ||
|
||
ansible-playbook -i /vagrant/ansible-inventory -e gcr_proxy_state="${1}" gcr_proxy.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,21 @@ | ||
- hosts: master | ||
become: yes | ||
become_method: sudo | ||
vars_files: | ||
- "global_vars.yml" | ||
tasks: | ||
- include_role: | ||
name: master | ||
tasks_from: gcr_proxy.yml | ||
when: custom_registry_gcr | default(false) | ||
|
||
- hosts: nodes | ||
become: yes | ||
become_method: sudo | ||
vars_files: | ||
- "global_vars.yml" | ||
tasks: | ||
- include_role: | ||
name: nodes | ||
tasks_from: gcr_proxy.yml | ||
when: custom_registry_gcr | default(false) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
custom_registry_add: false | ||
custom_registry_gcr: false | ||
gcr_proxy_nginx: 0.8 |
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,58 @@ | ||
--- | ||
- name: install ansible-docker depencendies | ||
yum: | ||
name: "{{ item }}" | ||
state: present | ||
disable_gpg_check: yes | ||
with_items: | ||
- docker-python | ||
|
||
- name: check for nginx-slim image | ||
uri: | ||
url: "http://{{ custom_registry }}/v2/google_containers/nginx-slim/manifests/{{ gcr_proxy_nginx }}" | ||
status_code: "200,404" | ||
register: nginx_exists | ||
|
||
- name: pull nginx-slim image (custom) | ||
docker_image: | ||
repository: "{{ custom_registry }}" | ||
name: google_containers/nginx-slim | ||
tag: "{{ gcr_proxy_nginx }}" | ||
when: | ||
- nginx_exists.status == "200" | ||
|
||
- name: pull nginx-slim image (gcr.io) | ||
docker_image: | ||
repository: gcr.io | ||
name: google_containers/nginx-slim | ||
tag: "{{ gcr_proxy_nginx }}" | ||
when: | ||
- nginx_exists.status == "404" | ||
|
||
- name: push nginx-slim image | ||
docker_image: | ||
repository: "{{ custom_registry }}" | ||
name: google_containers/nginx-slim | ||
tag: "{{ gcr_proxy_nginx }}" | ||
push: yes | ||
when: | ||
- nginx_exists.status == "404" | ||
|
||
- name: copy nginx.conf | ||
template: src=nginx.conf.j2 dest=/vagrant/nginx.conf force=yes mode=0644 | ||
|
||
- name: start proxy container | ||
docker_container: | ||
name: gcr_proxy | ||
image: "google_containers/nginx-slim:{{ gcr_proxy_nginx }}" | ||
ports: | ||
- "80:80" | ||
state: started | ||
restart_policy: always | ||
volumes: | ||
- /vagrant/nginx.conf:/etc/nginx/nginx.conf:ro | ||
|
||
- lineinfile: | ||
path: /etc/hosts | ||
state: "{{ gcr_proxy_state | default('present') }}" | ||
line: "{{ vagrant_master }} gcr.io" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
events { | ||
worker_connections 1024; | ||
} | ||
http { | ||
upstream my_gcr { | ||
server {{ custom_registry }}; | ||
} | ||
server { | ||
listen *:80; | ||
location / { | ||
proxy_http_version 1.1; | ||
proxy_buffering off; | ||
proxy_set_header Proxy ""; | ||
proxy_pass http://my_gcr; | ||
} | ||
} | ||
} |
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,5 @@ | ||
--- | ||
- lineinfile: | ||
path: /etc/hosts | ||
state: "{{ gcr_proxy_state | default('present') }}" | ||
line: "{{ vagrant_master }} gcr.io" |
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