Skip to content

Commit

Permalink
Bug 1822127 - Create secret with proxy config if setting present (#294)
Browse files Browse the repository at this point in the history
* Create secret with proxy config if setting present

* Add label to proxy secret and gen name

* Quote label true value

* Revert to using static name

* generateName is a headache with the k8s module since its trying to
  patch a resource
  • Loading branch information
eriknelson committed Apr 9, 2020
1 parent c5343c3 commit c8dbd42
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion roles/migrationcontroller/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ configmap_secret: ""
controller_state: absent
deprecated_cors_configuration: false
cors_origins: []
proxy_secret_name: "migration-proxy-"
http_proxy: "{{ lookup( 'env', 'HTTP_PROXY') }}"
https_proxy: "{{ lookup( 'env', 'HTTPS_PROXY') }}"
no_proxy: "{{ lookup( 'env', 'NO_PROXY') }}"
image_pull_policy: Always
mig_controller_image: "{{ registry }}/{{ project }}/{{ mig_controller_repo }}"
mig_controller_limits_cpu: "100m"
Expand Down Expand Up @@ -33,7 +35,6 @@ mig_ui_version: "{{ snapshot_tag | default(lookup( 'env', 'MIG_UI_TAG')) }}"
migration_registry_image: "{{ registry }}/{{ project }}/{{ migration_registry_repo }}"
migration_registry_repo: "{{ lookup( 'env', 'MIGRATION_REGISTRY_REPO') }}"
migration_registry_version: "{{ lookup( 'env', 'MIGRATION_REGISTRY_TAG') }}"
no_proxy: "{{ lookup( 'env', 'NO_PROXY') }}"
olm_managed: false
registry: "{{ lookup( 'env', 'REGISTRY') }}"
project: "{{ lookup( 'env', 'PROJECT') }}"
Expand Down
6 changes: 6 additions & 0 deletions roles/migrationcontroller/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@
definition: "{{ lookup('template', 'velero_supporting.yml.j2') }}"
when: not olm_managed

- name: "Create proxy configuration secret if proxy is configured"
k8s:
state: "present"
definition: "{{ lookup('template', 'proxy_secret.yml.j2') }}"
when: http_proxy != "" or https_proxy != "" or no_proxy != ""

- name: "Set up velero controller"
k8s:
state: "{{ velero_state }}"
Expand Down
19 changes: 19 additions & 0 deletions roles/migrationcontroller/templates/proxy_secret.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: v1
kind: Secret
metadata:
name: {{ proxy_secret_name }}
namespace: {{ mig_namespace }}
labels:
migration-proxy-config: "true"
type: Opaque
data:
{% if http_proxy|length >0 %}
http_proxy: {{ http_proxy|b64encode }}
{% endif %}
{% if https_proxy|length >0 %}
https_proxy: {{ https_proxy|b64encode }}
{% endif %}
{% if no_proxy|length >0 %}
no_proxy: {{ no_proxy|b64encode }}
{% endif %}

0 comments on commit c8dbd42

Please sign in to comment.