diff --git a/deploy/infrastructure/vagrant/.env b/deploy/infrastructure/vagrant/.env index d31b8e09..5c4dfdf2 100644 --- a/deploy/infrastructure/vagrant/.env +++ b/deploy/infrastructure/vagrant/.env @@ -5,7 +5,10 @@ MACHINE1_IP=192.168.56.43 MACHINE1_MAC=08:00:27:9e:f5:3a #USE_POSTGRES=true -USE_POSTGRES=true +USE_POSTGRES= # USE_HELM=true -USE_HELM= +USE_HELM=true + +# https://github.com/tinkerbell/charts/pkgs/container/charts%2Fstack +HELM_CHART_VERSION=0.1.1 diff --git a/deploy/infrastructure/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile index b147f4d0..fca28a67 100644 --- a/deploy/infrastructure/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -16,6 +16,8 @@ MACHINE1_IP = ENV["MACHINE1_IP"] || "192.168.56.43" MACHINE1_MAC = (ENV["MACHINE1_MAC"] || "08:00:27:9E:F5:3A").downcase USE_POSTGRES = ENV["USE_POSTGRES"] || "" USE_HELM = ENV["USE_HELM"] || "" +HELM_CHART_VERSION = ENV["HELM_CHART_VERSION"] || "0.1.1" +HELM_LOADBALANCER_INTERFACE = ENV["HELM_LOADBALANCER_INTERFACE"] || "eth1" STACK_OPT = "compose/" STACK_BASE_DIR = "../../stack/" STACK_DIR = STACK_BASE_DIR + STACK_OPT @@ -28,6 +30,10 @@ Vagrant.configure("2") do |config| end config.vm.define "provisioner" do |provisioner| + if USE_POSTGRES == "true" && USE_HELM == "true" + puts "USE_POSTGRES and USE_HELM cannot both be true" + abort + end if USE_HELM == "true" STACK_DIR = STACK_BASE_DIR + "helm/" DEST_DIR = DEST_DIR_BASE + "helm/" @@ -55,7 +61,7 @@ Vagrant.configure("2") do |config| if USE_POSTGRES == "true" DEST_DIR = DEST_DIR_BASE + STACK_OPT + "postgres" end - provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR, LOADBALANCER_IP] + provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR, LOADBALANCER_IP, HELM_CHART_VERSION, HELM_LOADBALANCER_INTERFACE] end config.vm.define :machine1, autostart: false do |machine1| diff --git a/deploy/stack/helm/setup.sh b/deploy/stack/helm/setup.sh index 6f7602b9..e8bd9589 100644 --- a/deploy/stack/helm/setup.sh +++ b/deploy/stack/helm/setup.sh @@ -58,16 +58,19 @@ kubectl_for_vagrant_user() { helm_customize_values() { local loadbalancer_ip=$1 + local helm_chart_version=$2 - helm inspect values oci://ghcr.io/tinkerbell/charts/stack --version 0.1.1 >/tmp/stack-values.yaml + helm inspect values oci://ghcr.io/tinkerbell/charts/stack --version "$helm_chart_version" >/tmp/stack-values.yaml sed -i "s/192.168.2.111/${loadbalancer_ip}/g" /tmp/stack-values.yaml } helm_install_tink_stack() { local namespace=$1 + local version=$2 + local interface=$3 trusted_proxies=$(kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}' | tr ' ' ',') - helm install stack-release oci://ghcr.io/tinkerbell/charts/stack --version 0.1.1 --create-namespace --namespace "$namespace" --wait --set "boots.boots.trustedProxies=${trusted_proxies}" --set "hegel.hegel.trustedProxies=${trusted_proxies}" --set "kubevip.interface=eth1" --values /tmp/stack-values.yaml + helm install stack-release oci://ghcr.io/tinkerbell/charts/stack --version "$version" --create-namespace --namespace "$namespace" --wait --set "boots.boots.trustedProxies=${trusted_proxies}" --set "hegel.hegel.trustedProxies=${trusted_proxies}" --set "kubevip.interface=$interface" --values /tmp/stack-values.yaml } apply_manifests() { @@ -100,14 +103,15 @@ run_helm() { local worker_mac=$3 local manifests_dir=$4 local loadbalancer_ip=$5 + local helm_chart_version=$6 + local loadbalancer_interface=$7 local namespace="tink-system" install_k3d start_k3d install_helm - helm_customize_values "$loadbalancer_ip" - # do we need to wait til cluster is ready? TBD - helm_install_tink_stack "$namespace" + helm_customize_values "$loadbalancer_ip" "$helm_chart_version" + helm_install_tink_stack "$namespace" "$helm_chart_version" "$loadbalancer_interface" apply_manifests "$worker_ip" "$worker_mac" "$manifests_dir" "$loadbalancer_ip" "$namespace" kubectl_for_vagrant_user } @@ -118,12 +122,14 @@ main() { local worker_mac=$3 local manifests_dir=$4 local loadbalancer_ip=$5 + local helm_chart_version=$6 + local loadbalancer_interface=$7 update_apt install_docker install_kubectl - run_helm "$host_ip" "$worker_ip" "$worker_mac" "$manifests_dir"/manifests "$loadbalancer_ip" + run_helm "$host_ip" "$worker_ip" "$worker_mac" "$manifests_dir"/manifests "$loadbalancer_ip" "$helm_chart_version" "$loadbalancer_interface" } if [[ ${BASH_SOURCE[0]} == "$0" ]]; then