From 03692ff2b2b827307065817bcaf148edde851b10 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Fri, 21 Oct 2022 20:16:50 +0000 Subject: [PATCH 1/8] Reorganize into `infrastructure` and `stack` components: This clarifies the architectural design for the Sandbox. Signed-off-by: Jacob Weinstock --- .gitignore | 20 +-- CONTRIBUTING.md | 7 + .../terraform/.terraform.lock.hcl | 0 .../terraform/cloud-config.cfg | 0 deploy/{ => infrastructure}/terraform/main.tf | 0 .../{ => infrastructure}/terraform/outputs.tf | 0 .../{ => infrastructure}/terraform/setup.sh | 0 .../terraform/variables.tf | 0 .../terraform/versions.tf | 0 .../{ => infrastructure}/vagrant/Vagrantfile | 34 +++-- deploy/{ => stack}/compose/.env | 0 deploy/{ => stack}/compose/docker-compose.yml | 0 .../compose/manifests/hardware.yaml | 3 +- .../compose/manifests/template.yaml | 1 - .../compose/manifests/ubuntu-download.yaml | 13 ++ .../compose/manifests/workflow.yaml | 1 - .../postgres/create-tink-records/create.sh | 0 .../hardware/hardware-equinix-metal.json | 0 .../manifests/hardware/hardware.json | 0 .../template/ubuntu-equinix-metal.yaml | 0 .../manifests/template/ubuntu.yaml | 0 .../compose/postgres/docker-compose.yml | 0 .../fetch-and-convert-ubuntu-img/fetch.sh | 0 .../compose/postgres/fetch-osie/fetch.sh | 0 .../generate-tls-certs/ca-config.json | 0 .../postgres/generate-tls-certs/ca-csr.json | 0 .../postgres/generate-tls-certs/csr.json | 0 .../postgres/generate-tls-certs/generate.sh | 0 .../registry_images.txt | 0 .../sync-images-to-local-registry/upload.sh | 0 .../{ => stack}/compose/scripts/fetch-osie.sh | 0 .../compose/scripts/fetch-ubuntu.sh | 0 deploy/{vagrant => stack/compose}/setup.sh | 5 +- deploy/{ => stack}/compose/state/.keep | 0 deploy/{vagrant => stack/compose}/tink | 0 deploy/stack/helm/setup.sh | 123 ++++++++++++++++++ docs/quickstarts/VAGRANTLVIRT.md | 2 +- 37 files changed, 180 insertions(+), 29 deletions(-) rename deploy/{ => infrastructure}/terraform/.terraform.lock.hcl (100%) rename deploy/{ => infrastructure}/terraform/cloud-config.cfg (100%) rename deploy/{ => infrastructure}/terraform/main.tf (100%) rename deploy/{ => infrastructure}/terraform/outputs.tf (100%) rename deploy/{ => infrastructure}/terraform/setup.sh (100%) rename deploy/{ => infrastructure}/terraform/variables.tf (100%) rename deploy/{ => infrastructure}/terraform/versions.tf (100%) rename deploy/{ => infrastructure}/vagrant/Vagrantfile (73%) rename deploy/{ => stack}/compose/.env (100%) rename deploy/{ => stack}/compose/docker-compose.yml (100%) rename deploy/{ => stack}/compose/manifests/hardware.yaml (93%) rename deploy/{ => stack}/compose/manifests/template.yaml (99%) create mode 100644 deploy/stack/compose/manifests/ubuntu-download.yaml rename deploy/{ => stack}/compose/manifests/workflow.yaml (90%) rename deploy/{ => stack}/compose/postgres/create-tink-records/create.sh (100%) rename deploy/{ => stack}/compose/postgres/create-tink-records/manifests/hardware/hardware-equinix-metal.json (100%) rename deploy/{ => stack}/compose/postgres/create-tink-records/manifests/hardware/hardware.json (100%) rename deploy/{ => stack}/compose/postgres/create-tink-records/manifests/template/ubuntu-equinix-metal.yaml (100%) rename deploy/{ => stack}/compose/postgres/create-tink-records/manifests/template/ubuntu.yaml (100%) rename deploy/{ => stack}/compose/postgres/docker-compose.yml (100%) rename deploy/{ => stack}/compose/postgres/fetch-and-convert-ubuntu-img/fetch.sh (100%) rename deploy/{ => stack}/compose/postgres/fetch-osie/fetch.sh (100%) rename deploy/{ => stack}/compose/postgres/generate-tls-certs/ca-config.json (100%) rename deploy/{ => stack}/compose/postgres/generate-tls-certs/ca-csr.json (100%) rename deploy/{ => stack}/compose/postgres/generate-tls-certs/csr.json (100%) rename deploy/{ => stack}/compose/postgres/generate-tls-certs/generate.sh (100%) rename deploy/{ => stack}/compose/postgres/sync-images-to-local-registry/registry_images.txt (100%) rename deploy/{ => stack}/compose/postgres/sync-images-to-local-registry/upload.sh (100%) rename deploy/{ => stack}/compose/scripts/fetch-osie.sh (100%) rename deploy/{ => stack}/compose/scripts/fetch-ubuntu.sh (100%) rename deploy/{vagrant => stack/compose}/setup.sh (95%) rename deploy/{ => stack}/compose/state/.keep (100%) rename deploy/{vagrant => stack/compose}/tink (100%) create mode 100644 deploy/stack/helm/setup.sh diff --git a/.gitignore b/.gitignore index def36486..bcc6c64e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ # hidden files/dirs .* -!deploy/compose/postgres/state/webroot/misc/osie/current/.keep -!deploy/compose/postgres/state/webroot/workflow/.keep -!deploy/.env -!deploy/compose/.env +!deploy/stack/compose/postgres/state/webroot/misc/osie/current/.keep +!deploy/stack/compose/postgres/state/webroot/workflow/.keep +!deploy/stack/.env +!deploy/stack/compose/.env !.gitignore !.github/ @@ -17,12 +17,12 @@ compose.tar.gz compose.zip -deploy/compose/postgres/state/webroot/*.gz -deploy/compose/postgres/state/webroot/misc/osie/current/* -deploy/compose/postgres/state/webroot/workflow/* -deploy/compose/manifests/manifests.yaml -deploy/compose/state/* -!deploy/compose/state/.keep +deploy/stack/compose/postgres/state/webroot/*.gz +deploy/stack/compose/postgres/state/webroot/misc/osie/current/* +deploy/stack/compose/postgres/state/webroot/workflow/* +deploy/stack/compose/manifests/manifests.yaml +deploy/stack/compose/state/* +!deploy/stack/compose/state/.keep envrc out workflow_id.txt diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c278be5..ca302233 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,3 +43,10 @@ We'll try to add comments as soon as possible, though. Bugs are problems in code, in the functionality of an application or in its UI design; you can submit them through [Issues](https://github.com/tinkerbell/sandbox/issues). ## Code Style Guides + +## Implementation Details + +The Sandbox is organized into two high level components: `infrastructure` and `stack`. + +- The `infrastructure` component is responsible for provisioning the infrastructure required to run the Tinkerbell stack. `Vagrant` and `Terraform` are the supported infrastructure tools. +- The `stack` component is responsible for provisioning the Tinkerbell stack itself. `Docker Compose` and `Helm` are the supported stack tools. diff --git a/deploy/terraform/.terraform.lock.hcl b/deploy/infrastructure/terraform/.terraform.lock.hcl similarity index 100% rename from deploy/terraform/.terraform.lock.hcl rename to deploy/infrastructure/terraform/.terraform.lock.hcl diff --git a/deploy/terraform/cloud-config.cfg b/deploy/infrastructure/terraform/cloud-config.cfg similarity index 100% rename from deploy/terraform/cloud-config.cfg rename to deploy/infrastructure/terraform/cloud-config.cfg diff --git a/deploy/terraform/main.tf b/deploy/infrastructure/terraform/main.tf similarity index 100% rename from deploy/terraform/main.tf rename to deploy/infrastructure/terraform/main.tf diff --git a/deploy/terraform/outputs.tf b/deploy/infrastructure/terraform/outputs.tf similarity index 100% rename from deploy/terraform/outputs.tf rename to deploy/infrastructure/terraform/outputs.tf diff --git a/deploy/terraform/setup.sh b/deploy/infrastructure/terraform/setup.sh similarity index 100% rename from deploy/terraform/setup.sh rename to deploy/infrastructure/terraform/setup.sh diff --git a/deploy/terraform/variables.tf b/deploy/infrastructure/terraform/variables.tf similarity index 100% rename from deploy/terraform/variables.tf rename to deploy/infrastructure/terraform/variables.tf diff --git a/deploy/terraform/versions.tf b/deploy/infrastructure/terraform/versions.tf similarity index 100% rename from deploy/terraform/versions.tf rename to deploy/infrastructure/terraform/versions.tf diff --git a/deploy/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile similarity index 73% rename from deploy/vagrant/Vagrantfile rename to deploy/infrastructure/vagrant/Vagrantfile index 529656e1..a9938326 100644 --- a/deploy/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -1,12 +1,19 @@ # -*- mode: ruby -*- # vi: set ft=ruby : - +open('.env', 'r').readlines.each { + |l| kv = l.split('=') + if kv[1] != nil + ENV[kv[0]] = kv[1].strip + end +} LIBVIRT_HOST_IP = ENV["LIBVIRT_HOST_IP"] || "192.168.56.1" PROVISIONER_IP = ENV["PROVISIONER_IP"] || "192.168.56.4" MACHINE1_IP = ENV["MACHINE1_IP"] || "192.168.56.43" MACHINE1_MAC = (ENV["MACHINE1_MAC"] || "08:00:27:9E:F5:3A").downcase BACKEND_POSTGRES = ENV["BACKEND_POSTGRES"] || "" -COMPOSE_DIR = "/sandbox/compose" +USE_HELM = ENV["USE_HELM"] || "" +STACK_DIR = "../../stack/compose/" +DEST_DIR = "/sandbox/stack/compose" Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| @@ -14,31 +21,34 @@ Vagrant.configure("2") do |config| end config.vm.define "provisioner" do |provisioner| + if USE_HELM == "true" + STACK_DIR = "../stack/helm/" + DEST_DIR = "/sandbox/stack/helm" + end provisioner.vm.box = "generic/ubuntu2204" - provisioner.vm.synced_folder "../compose/", "/sandbox/compose/" - provisioner.vm.network "private_network", ip: PROVISIONER_IP, + provisioner.vm.synced_folder STACK_DIR, DEST_DIR + provisioner.vm.network "private_network", ip: "192.168.56.4", netmask: "255.255.255.0", libvirt__network_name: "tink_network", libvirt__host_ip: LIBVIRT_HOST_IP, libvirt__netmask: "255.255.255.0", - libvirt__dhcp_enabled: false, - auto_config: false + libvirt__dhcp_enabled: false provisioner.vm.provider "virtualbox" do |v, override| v.memory = 2048 v.cpus = 2 - override.vm.synced_folder "../compose/", "/sandbox/compose/" + override.vm.synced_folder STACK_DIR, DEST_DIR end provisioner.vm.provider "libvirt" do |l, override| l.memory = 2048 l.cpus = 2 - override.vm.synced_folder "../compose/", "/sandbox/compose/", type: "rsync" + override.vm.synced_folder STACK_DIR, DEST_DIR, type: "rsync" end - if BACKEND_POSTGRES != "" - COMPOSE_DIR = "/sandbox/compose/postgres" + if BACKEND_POSTGRES == "true" + DEST_DIR = "/sandbox/stack/compose/postgres" end - provisioner.vm.provision :shell, path: "setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, COMPOSE_DIR] + provisioner.vm.provision :shell, path: STACK_DIR+"/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR] end config.vm.define :machine1, autostart: false do |machine1| @@ -46,7 +56,7 @@ Vagrant.configure("2") do |config| machine1.vm.boot_timeout = 10 machine1.vm.synced_folder ".", "/vagrant", disabled: true machine1.vm.network :private_network, ip: MACHINE1_IP, - mac: MACHINE1_MAC.gsub(/[:-]/, ""), + mac: MACHINE1_MAC.gsub(/[:-]/, "").strip, adapter: 1, libvirt__network_name: "tink_network", libvirt__dhcp_enabled: false, diff --git a/deploy/compose/.env b/deploy/stack/compose/.env similarity index 100% rename from deploy/compose/.env rename to deploy/stack/compose/.env diff --git a/deploy/compose/docker-compose.yml b/deploy/stack/compose/docker-compose.yml similarity index 100% rename from deploy/compose/docker-compose.yml rename to deploy/stack/compose/docker-compose.yml diff --git a/deploy/compose/manifests/hardware.yaml b/deploy/stack/compose/manifests/hardware.yaml similarity index 93% rename from deploy/compose/manifests/hardware.yaml rename to deploy/stack/compose/manifests/hardware.yaml index c7be091e..9c21058c 100644 --- a/deploy/compose/manifests/hardware.yaml +++ b/deploy/stack/compose/manifests/hardware.yaml @@ -2,7 +2,6 @@ apiVersion: "tinkerbell.org/v1alpha1" kind: Hardware metadata: name: machine1 - namespace: default spec: disks: - device: $DISK_DEVICE @@ -22,7 +21,7 @@ spec: hostname: machine1 ip: address: $TINKERBELL_CLIENT_IP - # gateway: 192.168.2.1 + gateway: $TINKERBELL_CLIENT_GW netmask: 255.255.255.0 lease_time: 86400 mac: $TINKERBELL_CLIENT_MAC diff --git a/deploy/compose/manifests/template.yaml b/deploy/stack/compose/manifests/template.yaml similarity index 99% rename from deploy/compose/manifests/template.yaml rename to deploy/stack/compose/manifests/template.yaml index 7b5bb522..65e6d35a 100644 --- a/deploy/compose/manifests/template.yaml +++ b/deploy/stack/compose/manifests/template.yaml @@ -2,7 +2,6 @@ apiVersion: "tinkerbell.org/v1alpha1" kind: Template metadata: name: ubuntu-focal - namespace: default spec: data: | version: "0.1" diff --git a/deploy/stack/compose/manifests/ubuntu-download.yaml b/deploy/stack/compose/manifests/ubuntu-download.yaml new file mode 100644 index 00000000..3c4abc3c --- /dev/null +++ b/deploy/stack/compose/manifests/ubuntu-download.yaml @@ -0,0 +1,13 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: download-ubuntu-focal +spec: + ttlSecondsAfterFinished: 100 + template: + spec: + containers: + - name: downloadUbuntuFocal + image: perl:5.34.0 + command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] + restartPolicy: Never \ No newline at end of file diff --git a/deploy/compose/manifests/workflow.yaml b/deploy/stack/compose/manifests/workflow.yaml similarity index 90% rename from deploy/compose/manifests/workflow.yaml rename to deploy/stack/compose/manifests/workflow.yaml index 59c335e0..8cd9ec8d 100644 --- a/deploy/compose/manifests/workflow.yaml +++ b/deploy/stack/compose/manifests/workflow.yaml @@ -2,7 +2,6 @@ apiVersion: "tinkerbell.org/v1alpha1" kind: Workflow metadata: name: sandbox-workflow - namespace: default spec: templateRef: ubuntu-focal hardwareRef: machine1 diff --git a/deploy/compose/postgres/create-tink-records/create.sh b/deploy/stack/compose/postgres/create-tink-records/create.sh similarity index 100% rename from deploy/compose/postgres/create-tink-records/create.sh rename to deploy/stack/compose/postgres/create-tink-records/create.sh diff --git a/deploy/compose/postgres/create-tink-records/manifests/hardware/hardware-equinix-metal.json b/deploy/stack/compose/postgres/create-tink-records/manifests/hardware/hardware-equinix-metal.json similarity index 100% rename from deploy/compose/postgres/create-tink-records/manifests/hardware/hardware-equinix-metal.json rename to deploy/stack/compose/postgres/create-tink-records/manifests/hardware/hardware-equinix-metal.json diff --git a/deploy/compose/postgres/create-tink-records/manifests/hardware/hardware.json b/deploy/stack/compose/postgres/create-tink-records/manifests/hardware/hardware.json similarity index 100% rename from deploy/compose/postgres/create-tink-records/manifests/hardware/hardware.json rename to deploy/stack/compose/postgres/create-tink-records/manifests/hardware/hardware.json diff --git a/deploy/compose/postgres/create-tink-records/manifests/template/ubuntu-equinix-metal.yaml b/deploy/stack/compose/postgres/create-tink-records/manifests/template/ubuntu-equinix-metal.yaml similarity index 100% rename from deploy/compose/postgres/create-tink-records/manifests/template/ubuntu-equinix-metal.yaml rename to deploy/stack/compose/postgres/create-tink-records/manifests/template/ubuntu-equinix-metal.yaml diff --git a/deploy/compose/postgres/create-tink-records/manifests/template/ubuntu.yaml b/deploy/stack/compose/postgres/create-tink-records/manifests/template/ubuntu.yaml similarity index 100% rename from deploy/compose/postgres/create-tink-records/manifests/template/ubuntu.yaml rename to deploy/stack/compose/postgres/create-tink-records/manifests/template/ubuntu.yaml diff --git a/deploy/compose/postgres/docker-compose.yml b/deploy/stack/compose/postgres/docker-compose.yml similarity index 100% rename from deploy/compose/postgres/docker-compose.yml rename to deploy/stack/compose/postgres/docker-compose.yml diff --git a/deploy/compose/postgres/fetch-and-convert-ubuntu-img/fetch.sh b/deploy/stack/compose/postgres/fetch-and-convert-ubuntu-img/fetch.sh similarity index 100% rename from deploy/compose/postgres/fetch-and-convert-ubuntu-img/fetch.sh rename to deploy/stack/compose/postgres/fetch-and-convert-ubuntu-img/fetch.sh diff --git a/deploy/compose/postgres/fetch-osie/fetch.sh b/deploy/stack/compose/postgres/fetch-osie/fetch.sh similarity index 100% rename from deploy/compose/postgres/fetch-osie/fetch.sh rename to deploy/stack/compose/postgres/fetch-osie/fetch.sh diff --git a/deploy/compose/postgres/generate-tls-certs/ca-config.json b/deploy/stack/compose/postgres/generate-tls-certs/ca-config.json similarity index 100% rename from deploy/compose/postgres/generate-tls-certs/ca-config.json rename to deploy/stack/compose/postgres/generate-tls-certs/ca-config.json diff --git a/deploy/compose/postgres/generate-tls-certs/ca-csr.json b/deploy/stack/compose/postgres/generate-tls-certs/ca-csr.json similarity index 100% rename from deploy/compose/postgres/generate-tls-certs/ca-csr.json rename to deploy/stack/compose/postgres/generate-tls-certs/ca-csr.json diff --git a/deploy/compose/postgres/generate-tls-certs/csr.json b/deploy/stack/compose/postgres/generate-tls-certs/csr.json similarity index 100% rename from deploy/compose/postgres/generate-tls-certs/csr.json rename to deploy/stack/compose/postgres/generate-tls-certs/csr.json diff --git a/deploy/compose/postgres/generate-tls-certs/generate.sh b/deploy/stack/compose/postgres/generate-tls-certs/generate.sh similarity index 100% rename from deploy/compose/postgres/generate-tls-certs/generate.sh rename to deploy/stack/compose/postgres/generate-tls-certs/generate.sh diff --git a/deploy/compose/postgres/sync-images-to-local-registry/registry_images.txt b/deploy/stack/compose/postgres/sync-images-to-local-registry/registry_images.txt similarity index 100% rename from deploy/compose/postgres/sync-images-to-local-registry/registry_images.txt rename to deploy/stack/compose/postgres/sync-images-to-local-registry/registry_images.txt diff --git a/deploy/compose/postgres/sync-images-to-local-registry/upload.sh b/deploy/stack/compose/postgres/sync-images-to-local-registry/upload.sh similarity index 100% rename from deploy/compose/postgres/sync-images-to-local-registry/upload.sh rename to deploy/stack/compose/postgres/sync-images-to-local-registry/upload.sh diff --git a/deploy/compose/scripts/fetch-osie.sh b/deploy/stack/compose/scripts/fetch-osie.sh similarity index 100% rename from deploy/compose/scripts/fetch-osie.sh rename to deploy/stack/compose/scripts/fetch-osie.sh diff --git a/deploy/compose/scripts/fetch-ubuntu.sh b/deploy/stack/compose/scripts/fetch-ubuntu.sh similarity index 100% rename from deploy/compose/scripts/fetch-ubuntu.sh rename to deploy/stack/compose/scripts/fetch-ubuntu.sh diff --git a/deploy/vagrant/setup.sh b/deploy/stack/compose/setup.sh similarity index 95% rename from deploy/vagrant/setup.sh rename to deploy/stack/compose/setup.sh index e52ffd1f..815d42dc 100755 --- a/deploy/vagrant/setup.sh +++ b/deploy/stack/compose/setup.sh @@ -59,6 +59,7 @@ setup_compose_env_overrides() { DISK_DEVICE="$disk_device" EOF for line in "${lines[@]}"; do + echo "$line" grep -q "$line" "$compose_dir"/.env && continue echo "$line" >>"$compose_dir"/.env done @@ -79,7 +80,7 @@ create_tink_helper_script() { tweak_bash_interactive_settings() { local compose_dir=$1 - grep -q 'cd /sandbox/compose' ~vagrant/.bashrc || echo 'cd /sandbox/compose' >>~vagrant/.bashrc + grep -q "cd $compose_dir" ~vagrant/.bashrc || echo "cd $compose_dir" >>~vagrant/.bashrc echo 'export KUBECONFIG='"$compose_dir"'/state/kube/kubeconfig.yaml' >>~vagrant/.bashrc readarray -t aliases <<-EOF dc="docker compose" @@ -99,7 +100,7 @@ main() { install_docker install_kubectl - setup_layer2_network "$host_ip" + # setup_layer2_network "$host_ip" setup_compose_env_overrides "$host_ip" "$worker_ip" "$worker_mac" "$compose_dir" docker compose -f "$compose_dir"/docker-compose.yml up -d diff --git a/deploy/compose/state/.keep b/deploy/stack/compose/state/.keep similarity index 100% rename from deploy/compose/state/.keep rename to deploy/stack/compose/state/.keep diff --git a/deploy/vagrant/tink b/deploy/stack/compose/tink similarity index 100% rename from deploy/vagrant/tink rename to deploy/stack/compose/tink diff --git a/deploy/stack/helm/setup.sh b/deploy/stack/helm/setup.sh new file mode 100644 index 00000000..589c4f3b --- /dev/null +++ b/deploy/stack/helm/setup.sh @@ -0,0 +1,123 @@ +#!/bin/bash + +install_docker() { + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + update_apt + apt-get install --no-install-recommends containerd.io docker-ce docker-ce-cli docker-compose-plugin + gpasswd -a vagrant docker +} + +install_kubectl() { + curl -LO https://dl.k8s.io/v1.25.2/bin/linux/amd64/kubectl + chmod +x ./kubectl + mv ./kubectl /usr/local/bin/kubectl +} + +install_helm() { + helm_ver=v3.9.4 + + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 + chmod 700 get_helm.sh + ./get_helm.sh --version "$helm_ver" +} + +apt-get() { + DEBIAN_FRONTEND=noninteractive command apt-get \ + --allow-change-held-packages \ + --allow-downgrades \ + --allow-remove-essential \ + --allow-unauthenticated \ + --option Dpkg::Options::=--force-confdef \ + --option Dpkg::Options::=--force-confold \ + --yes \ + "$@" +} + +update_apt() { + apt-get update +} + +install_k3d() { + wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | TAG=v5.4.6 bash +} + +start_k3d() { + k3d cluster create --network host --no-lb --k3s-arg "--disable=traefik,servicelb" --k3s-arg "--kube-apiserver-arg=feature-gates=MixedProtocolLBService=true" --host-pid-mode + mkdir -p ~/.kube/ + k3d kubeconfig get -a > ~/.kube/config + until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do sleep 1; done +} + +kubectl_for_vagrant_user() { + runuser -l vagrant -c "mkdir -p ~/.kube/" + runuser -l vagrant -c "k3d kubeconfig get -a > ~/.kube/config" + chmod 600 /home/vagrant/.kube/config + echo 'export KUBECONFIG="/home/vagrant/.kube/config"' >>~vagrant/.bashrc +} + +helm_customize_values() { + local loadbalancer_ip=$1 + + helm inspect values oci://ghcr.io/tinkerbell/charts/stack --version 0.1.1 > /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 + + 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 +} + +apply_manifests() { + local worker_ip=$1 + local worker_mac=$2 + local manifests_dir=$3 + local host_ip=$4 + local namespace=$5 + + export TINKERBELL_CLIENT_IP="$worker_ip" + export TINKERBELL_CLIENT_MAC="$worker_mac" + export TINKERBELL_HOST_IP="$host_ip" + for i in "$manifests_dir"/{hardware.yaml,template.yaml,workflow.yaml}; do envsubst < $i; echo -e '---'; done > /tmp/manifests.yaml + kubectl apply -n "$namespace" -f /tmp/manifests.yaml +} + +run_helm() { + local host_ip=$1 + local worker_ip=$2 + local worker_mac=$3 + local manifests_dir=$4 + local namespace="tink-system" + local loadbalancer_ip="192.168.56.5" + + 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" + apply_manifests "$worker_ip" "$worker_mac" "$manifests_dir" "$loadbalancer_ip", "$namespace" + kubectl_for_vagrant_user +} + +main() { + local host_ip=$1 + local worker_ip=$2 + local worker_mac=$3 + local compose_dir=$4 + + update_apt + install_docker + install_kubectl + + run_helm "$host_ip" "$worker_ip" "$worker_mac" "$compose_dir"/manifests +} + +if [[ ${BASH_SOURCE[0]} == "$0" ]]; then + set -euxo pipefail + + main "$@" + echo "all done!" +fi \ No newline at end of file diff --git a/docs/quickstarts/VAGRANTLVIRT.md b/docs/quickstarts/VAGRANTLVIRT.md index 1e21f416..05af7f2b 100644 --- a/docs/quickstarts/VAGRANTLVIRT.md +++ b/docs/quickstarts/VAGRANTLVIRT.md @@ -21,7 +21,7 @@ This option will also show you how to create a machine to provision. 2. Start the provisioner ```bash - cd deploy/vagrant + cd deploy/infrastructure/vagrant vagrant up # This process will take about 5-10 minutes depending on your internet connection. # Hook is about 400MB in size and the Ubuntu Focal image is about 500MB From e56a7f256b1c120c400608d0cbe2a676e25e8c75 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Fri, 21 Oct 2022 20:31:30 +0000 Subject: [PATCH 2/8] Reorganize into `infrastructure` and `stack` components: This clarifies the architectural design for the Sandbox. An initial structure for a helm deployment has been created. Signed-off-by: Jacob Weinstock --- .github/workflows/ci-non-go.sh | 4 ++-- CONTRIBUTING.md | 2 +- deploy/infrastructure/vagrant/Vagrantfile | 7 ++++--- .../compose/manifests/ubuntu-download.yaml | 8 ++++---- deploy/stack/compose/setup.sh | 1 - deploy/stack/helm/setup.sh | 19 +++++++++++-------- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-non-go.sh b/.github/workflows/ci-non-go.sh index 1f6a88ac..3d0cdca0 100755 --- a/.github/workflows/ci-non-go.sh +++ b/.github/workflows/ci-non-go.sh @@ -22,11 +22,11 @@ if ! make lint; then failed=1 fi -if ! terraform fmt -write -recursive deploy/terraform/; then +if ! terraform fmt -write -recursive deploy/infrastructure/terraform/; then failed=1 fi -if ! rufo deploy/vagrant/Vagrantfile; then +if ! rufo deploy/infrastructure/vagrant/Vagrantfile; then failed=1 fi diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca302233..09af5561 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ Bugs are problems in code, in the functionality of an application or in its UI d ## Implementation Details -The Sandbox is organized into two high level components: `infrastructure` and `stack`. +The Sandbox is organized into two high level components: `infrastructure` and `stack`. - The `infrastructure` component is responsible for provisioning the infrastructure required to run the Tinkerbell stack. `Vagrant` and `Terraform` are the supported infrastructure tools. - The `stack` component is responsible for provisioning the Tinkerbell stack itself. `Docker Compose` and `Helm` are the supported stack tools. diff --git a/deploy/infrastructure/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile index a9938326..39817d5d 100644 --- a/deploy/infrastructure/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -1,7 +1,8 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -open('.env', 'r').readlines.each { - |l| kv = l.split('=') +open(".env", "r").readlines.each { + |l| + kv = l.split("=") if kv[1] != nil ENV[kv[0]] = kv[1].strip end @@ -48,7 +49,7 @@ Vagrant.configure("2") do |config| if BACKEND_POSTGRES == "true" DEST_DIR = "/sandbox/stack/compose/postgres" end - provisioner.vm.provision :shell, path: STACK_DIR+"/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR] + provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR] end config.vm.define :machine1, autostart: false do |machine1| diff --git a/deploy/stack/compose/manifests/ubuntu-download.yaml b/deploy/stack/compose/manifests/ubuntu-download.yaml index 3c4abc3c..35602924 100644 --- a/deploy/stack/compose/manifests/ubuntu-download.yaml +++ b/deploy/stack/compose/manifests/ubuntu-download.yaml @@ -7,7 +7,7 @@ spec: template: spec: containers: - - name: downloadUbuntuFocal - image: perl:5.34.0 - command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] - restartPolicy: Never \ No newline at end of file + - name: downloadUbuntuFocal + image: perl:5.34.0 + command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] + restartPolicy: Never diff --git a/deploy/stack/compose/setup.sh b/deploy/stack/compose/setup.sh index 815d42dc..cd13c709 100755 --- a/deploy/stack/compose/setup.sh +++ b/deploy/stack/compose/setup.sh @@ -59,7 +59,6 @@ setup_compose_env_overrides() { DISK_DEVICE="$disk_device" EOF for line in "${lines[@]}"; do - echo "$line" grep -q "$line" "$compose_dir"/.env && continue echo "$line" >>"$compose_dir"/.env done diff --git a/deploy/stack/helm/setup.sh b/deploy/stack/helm/setup.sh index 589c4f3b..966d66bf 100644 --- a/deploy/stack/helm/setup.sh +++ b/deploy/stack/helm/setup.sh @@ -45,7 +45,7 @@ install_k3d() { start_k3d() { k3d cluster create --network host --no-lb --k3s-arg "--disable=traefik,servicelb" --k3s-arg "--kube-apiserver-arg=feature-gates=MixedProtocolLBService=true" --host-pid-mode mkdir -p ~/.kube/ - k3d kubeconfig get -a > ~/.kube/config + k3d kubeconfig get -a >~/.kube/config until kubectl wait --for=condition=Ready nodes --all --timeout=600s; do sleep 1; done } @@ -59,7 +59,7 @@ kubectl_for_vagrant_user() { helm_customize_values() { local loadbalancer_ip=$1 - 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 0.1.1 >/tmp/stack-values.yaml sed -i "s/192.168.2.111/${loadbalancer_ip}/g" /tmp/stack-values.yaml } @@ -77,10 +77,13 @@ apply_manifests() { local host_ip=$4 local namespace=$5 - export TINKERBELL_CLIENT_IP="$worker_ip" - export TINKERBELL_CLIENT_MAC="$worker_mac" - export TINKERBELL_HOST_IP="$host_ip" - for i in "$manifests_dir"/{hardware.yaml,template.yaml,workflow.yaml}; do envsubst < $i; echo -e '---'; done > /tmp/manifests.yaml + export TINKERBELL_CLIENT_IP="$worker_ip" + export TINKERBELL_CLIENT_MAC="$worker_mac" + export TINKERBELL_HOST_IP="$host_ip" + for i in "$manifests_dir"/{hardware.yaml,template.yaml,workflow.yaml}; do + envsubst <"$i" + echo -e '---' + done >/tmp/manifests.yaml kubectl apply -n "$namespace" -f /tmp/manifests.yaml } @@ -92,7 +95,7 @@ run_helm() { local namespace="tink-system" local loadbalancer_ip="192.168.56.5" - install_k3d + install_k3d start_k3d install_helm helm_customize_values "$loadbalancer_ip" @@ -120,4 +123,4 @@ if [[ ${BASH_SOURCE[0]} == "$0" ]]; then main "$@" echo "all done!" -fi \ No newline at end of file +fi From 576620ca3d57176d51442560e3fc186ceb8b52ed Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Sat, 22 Oct 2022 05:40:43 +0000 Subject: [PATCH 3/8] Add downloading of ubuntu raw image: This enables the example template to run successfully. Signed-off-by: Jacob Weinstock --- .gitignore | 2 +- deploy/infrastructure/vagrant/.env | 10 +++ deploy/infrastructure/vagrant/Vagrantfile | 25 +++--- .../compose/manifests/ubuntu-download.yaml | 13 --- deploy/stack/helm/manifests/hardware.yaml | 34 +++++++ deploy/stack/helm/manifests/template.yaml | 89 +++++++++++++++++++ .../stack/helm/manifests/ubuntu-download.yaml | 52 +++++++++++ deploy/stack/helm/manifests/workflow.yaml | 9 ++ deploy/stack/helm/setup.sh | 15 +++- 9 files changed, 221 insertions(+), 28 deletions(-) create mode 100644 deploy/infrastructure/vagrant/.env delete mode 100644 deploy/stack/compose/manifests/ubuntu-download.yaml create mode 100644 deploy/stack/helm/manifests/hardware.yaml create mode 100644 deploy/stack/helm/manifests/template.yaml create mode 100644 deploy/stack/helm/manifests/ubuntu-download.yaml create mode 100644 deploy/stack/helm/manifests/workflow.yaml diff --git a/.gitignore b/.gitignore index bcc6c64e..0057644d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ .* !deploy/stack/compose/postgres/state/webroot/misc/osie/current/.keep !deploy/stack/compose/postgres/state/webroot/workflow/.keep -!deploy/stack/.env +!deploy/infrastructure/vagrant/.env !deploy/stack/compose/.env !.gitignore !.github/ diff --git a/deploy/infrastructure/vagrant/.env b/deploy/infrastructure/vagrant/.env new file mode 100644 index 00000000..db06bfa5 --- /dev/null +++ b/deploy/infrastructure/vagrant/.env @@ -0,0 +1,10 @@ +LIBVIRT_HOST_IP=192.168.56.1 +PROVISIONER_IP=192.168.56.4 +MACHINE1_IP=192.168.56.43 +MACHINE1_MAC=08:00:27:9e:f5:3a + +#USE_POSTGRES=true +USE_POSTGRES= + +# USE_HELM=true +USE_HELM=true diff --git a/deploy/infrastructure/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile index 39817d5d..bd836e23 100644 --- a/deploy/infrastructure/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -1,5 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : + open(".env", "r").readlines.each { |l| kv = l.split("=") @@ -7,14 +8,18 @@ open(".env", "r").readlines.each { ENV[kv[0]] = kv[1].strip end } + LIBVIRT_HOST_IP = ENV["LIBVIRT_HOST_IP"] || "192.168.56.1" PROVISIONER_IP = ENV["PROVISIONER_IP"] || "192.168.56.4" MACHINE1_IP = ENV["MACHINE1_IP"] || "192.168.56.43" MACHINE1_MAC = (ENV["MACHINE1_MAC"] || "08:00:27:9E:F5:3A").downcase -BACKEND_POSTGRES = ENV["BACKEND_POSTGRES"] || "" +USE_POSTGRES = ENV["USE_POSTGRES"] || "" USE_HELM = ENV["USE_HELM"] || "" -STACK_DIR = "../../stack/compose/" -DEST_DIR = "/sandbox/stack/compose" +STACK_OPT = "compose/" +STACK_BASE_DIR = "../../stack/" +STACK_DIR = STACK_BASE_DIR + STACK_OPT +DEST_DIR_BASE = "/sandbox/stack/" +DEST_DIR = DEST_DIR_BASE + STACK_OPT Vagrant.configure("2") do |config| config.vm.provider :libvirt do |libvirt| @@ -23,11 +28,11 @@ Vagrant.configure("2") do |config| config.vm.define "provisioner" do |provisioner| if USE_HELM == "true" - STACK_DIR = "../stack/helm/" - DEST_DIR = "/sandbox/stack/helm" + STACK_DIR = STACK_BASE_DIR + "helm/" + DEST_DIR = DEST_DIR_BASE + "helm/" end provisioner.vm.box = "generic/ubuntu2204" - provisioner.vm.synced_folder STACK_DIR, DEST_DIR + provisioner.vm.synced_folder STACK_BASE_DIR, DEST_DIR_BASE provisioner.vm.network "private_network", ip: "192.168.56.4", netmask: "255.255.255.0", libvirt__network_name: "tink_network", libvirt__host_ip: LIBVIRT_HOST_IP, @@ -37,17 +42,17 @@ Vagrant.configure("2") do |config| provisioner.vm.provider "virtualbox" do |v, override| v.memory = 2048 v.cpus = 2 - override.vm.synced_folder STACK_DIR, DEST_DIR + override.vm.synced_folder STACK_BASE_DIR, DEST_DIR_BASE end provisioner.vm.provider "libvirt" do |l, override| l.memory = 2048 l.cpus = 2 - override.vm.synced_folder STACK_DIR, DEST_DIR, type: "rsync" + override.vm.synced_folder STACK_BASE_DIR, DEST_DIR_BASE, type: "rsync" end - if BACKEND_POSTGRES == "true" - DEST_DIR = "/sandbox/stack/compose/postgres" + if USE_POSTGRES == "true" + DEST_DIR = DEST_DIR_BASE + "postgres/" end provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR] end diff --git a/deploy/stack/compose/manifests/ubuntu-download.yaml b/deploy/stack/compose/manifests/ubuntu-download.yaml deleted file mode 100644 index 35602924..00000000 --- a/deploy/stack/compose/manifests/ubuntu-download.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: batch/v1 -kind: Job -metadata: - name: download-ubuntu-focal -spec: - ttlSecondsAfterFinished: 100 - template: - spec: - containers: - - name: downloadUbuntuFocal - image: perl:5.34.0 - command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"] - restartPolicy: Never diff --git a/deploy/stack/helm/manifests/hardware.yaml b/deploy/stack/helm/manifests/hardware.yaml new file mode 100644 index 00000000..9c21058c --- /dev/null +++ b/deploy/stack/helm/manifests/hardware.yaml @@ -0,0 +1,34 @@ +apiVersion: "tinkerbell.org/v1alpha1" +kind: Hardware +metadata: + name: machine1 +spec: + disks: + - device: $DISK_DEVICE + metadata: + facility: + facility_code: sandbox + instance: + hostname: "machine1" + id: "$TINKERBELL_CLIENT_MAC" + operating_system: + distro: "ubuntu" + os_slug: "ubuntu_20_04" + version: "20.04" + interfaces: + - dhcp: + arch: x86_64 + hostname: machine1 + ip: + address: $TINKERBELL_CLIENT_IP + gateway: $TINKERBELL_CLIENT_GW + netmask: 255.255.255.0 + lease_time: 86400 + mac: $TINKERBELL_CLIENT_MAC + name_servers: + - 1.1.1.1 + - 8.8.8.8 + uefi: false + netboot: + allowPXE: true + allowWorkflow: true diff --git a/deploy/stack/helm/manifests/template.yaml b/deploy/stack/helm/manifests/template.yaml new file mode 100644 index 00000000..65e6d35a --- /dev/null +++ b/deploy/stack/helm/manifests/template.yaml @@ -0,0 +1,89 @@ +apiVersion: "tinkerbell.org/v1alpha1" +kind: Template +metadata: + name: ubuntu-focal +spec: + data: | + version: "0.1" + name: ubuntu_Focal + global_timeout: 1800 + tasks: + - name: "os-installation" + worker: "{{.device_1}}" + volumes: + - /dev:/dev + - /dev/console:/dev/console + - /lib/firmware:/lib/firmware:ro + actions: + - name: "stream-ubuntu-image" + image: quay.io/tinkerbell-actions/image2disk:v1.0.0 + timeout: 600 + environment: + DEST_DISK: {{ index .Hardware.Disks 0 }} + IMG_URL: "http://$TINKERBELL_HOST_IP:8080/focal-server-cloudimg-amd64.raw.gz" + COMPRESSED: true + - name: "grow-partition" + image: quay.io/tinkerbell-actions/cexec:v1.0.0 + timeout: 90 + environment: + BLOCK_DEVICE: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + CHROOT: y + DEFAULT_INTERPRETER: "/bin/sh -c" + CMD_LINE: "growpart {{ index .Hardware.Disks 0 }} 1 && resize2fs {{ index .Hardware.Disks 0 }}1" + - name: "install-openssl" + image: quay.io/tinkerbell-actions/cexec:v1.0.0 + timeout: 90 + environment: + BLOCK_DEVICE: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + CHROOT: y + DEFAULT_INTERPRETER: "/bin/sh -c" + CMD_LINE: "apt -y update && apt -y install openssl" + - name: "create-user" + image: quay.io/tinkerbell-actions/cexec:v1.0.0 + timeout: 90 + environment: + BLOCK_DEVICE: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + CHROOT: y + DEFAULT_INTERPRETER: "/bin/sh -c" + CMD_LINE: "useradd -p $(openssl passwd -1 tink) -s /bin/bash -d /home/tink/ -m -G sudo tink" + - name: "enable-ssh" + image: quay.io/tinkerbell-actions/cexec:v1.0.0 + timeout: 90 + environment: + BLOCK_DEVICE: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + CHROOT: y + DEFAULT_INTERPRETER: "/bin/sh -c" + CMD_LINE: "ssh-keygen -A; systemctl enable ssh.service; sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config" + - name: "disable-apparmor" + image: quay.io/tinkerbell-actions/cexec:v1.0.0 + timeout: 90 + environment: + BLOCK_DEVICE: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + CHROOT: y + DEFAULT_INTERPRETER: "/bin/sh -c" + CMD_LINE: "systemctl disable apparmor; systemctl disable snapd" + - name: "write-netplan" + image: quay.io/tinkerbell-actions/writefile:v1.0.0 + timeout: 90 + environment: + DEST_DISK: {{ index .Hardware.Disks 0 }}1 + FS_TYPE: ext4 + DEST_PATH: /etc/netplan/config.yaml + CONTENTS: | + network: + version: 2 + renderer: networkd + ethernets: + id0: + match: + name: en* + dhcp4: true + UID: 0 + GID: 0 + MODE: 0644 + DIRMODE: 0755 diff --git a/deploy/stack/helm/manifests/ubuntu-download.yaml b/deploy/stack/helm/manifests/ubuntu-download.yaml new file mode 100644 index 00000000..ae931486 --- /dev/null +++ b/deploy/stack/helm/manifests/ubuntu-download.yaml @@ -0,0 +1,52 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: download-image +data: + entrypoint.sh: |- + #!/usr/bin/env bash + # This script is designed to download a cloud image file (.img) and then convert it to a .raw.gz file. + # This is purpose built so non-raw cloud image files can be used with the "image2disk" action. + # See https://artifacthub.io/packages/tbaction/tinkerbell-community/image2disk. + set -euxo pipefail + if ! which pigz qemu-img &>/dev/null; then + apk add --update pigz qemu-img + fi + image_url=$1 + file=$2/${image_url##*/} + file=${file%.*}.raw.gz + if [[ ! -f "$file" ]]; then + wget "$image_url" -O image.img + qemu-img convert -O raw image.img image.raw + pigz "$file" + rm -f image.img image.raw + fi +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: download-ubuntu-focal +spec: + template: + spec: + containers: + - name: download-ubuntu-focal + image: bash:5.2.2 + command: ["/script/entrypoint.sh"] + args: ["https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img", "/output"] + volumeMounts: + - mountPath: /output + name: hook-artifacts + - mountPath: /script + name: configmap-volume + restartPolicy: OnFailure + volumes: + - name: hook-artifacts + hostPath: + path: /opt/hook + type: DirectoryOrCreate + - name: configmap-volume + configMap: + defaultMode: 0700 + name: download-image diff --git a/deploy/stack/helm/manifests/workflow.yaml b/deploy/stack/helm/manifests/workflow.yaml new file mode 100644 index 00000000..8cd9ec8d --- /dev/null +++ b/deploy/stack/helm/manifests/workflow.yaml @@ -0,0 +1,9 @@ +apiVersion: "tinkerbell.org/v1alpha1" +kind: Workflow +metadata: + name: sandbox-workflow +spec: + templateRef: ubuntu-focal + hardwareRef: machine1 + hardwareMap: + device_1: $TINKERBELL_CLIENT_MAC diff --git a/deploy/stack/helm/setup.sh b/deploy/stack/helm/setup.sh index 966d66bf..0b8f1bf1 100644 --- a/deploy/stack/helm/setup.sh +++ b/deploy/stack/helm/setup.sh @@ -4,7 +4,7 @@ install_docker() { curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" update_apt - apt-get install --no-install-recommends containerd.io docker-ce docker-ce-cli docker-compose-plugin + apt-get install --no-install-recommends containerd.io docker-ce docker-ce-cli gpasswd -a vagrant docker } @@ -77,14 +77,21 @@ apply_manifests() { local host_ip=$4 local namespace=$5 + disk_device="/dev/sda" + if lsblk | grep -q vda; then + disk_device="/dev/vda" + fi + export DISK_DEVICE="$disk_device" export TINKERBELL_CLIENT_IP="$worker_ip" export TINKERBELL_CLIENT_MAC="$worker_mac" export TINKERBELL_HOST_IP="$host_ip" + for i in "$manifests_dir"/{hardware.yaml,template.yaml,workflow.yaml}; do envsubst <"$i" echo -e '---' done >/tmp/manifests.yaml kubectl apply -n "$namespace" -f /tmp/manifests.yaml + kubectl apply -n "$namespace" -f "$manifests_dir"/ubuntu-download.yaml } run_helm() { @@ -101,7 +108,7 @@ run_helm() { helm_customize_values "$loadbalancer_ip" # do we need to wait til cluster is ready? TBD helm_install_tink_stack "$namespace" - apply_manifests "$worker_ip" "$worker_mac" "$manifests_dir" "$loadbalancer_ip", "$namespace" + apply_manifests "$worker_ip" "$worker_mac" "$manifests_dir" "$loadbalancer_ip" "$namespace" kubectl_for_vagrant_user } @@ -109,13 +116,13 @@ main() { local host_ip=$1 local worker_ip=$2 local worker_mac=$3 - local compose_dir=$4 + local manifests_dir=$4 update_apt install_docker install_kubectl - run_helm "$host_ip" "$worker_ip" "$worker_mac" "$compose_dir"/manifests + run_helm "$host_ip" "$worker_ip" "$worker_mac" "$manifests_dir"/manifests } if [[ ${BASH_SOURCE[0]} == "$0" ]]; then From 6b48ebae2cedb6ec4d72d5ec55fc16be8b2cc09e Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Sat, 22 Oct 2022 16:13:19 +0000 Subject: [PATCH 4/8] Make the load balancer IP configurable for helm stack install: This puts the load balancer IP on par with other similar values. Signed-off-by: Jacob Weinstock --- deploy/infrastructure/vagrant/.env | 1 + deploy/infrastructure/vagrant/Vagrantfile | 3 ++- deploy/stack/helm/setup.sh | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deploy/infrastructure/vagrant/.env b/deploy/infrastructure/vagrant/.env index db06bfa5..ad5b2372 100644 --- a/deploy/infrastructure/vagrant/.env +++ b/deploy/infrastructure/vagrant/.env @@ -1,5 +1,6 @@ LIBVIRT_HOST_IP=192.168.56.1 PROVISIONER_IP=192.168.56.4 +LOADBALANCER_IP=192.168.56.5 MACHINE1_IP=192.168.56.43 MACHINE1_MAC=08:00:27:9e:f5:3a diff --git a/deploy/infrastructure/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile index bd836e23..0c018540 100644 --- a/deploy/infrastructure/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -11,6 +11,7 @@ open(".env", "r").readlines.each { LIBVIRT_HOST_IP = ENV["LIBVIRT_HOST_IP"] || "192.168.56.1" PROVISIONER_IP = ENV["PROVISIONER_IP"] || "192.168.56.4" +LOADBALANCER_IP = ENV["LOADBALANCER_IP"] || "192.168.56.4" 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"] || "" @@ -54,7 +55,7 @@ Vagrant.configure("2") do |config| if USE_POSTGRES == "true" DEST_DIR = DEST_DIR_BASE + "postgres/" end - provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR] + provisioner.vm.provision :shell, path: STACK_DIR + "/setup.sh", args: [PROVISIONER_IP, MACHINE1_IP, MACHINE1_MAC, DEST_DIR, LOADBALANCER_IP] end config.vm.define :machine1, autostart: false do |machine1| diff --git a/deploy/stack/helm/setup.sh b/deploy/stack/helm/setup.sh index 0b8f1bf1..6f7602b9 100644 --- a/deploy/stack/helm/setup.sh +++ b/deploy/stack/helm/setup.sh @@ -99,8 +99,8 @@ run_helm() { local worker_ip=$2 local worker_mac=$3 local manifests_dir=$4 + local loadbalancer_ip=$5 local namespace="tink-system" - local loadbalancer_ip="192.168.56.5" install_k3d start_k3d @@ -117,12 +117,13 @@ main() { local worker_ip=$2 local worker_mac=$3 local manifests_dir=$4 + local loadbalancer_ip=$5 update_apt install_docker install_kubectl - run_helm "$host_ip" "$worker_ip" "$worker_mac" "$manifests_dir"/manifests + run_helm "$host_ip" "$worker_ip" "$worker_mac" "$manifests_dir"/manifests "$loadbalancer_ip" } if [[ ${BASH_SOURCE[0]} == "$0" ]]; then From c7b74f17033e0b0a58196c63dfdde91f7bfe5c48 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Sun, 23 Oct 2022 02:27:41 +0000 Subject: [PATCH 5/8] Updates for vagrant with virtualbox: Fixes issues caused by the reorg. Signed-off-by: Jacob Weinstock --- .gitignore | 1 + deploy/infrastructure/vagrant/.env | 4 ++-- deploy/infrastructure/vagrant/Vagrantfile | 2 +- deploy/stack/compose/postgres/.env | 27 +++++++++++++++++++++++ deploy/stack/compose/setup.sh | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 deploy/stack/compose/postgres/.env diff --git a/.gitignore b/.gitignore index 0057644d..c61d096d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ !deploy/stack/compose/postgres/state/webroot/workflow/.keep !deploy/infrastructure/vagrant/.env !deploy/stack/compose/.env +!deploy/stack/compose/postgres/.env !.gitignore !.github/ diff --git a/deploy/infrastructure/vagrant/.env b/deploy/infrastructure/vagrant/.env index ad5b2372..d31b8e09 100644 --- a/deploy/infrastructure/vagrant/.env +++ b/deploy/infrastructure/vagrant/.env @@ -5,7 +5,7 @@ MACHINE1_IP=192.168.56.43 MACHINE1_MAC=08:00:27:9e:f5:3a #USE_POSTGRES=true -USE_POSTGRES= +USE_POSTGRES=true # USE_HELM=true -USE_HELM=true +USE_HELM= diff --git a/deploy/infrastructure/vagrant/Vagrantfile b/deploy/infrastructure/vagrant/Vagrantfile index 0c018540..b147f4d0 100644 --- a/deploy/infrastructure/vagrant/Vagrantfile +++ b/deploy/infrastructure/vagrant/Vagrantfile @@ -53,7 +53,7 @@ Vagrant.configure("2") do |config| end if USE_POSTGRES == "true" - DEST_DIR = DEST_DIR_BASE + "postgres/" + 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] end diff --git a/deploy/stack/compose/postgres/.env b/deploy/stack/compose/postgres/.env new file mode 100644 index 00000000..d9cb2280 --- /dev/null +++ b/deploy/stack/compose/postgres/.env @@ -0,0 +1,27 @@ +# These must be defined above/before first use. +# Use of these variables *must* be in ${} form, otherwise docker-compose won't substitute when processing this file +vOSIE=v0.7.0 +vTINK=sha-16186501 + +# Probably don't want to mess with these, unless you know you do +FACILITY=onprem +TINKERBELL_REGISTRY_PASSWORD=Admin1234 +TINKERBELL_REGISTRY_USERNAME=admin +TINKERBELL_TLS= false + +# Can be set to your own hook builds +OSIE_DOWNLOAD_URLS=https://github.com/tinkerbell/hook/releases/download/${vOSIE}/hook_x86_64.tar.gz,https://github.com/tinkerbell/hook/releases/download/${vOSIE}/hook_aarch64.tar.gz + +TINKERBELL_HARDWARE_MANIFEST=/manifests/hardware/hardware.json +TINKERBELL_TEMPLATE_MANIFEST=/manifests/template/ubuntu.yaml + +TINKERBELL_CLIENT_IP=192.168.56.43 +TINKERBELL_CLIENT_MAC=08:00:27:9e:f5:3a +TINKERBELL_HOST_IP=192.168.56.4 + +# Images used by docker-compose natively or in terraform/vagrant, update if necessary +BOOTS_IMAGE=quay.io/tinkerbell/boots:sha-505785d7 +HEGEL_IMAGE=quay.io/tinkerbell/hegel:sha-592588cf +TINK_CLI_IMAGE=quay.io/tinkerbell/tink-cli:${vTINK} +TINK_SERVER_IMAGE=quay.io/tinkerbell/tink:${vTINK} +TINK_WORKER_IMAGE=quay.io/tinkerbell/tink-worker:${vTINK} diff --git a/deploy/stack/compose/setup.sh b/deploy/stack/compose/setup.sh index cd13c709..10da7c1e 100755 --- a/deploy/stack/compose/setup.sh +++ b/deploy/stack/compose/setup.sh @@ -102,7 +102,7 @@ main() { # setup_layer2_network "$host_ip" setup_compose_env_overrides "$host_ip" "$worker_ip" "$worker_mac" "$compose_dir" - docker compose -f "$compose_dir"/docker-compose.yml up -d + docker compose --env-file "$compose_dir"/.env -f "$compose_dir"/docker-compose.yml up -d create_tink_helper_script "$compose_dir" tweak_bash_interactive_settings "$compose_dir" From 2baf962ed8b24deebdf03ea41b9f50c26aaea85c Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Mon, 24 Oct 2022 23:06:07 -0400 Subject: [PATCH 6/8] Make helm chart version and helm load balancer IP configurable: This allows infrastructure to determine these values instead of being hard coded. Signed-off-by: Jacob Weinstock --- deploy/infrastructure/vagrant/.env | 7 +++++-- deploy/infrastructure/vagrant/Vagrantfile | 8 +++++++- deploy/stack/helm/setup.sh | 18 ++++++++++++------ 3 files changed, 24 insertions(+), 9 deletions(-) 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 From ab0e8dbfe1b182d4b8a52d434a9564d933c1bc8f Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Tue, 25 Oct 2022 19:29:25 +0000 Subject: [PATCH 7/8] Fix linting issues Signed-off-by: Jacob Weinstock --- .../stack/helm/manifests/ubuntu-download.yaml | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/deploy/stack/helm/manifests/ubuntu-download.yaml b/deploy/stack/helm/manifests/ubuntu-download.yaml index ae931486..0512eb8a 100644 --- a/deploy/stack/helm/manifests/ubuntu-download.yaml +++ b/deploy/stack/helm/manifests/ubuntu-download.yaml @@ -34,19 +34,23 @@ spec: - name: download-ubuntu-focal image: bash:5.2.2 command: ["/script/entrypoint.sh"] - args: ["https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img", "/output"] + args: + [ + "https://cloud-images.ubuntu.com/daily/server/focal/current/focal-server-cloudimg-amd64.img", + "/output", + ] volumeMounts: - - mountPath: /output - name: hook-artifacts - - mountPath: /script - name: configmap-volume + - mountPath: /output + name: hook-artifacts + - mountPath: /script + name: configmap-volume restartPolicy: OnFailure volumes: - - name: hook-artifacts - hostPath: - path: /opt/hook - type: DirectoryOrCreate - - name: configmap-volume - configMap: - defaultMode: 0700 - name: download-image + - name: hook-artifacts + hostPath: + path: /opt/hook + type: DirectoryOrCreate + - name: configmap-volume + configMap: + defaultMode: 0700 + name: download-image From 07a0c3e587133f0fd10831cbe9c5603e82160a85 Mon Sep 17 00:00:00 2001 From: Jacob Weinstock Date: Tue, 25 Oct 2022 20:02:17 +0000 Subject: [PATCH 8/8] Update docs to reflect new directory structure Signed-off-by: Jacob Weinstock --- docs/CONTRIBUTING.md | 28 ++++++++++++++-------------- docs/quickstarts/COMPOSE.md | 4 ++-- docs/quickstarts/TERRAFORMEM.md | 2 +- docs/quickstarts/VAGRANTLVIRT.md | 4 ++-- docs/quickstarts/VAGRANTVBOX.md | 4 ++-- test/vagrant/vagrant_test.go | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index fa34f154..33a61e15 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -23,10 +23,10 @@ Its goal is to be **_"The easiest way to setup the Tinkerbell Stack"_**. There are two major areas of responsibility. 1. Stand up of the Tinkerbell application stack - - Handled by Docker Compose ([deploy/compose/docker-compose.yml](../deploy/compose/docker-compose.yml)) + - Handled by Docker Compose ([deploy/stack/compose/docker-compose.yml](../deploy/stack/compose/docker-compose.yml)) 2. Stand up of infrastructure to support the Tinkerbell application stack - - [Vagrant](../deploy/vagrant/Vagrantfile) - - [Terraform](../deploy/terraform/main.tf) + - [Vagrant](../deploy/infrastructure/vagrant/Vagrantfile) + - [Terraform](../deploy/infrastructure/terraform/main.tf) ## Architecture @@ -61,29 +61,29 @@ The sandbox architecture can be broken down into 3 distinct groups. 3. Single Run Services - Tink Record Creation - - This [script](../deploy/compose/create-tink-records/create.sh) that creates Tink records from templated files ([hardware](../deploy/compose/create-tink-records/manifests/hardware), [template](../deploy/compose/create-tink-records/manifests/template), and workflow) + - This [script](../deploy/stack/compose/create-tink-records/create.sh) that creates Tink records from templated files ([hardware](../deploy/stack/compose/create-tink-records/manifests/hardware), [template](../deploy/stack/compose/create-tink-records/manifests/template), and workflow) - Tink DB Migrations - Builtin functionality to the Tink Server binary that will create DB schemas, tables, etc - TLS Setup - - This [script](../deploy/compose/generate-tls-certs/generate.sh) that handles creating the self-signed TLS certificates for the Tink Server and the Container Registry (the same certs are shared for both). - Valid domain names are defined in the [csr.json](../deploy/compose/generate-tls-certs/csr.json) file. By default the value of `TINKERBELL_HOST_IP` in the [.env](../deploy/compose/.env) file is added as a valid domain name. - This addition happens via the [generate.sh](../deploy/compose/generate-tls-certs/generate.sh) script. + - This [script](../deploy/stack/compose/generate-tls-certs/generate.sh) that handles creating the self-signed TLS certificates for the Tink Server and the Container Registry (the same certs are shared for both). + Valid domain names are defined in the [csr.json](../deploy/stack/compose/generate-tls-certs/csr.json) file. By default the value of `TINKERBELL_HOST_IP` in the [.env](../deploy/stack/compose/.env) file is added as a valid domain name. + This addition happens via the [generate.sh](../deploy/stack/compose/generate-tls-certs/generate.sh) script. - Registry Auth - - This container (named `registry-auth` in the [docker-compose.yml](../deploy/compose/docker-compose.yml)) creates the user/passwd pair for use to login to the container registry. + - This container (named `registry-auth` in the [docker-compose.yml](../deploy/stack/compose/docker-compose.yml)) creates the user/passwd pair for use to login to the container registry. Defaults to admin/Admin1234. - These can be customized by setting `TINKERBELL_REGISTRY_USERNAME` and `TINKERBELL_REGISTRY_PASSWORD` in the [.env](../deploy/compose/.env) file. + These can be customized by setting `TINKERBELL_REGISTRY_USERNAME` and `TINKERBELL_REGISTRY_PASSWORD` in the [.env](../deploy/stack/compose/.env) file. - Registry Image Population - - This [script](../deploy/compose/sync-images-to-local-registry/upload.sh) uploads images to the local/internal container registry, including the tink-worker image. - Any image needed in a workflow will need to be added to the [registry_images.txt](../deploy/compose/sync-images-to-local-registry/registry_images.txt) file. - The [registry_images.txt](../deploy/compose/sync-images-to-local-registry/registry_images.txt) file should not contain a final newline and each line must have the form of `space` + - This [script](../deploy/stack/compose/sync-images-to-local-registry/upload.sh) uploads images to the local/internal container registry, including the tink-worker image. + Any image needed in a workflow will need to be added to the [registry_images.txt](../deploy/stack/compose/sync-images-to-local-registry/registry_images.txt) file. + The [registry_images.txt](../deploy/stack/compose/sync-images-to-local-registry/registry_images.txt) file should not contain a final newline and each line must have the form of `space` ```bash quay.io/tinkerbell/tink-worker:latest tink-worker:latest ``` - Hook Setup - - This [script](../deploy/compose/fetch-osie/fetch.sh) handles downloading Hook, extracting it, and placing it in the path ([deploy/compose/state/misc/osie/current](../deploy/compose/state/misc/osie/current)) that the compose service `osie-bootloader` uses for serving files. + - This [script](../deploy/stack/compose/fetch-osie/fetch.sh) handles downloading Hook, extracting it, and placing it in the path ([deploy/stack/compose/state/misc/osie/current](../deploy/stack/compose/state/misc/osie/current)) that the compose service `osie-bootloader` uses for serving files. FYI, currently only an x86_64 Hook is published so only x86_64 machines can be provisioned with the sandbox using Hook. - Ubuntu Image Setup - - This [script](../deploy/compose/fetch-and-convert-ubuntu-img/fetch.sh) handles downloading the Ubuntu focal cloud `.img` file and [converting it to a raw image](https://docs.tinkerbell.org/deploying-operating-systems/examples-ubuntu/). + - This [script](../deploy/stack/compose/fetch-and-convert-ubuntu-img/fetch.sh) handles downloading the Ubuntu focal cloud `.img` file and [converting it to a raw image](https://docs.tinkerbell.org/deploying-operating-systems/examples-ubuntu/). This will be used with workflow action [`quay.io/tinkerbell-actions/image2disk:v1.0.0`](https://artifacthub.io/packages/tbaction/tinkerbell-community/image2disk). ## Prerequisites diff --git a/docs/quickstarts/COMPOSE.md b/docs/quickstarts/COMPOSE.md index 3b3b854d..4fd6dc67 100644 --- a/docs/quickstarts/COMPOSE.md +++ b/docs/quickstarts/COMPOSE.md @@ -34,12 +34,12 @@ You will need to bring your own machines to provision. export TINKERBELL_CLIENT_MAC=08:00:27:9E:F5:3A ``` - > Modify the [hardware.yaml](../../deploy/compose/manifests/hardware.yaml), as needed, for your machine. + > Modify the [hardware.yaml](../../deploy/stack/compose/manifests/hardware.yaml), as needed, for your machine. 4. Start the provisioner ```bash - cd deploy/compose + cd deploy/stack/compose docker compose up -d # This process will take about 5-10 minutes depending on your internet connection. # Hook (OSIE) is about 400MB in size and the Ubuntu Focal image is about 500MB diff --git a/docs/quickstarts/TERRAFORMEM.md b/docs/quickstarts/TERRAFORMEM.md index 2d5ebbc8..bdfc8c5d 100644 --- a/docs/quickstarts/TERRAFORMEM.md +++ b/docs/quickstarts/TERRAFORMEM.md @@ -19,7 +19,7 @@ This option will also show you how to create a machine to provision. 2. Set your Equinix Metal project id and access token ```bash - cd deploy/terraform + cd deploy/infrastructure/terraform cat << EOF > terraform.tfvars metal_api_token = "awegaga4gs4g" project_id = "235-23452-245-345" diff --git a/docs/quickstarts/VAGRANTLVIRT.md b/docs/quickstarts/VAGRANTLVIRT.md index 05af7f2b..0ac6e95a 100644 --- a/docs/quickstarts/VAGRANTLVIRT.md +++ b/docs/quickstarts/VAGRANTLVIRT.md @@ -36,7 +36,7 @@ This option will also show you how to create a machine to provision. ==> provisioner: Creating image (snapshot of base box volume). ==> provisioner: Creating domain with the following settings... ==> provisioner: -- Name: vagrant_provisioner - ==> provisioner: -- Description: Source: /home/tink/repos/tinkerbell/sandbox/deploy/vagrant/Vagrantfile + ==> provisioner: -- Description: Source: /home/tink/repos/tinkerbell/sandbox/deploy/infrastructure/vagrant/Vagrantfile ==> provisioner: -- Domain type: kvm ==> provisioner: -- Cpus: 2 ==> provisioner: -- Feature: acpi @@ -80,7 +80,7 @@ This option will also show you how to create a machine to provision. provisioner: Removing insecure key from the guest if it's present... provisioner: Key inserted! Disconnecting and reconnecting using new SSH key... ==> provisioner: Machine booted and ready! - ==> provisioner: Rsyncing folder: /home/tink/repos/tinkerbell/sandbox/deploy/compose/ => /sandbox/compose + ==> provisioner: Rsyncing folder: /home/tink/repos/tinkerbell/sandbox/deploy/stack/compose/ => /sandbox/compose ==> provisioner: Running provisioner: shell... provisioner: Running: /tmp/vagrant-shell20221004-689177-1x7ep6c.sh provisioner: + main 192.168.56.4 192.168.56.43 08:00:27:9e:f5:3a /sandbox/compose diff --git a/docs/quickstarts/VAGRANTVBOX.md b/docs/quickstarts/VAGRANTVBOX.md index 6331e8a3..9039a328 100644 --- a/docs/quickstarts/VAGRANTVBOX.md +++ b/docs/quickstarts/VAGRANTVBOX.md @@ -20,7 +20,7 @@ This option will also show you how to create a machine to provision. 2. Start the provisioner ```bash - cd deploy/vagrant + cd deploy/infrastructure/vagrant vagrant up # This process will take about 5-10 minutes depending on your internet connection. # OSIE is about 2GB in size and the Ubuntu Focal image is about 500MB @@ -57,7 +57,7 @@ This option will also show you how to create a machine to provision. ==> provisioner: Machine booted and ready! ==> provisioner: Checking for guest additions in VM... ==> provisioner: Mounting shared folders... - provisioner: /sandbox/compose => /private/tmp/sandbox/deploy/compose + provisioner: /sandbox/compose => /private/tmp/sandbox/deploy/stack/compose ==> provisioner: Running provisioner: shell... provisioner: Running: /var/folders/xt/8w5g0fv54tj4njvjhk_0_25r0000gr/T/vagrant-shell20221004-97370-3zoxlv.sh provisioner: + main 192.168.56.4 192.168.56.43 08:00:27:9e:f5:3a /sandbox/compose diff --git a/test/vagrant/vagrant_test.go b/test/vagrant/vagrant_test.go index dea800fa..6759bfb1 100644 --- a/test/vagrant/vagrant_test.go +++ b/test/vagrant/vagrant_test.go @@ -27,7 +27,7 @@ func TestVagrantSetupGuide(t *testing.T) { machine, err := vagrant.Up(ctx, vagrant.WithLogger(t.Logf), vagrant.WithMachineName("provisioner"), - vagrant.WithWorkdir("../../deploy/vagrant"), + vagrant.WithWorkdir("../../deploy/infrastructure/vagrant"), ) if err != nil { t.Fatal(err) @@ -118,7 +118,7 @@ func TestVagrantSetupGuide(t *testing.T) { worker, err := vagrant.Up(ctx, vagrant.WithLogger(t.Logf), vagrant.WithMachineName("worker"), - vagrant.WithWorkdir("../../deploy/vagrant"), + vagrant.WithWorkdir("../../deploy/infrastructure/vagrant"), vagrant.RunAsync(), ) if err != nil {