From 05cf6bdec5cf03b23766cc7675d9294222e9a801 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Mon, 11 Jan 2021 11:15:52 -0600 Subject: [PATCH] fix(proxy): fixes up proxy issues This patch set fixes outstanding issues and ease the use of the AIO when deployed behind a corporate proxy. Signed-off-by: Tin Lam Change-Id: Ia80cce18e6a7d3105bfed3ec423bbbd678dbe019 --- doc/source/conf.py | 4 +- doc/source/install/jarvis/index.rst | 1 + doc/source/install/jarvis/proxy.rst | 46 +++++++++++++++++++ doc/source/install/jarvis/vagrant.rst | 18 +++++++- tools/deployment/vagrant/Vagrantfile | 14 +++++- tools/gate/deploy-k8s.sh | 26 ++++++++--- tools/gate/jarvis/010-pre-setup.sh | 18 ++++++++ tools/gate/jarvis/050-setup-development-ca.sh | 4 +- tools/gate/jarvis/600-deploy-tekton.sh | 20 +++++++- .../triggertemplates/triggertemplate.yaml | 8 +++- 10 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 doc/source/install/jarvis/proxy.rst create mode 100755 tools/gate/jarvis/010-pre-setup.sh diff --git a/doc/source/conf.py b/doc/source/conf.py index 9d0af1bd..91866c3f 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -28,8 +28,10 @@ author = 'Airship Charts Authors' # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'recommonmark' + 'recommonmark', + 'sphinx.ext.autosectionlabel' ] +autosectionlabel_prefix_document = True # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/source/install/jarvis/index.rst b/doc/source/install/jarvis/index.rst index fd935e3b..8eb178ad 100644 --- a/doc/source/install/jarvis/index.rst +++ b/doc/source/install/jarvis/index.rst @@ -9,3 +9,4 @@ Contents: introduction requirements-and-host-config vagrant + proxy diff --git a/doc/source/install/jarvis/proxy.rst b/doc/source/install/jarvis/proxy.rst new file mode 100644 index 00000000..b9ffaf0c --- /dev/null +++ b/doc/source/install/jarvis/proxy.rst @@ -0,0 +1,46 @@ +===================================== +Running Jarvis Behind Corporate Proxy +===================================== + +Environment Variables +===================== + +On the host machine, ensure the following environment variables are set with the appropriate proxy information: +``HTTP_PROXY``, ``HTTPS_PROXY``, and ``NO_PROXY``. You will also need to set the environment variable ``PRIVATE_NS`` +to an IP address of a corporate name server that will resolve internal URLs. + +Vagrant Plugin +============== + +To easily set up the Vagrant box's proxy setting, install the `vagrant_proxyconf`_ plugin by running: + +.. code:: bash + + $ vagrant plugin install vagrant-proxyconf + +``NO_PROXY`` Configuration +========================== + +In the event ``NO_PROXY`` is not specified, the following default value will be used: + +.. code:: + + localhost,127.0.0.1,10.96.0.0/12,192.168.49.0/24,192.168.99.0/24,10.0.2.15,10.244.0.0/16,172.28.0.0/30,.minikube.internal,.svc,.svc.cluster.local,jarvis.local + +Please note the following will need to be accounted for to avoid traffic being routed through the proxy: + +- Localhost: ``localhost`` and ``127.0.0.1``, +- Host and guest machine IP and name: ``jarvis``, ``jarvis.local``, etc., +- Minikube specific IP ranges (e.g. ``102.168.49.0/24``). See minikube's `documentation`_ for detail, +- Minikube places ``host.minikube.internal`` and ``control-plane.minikube.internal`` into ``/etc/hosts``, +- Kubernetes services' URLs with ending of ``.svc``, ``.cluster.local`` or ``.svc.cluster.local``, +- Kubernetes service cluster IP ranges: ``10.96.0.0/12`` or what's configured via ``--service-cluster-ip-range``. +- DNSMasq subnet range: ``172.28.0.0/30`` + +Installation +============ + +With the appropriate environment variables set, follow instruction :ref:`here `. + +.. _vagrant_proxyconf: http://tmatilai.github.io/vagrant-proxyconf/ +.. _documentation: https://minikube.sigs.k8s.io/docs/handbook/vpn_and_proxy/ diff --git a/doc/source/install/jarvis/vagrant.rst b/doc/source/install/jarvis/vagrant.rst index f00f3ec6..7292aeb5 100644 --- a/doc/source/install/jarvis/vagrant.rst +++ b/doc/source/install/jarvis/vagrant.rst @@ -2,4 +2,20 @@ Jarvis AIO Vagrant ================== -A vagrant file is provided under `tools/deployment/vagrant`, running `vagrant up` from this directory should bring up and deploy a copy of the Jarvis AIO. \ No newline at end of file +.. _aio-installation: + +Installation +============ + +A vagrant file is provided under ``tools/deployment/vagrant``, running +``vagrant up`` from this directory should bring up and deploy a copy of the +Jarvis AIO. + + +.. hint:: The recommended provider in the ``Vagrantfile`` is ``virtualbox``, + however, ``libvirt`` is included. + + +.. note:: This document does not cover the installation of vagrant. + Please refer to the instructions + `here `_. diff --git a/tools/deployment/vagrant/Vagrantfile b/tools/deployment/vagrant/Vagrantfile index 3a753709..e85f6543 100644 --- a/tools/deployment/vagrant/Vagrantfile +++ b/tools/deployment/vagrant/Vagrantfile @@ -4,6 +4,16 @@ Vagrant.configure("2") do |config| config.vm.box = "generic/ubuntu2004" + if Vagrant.has_plugin?("vagrant-proxyconf") + config.proxy.http = ENV["HTTP_PROXY"] + config.proxy.https = ENV["HTTPS_PROXY"] + if ENV["NO_PROXY"].nil? + config.proxy.no_proxy = "localhost,127.0.0.1,10.96.0.0/12,192.168.49.0/24,192.168.99.0/24,10.0.2.15,10.244.0.0/16,172.28.0.0/30,.minikube.internal,.svc,.svc.cluster.local,jarvis.local" + else + config.proxy.no_proxy = ENV["NO_PROXY"] + end + end + config.vm.synced_folder "../../../", "/airship_charts" config.vm.network "private_network", ip: "192.168.56.10" @@ -19,9 +29,10 @@ Vagrant.configure("2") do |config| vb.memory = 8192 end - config.vm.provision "shell", inline: <<-SHELL + config.vm.provision "shell", env: {"PRIVATE_NS" => ENV["PRIVATE_NS"]}, inline: <<-SHELL set -ex cd /airship_charts/ + ./tools/gate/jarvis/010-pre-setup.sh ./tools/gate/jarvis/050-setup-development-ca.sh ./tools/gate/jarvis/100-deploy-k8s.sh ./tools/gate/jarvis/200-deploy-support.sh @@ -29,6 +40,5 @@ Vagrant.configure("2") do |config| ./tools/gate/jarvis/400-deploy-harbor.sh ./tools/gate/jarvis/500-deploy-gerrit.sh ./tools/gate/jarvis/600-deploy-tekton.sh - SHELL end diff --git a/tools/gate/deploy-k8s.sh b/tools/gate/deploy-k8s.sh index 008bc3db..c83c7560 100755 --- a/tools/gate/deploy-k8s.sh +++ b/tools/gate/deploy-k8s.sh @@ -15,14 +15,16 @@ set -ex export DEBCONF_NONINTERACTIVE_SEEN=true export DEBIAN_FRONTEND=noninteractive +sudo swapoff -a + # Note: Including fix from https://review.opendev.org/c/openstack/openstack-helm-infra/+/763619/ echo "DefaultLimitMEMLOCK=16384" | sudo tee -a /etc/systemd/system.conf sudo systemctl daemon-reexec # Function to help generate a resolv.conf formatted file. # Arguments are positional: - # 1st is location of file to be generated - # 2nd is a custom nameserver that should be used exclusively if avalible. +# 1st is location of file to be generated +# 2nd is a custom nameserver that should be used exclusively if avalible. function generate_resolvconf() { local target target="${1}" @@ -34,7 +36,7 @@ nameserver ${priority_nameserver} EOF fi local nameservers_systemd - nameservers_systemd="$(awk '/^nameserver/ { print $2}' /run/systemd/resolve/resolv.conf | sed '/^127.0.0./d')" + nameservers_systemd="$(awk '/^nameserver/ { print $2 }' /run/systemd/resolve/resolv.conf | sed '/^127.0.0./d')" if [[ ${nameservers_systemd} ]]; then for nameserver in ${nameservers_systemd}; do sudo -E tee --append "${target}" <= 4.x + yq eval '(.spec.resourcetemplates[].spec.params[] | select(.name=="httpProxy")).value |= env(HTTP_PROXY)' -i ./tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml + yq eval '(.spec.resourcetemplates[].spec.params[] | select(.name=="httpsProxy")).value |= env(HTTPS_PROXY)' -i ./tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml + yq eval '(.spec.resourcetemplates[].spec.params[] | select(.name=="noProxy")).value |= env(NO_PROXY)' -i ./tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml + fi + kubectl -n tekton-pipelines apply -f ./tools/gate/jarvis/resources/tekton/yaml/role-resources/secret.yaml kubectl -n tekton-pipelines apply -f ./tools/gate/jarvis/resources/tekton/yaml/role-resources/serviceaccount.yaml kubectl -n tekton-pipelines apply -f ./tools/gate/jarvis/resources/tekton/yaml/role-resources/clustertriggerbinding-roles @@ -88,4 +106,4 @@ EOF kubectl -n tekton-pipelines get pipelinerun } -validate \ No newline at end of file +validate diff --git a/tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml b/tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml index 86a9197a..4dba5570 100644 --- a/tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml +++ b/tools/gate/jarvis/resources/tekton/yaml/triggertemplates/triggertemplate.yaml @@ -24,4 +24,10 @@ spec: - name: gitrevision value: $(tt.params.gitrevision) - name: message - value: $(tt.params.message) \ No newline at end of file + value: $(tt.params.message) + - name: httpProxy + value: "" + - name: httpsProxy + value: "" + - name: noProxy + value: "172.28.0.2,localhost,127.0.0.1,10.96.0.0/12,192.168.49.0/24,192.168.99.0/24,107.124.202.156,10.0.2.15,10.244.0.0/16,.minikube.internal,.svc,.svc.cluster.local,jarvis.local,jarvis"