Skip to content

Commit

Permalink
Make helm chart version and helm load balancer IP configurable:
Browse files Browse the repository at this point in the history
This allows infrastructure to determine these values
instead of being hard coded.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed Oct 25, 2022
1 parent c7b74f1 commit 2baf962
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 5 additions & 2 deletions deploy/infrastructure/vagrant/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion deploy/infrastructure/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/"
Expand Down Expand Up @@ -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|
Expand Down
18 changes: 12 additions & 6 deletions deploy/stack/helm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 2baf962

Please sign in to comment.