techno-tim / k3s-ansible

The easiest way to bootstrap a self-hosted High Availability Kubernetes cluster. A fully automated HA k3s etcd install with kube-vip, MetalLB, and more. Build. Destroy. Repeat.
https://technotim.live/posts/k3s-etcd-ansible/
Apache License 2.0
2.41k stars 1.05k forks source link

Add option for install behind http_proxy #384

Closed balazshasprai closed 1 year ago

balazshasprai commented 1 year ago

Proposed Changes

Added the option to install from behind an http proxy.

If configured (false by default), it puts your http_proxy + https_proxy + no_proxy env vars into a k3s(-agent).service.d/http_proxy.conf file, before anything gets installed. This way k3s can access the internet for images etc through the proxy.

Also added env vars to the playbooks, defaulted to '', so ansible can still download the binaries and manifests even if you're behind a proxy.

In the reset main.yml I thought I'd add a conditional task. So it doesn't try to remove the http_proxy files and errors out when you don't have them enabled/installed.

(I've ran and re-ran the checks a bunch of times on my fork, not sure what's up with the hosted runners. The majority of the time it failed with the gurumeditation state error and when it did go past that, it couldn't resolve DNS. I've ran this both with http_proxy enabled and disabled, installed fine in both environments.)

Checklist

timothystewart6 commented 1 year ago

Thank you! Sorry about the CI woes. It's been pretty flaky lately.

balazshasprai commented 1 year ago

Yeah no worries. I thought it might override the already existing proxy env vars on the runner/vagrant hosts, but according to this (printing out the ansible_facts), they're not set. So that shouldn't(?) be an issue? Now I'm thinking it might not like the default(''), checks are currently running for a default({}) instead. If that works, I'll tidy up the environment: in the playbooks a bit and add a new commit to this

balazshasprai commented 1 year ago

Seems like it's fine now, if vagrant decides to cooperate. Please retry the checks, reran them on the fork, they're all nice and green