Skip to content

Commit

Permalink
Add option for install behind http_proxy (#384)
Browse files Browse the repository at this point in the history
* Add option for install behind http_proxy

* Tidy up http_proxy usage
  • Loading branch information
balazshasprai authored Oct 21, 2023
1 parent 95b2836 commit e880f08
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 0 deletions.
6 changes: 6 additions & 0 deletions inventory/sample/group_vars/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@ custom_registries_yaml: |
auth:
username: yourusername
password: yourpassword
# Only enable and configure these if you access the internet through a proxy
# proxy_env:
# HTTP_PROXY: "http://proxy.domain.local:3128"
# HTTPS_PROXY: "http://proxy.domain.local:3128"
# NO_PROXY: "*.domain.local,127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
18 changes: 18 additions & 0 deletions roles/k3s_agent/tasks/http_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: Create k3s.service.d directory
file:
path: '{{ systemd_dir }}/k3s.service.d'
state: directory
owner: root
group: root
mode: '0755'


- name: Copy K3s http_proxy conf file
template:
src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
owner: root
group: root
mode: '0755'
4 changes: 4 additions & 0 deletions roles/k3s_agent/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined

- name: Copy K3s service file
template:
src: "k3s.service.j2"
Expand Down
4 changes: 4 additions & 0 deletions roles/k3s_agent/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
18 changes: 18 additions & 0 deletions roles/k3s_server/tasks/http_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---

- name: Create k3s.service.d directory
file:
path: '{{ systemd_dir }}/k3s.service.d'
state: directory
owner: root
group: root
mode: '0755'


- name: Copy K3s http_proxy conf file
template:
src: "http_proxy.conf.j2"
dest: "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
owner: root
group: root
mode: '0755'
4 changes: 4 additions & 0 deletions roles/k3s_server/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
failed_when: false
changed_when: false

- name: Deploy K3s http_proxy conf
include_tasks: http_proxy.yml
when: proxy_env is defined

- name: Deploy vip manifest
include_tasks: vip.yml

Expand Down
4 changes: 4 additions & 0 deletions roles/k3s_server/templates/http_proxy.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Service]
Environment=HTTP_PROXY={{ proxy_env.HTTP_PROXY }}
Environment=HTTPS_PROXY={{ proxy_env.HTTPS_PROXY }}
Environment=NO_PROXY={{ proxy_env.NO_PROXY }}
9 changes: 9 additions & 0 deletions roles/reset/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@
- /var/lib/rancher/
- /var/lib/cni/

- name: Remove K3s http_proxy files
file:
name: "{{ item }}"
state: absent
with_items:
- "{{ systemd_dir }}/k3s.service.d"
- "{{ systemd_dir }}/k3s-node.service.d"
when: proxy_env is defined

- name: Reload daemon_reload
systemd:
daemon_reload: yes
Expand Down
5 changes: 5 additions & 0 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
hosts: proxmox
gather_facts: true
become: yes
environment: "{{ proxy_env | default({}) }}"
roles:
- role: proxmox_lxc
when: proxmox_lxc_configure

- name: Prepare k3s nodes
hosts: k3s_cluster
gather_facts: yes
environment: "{{ proxy_env | default({}) }}"
roles:
- role: lxc
become: true
Expand All @@ -26,18 +28,21 @@

- name: Setup k3s servers
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server
become: true

- name: Setup k3s agents
hosts: node
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_agent
become: true

- name: Configure k3s cluster
hosts: master
environment: "{{ proxy_env | default({}) }}"
roles:
- role: k3s_server_post
become: true

0 comments on commit e880f08

Please sign in to comment.