Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions p2/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
VAGRANT_FILE ?= Vagrantfile.ingress

MODE ?= ingress
HOSTS_LINE = 192.168.56.110 app1.com app2.com app3.com

VAGRANT_CMD = VAGRANT_VAGRANTFILE=$(VAGRANT_FILE) vagrant
VAGRANT_CMD = MODE=$(MODE) vagrant

all:
@echo "Starting Vagrant VM unsing $(VAGRANT_FILE)..."
@echo "Starting Vagrant VM with mode: $(MODE)"
$(VAGRANT_CMD) up

setup:
Expand All @@ -15,7 +14,7 @@ setup:
else \
echo "Hosts entries already present."; \
fi
@echo "Starting Vagrant VM using $(VAGRANT_FILE)..."
@echo "Starting Vagrant VM with mode: $(MODE)"
$(VAGRANT_CMD) up

into:
Expand Down
4 changes: 3 additions & 1 deletion p2/Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
LOGIN = "lyeh"

MODE = ENV.fetch("MODE", "ingress").downcase

Vagrant.configure("2") do |config|
config.vm.box = "debian/bookworm64"
config.vm.provider "virtualbox" do |vb|
Expand All @@ -16,7 +18,7 @@ Vagrant.configure("2") do |config|
srv.vm.hostname = "#{LOGIN}S"
srv.vm.network "private_network", ip: "192.168.56.110"

srv.vm.provision "shell", path: "tools/k3s_server.sh", args: ["192.168.56.110"]
srv.vm.provision "shell", path: "tools/k3s_server.sh", args: ["192.168.56.110", MODE]
end

end
24 changes: 0 additions & 24 deletions p2/Vagrantfile.ingress

This file was deleted.

42 changes: 0 additions & 42 deletions p2/manifests/apps/app1/deploy.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions p2/manifests/apps/app1/html.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions p2/manifests/apps/app1/kustomization.yaml

This file was deleted.

40 changes: 0 additions & 40 deletions p2/manifests/apps/app2/deploy.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions p2/manifests/apps/app2/html.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions p2/manifests/apps/app2/kustomization.yaml

This file was deleted.

40 changes: 0 additions & 40 deletions p2/manifests/apps/app3/deploy.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions p2/manifests/apps/app3/html.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions p2/manifests/apps/app3/kustomization.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions p2/manifests/kustomization.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# manifest/apps/app1/route.yaml
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: app1-route
namespace: application
spec:
parentRefs:
- name: web
namespace: application
sectionName: http
hostnames: ["app1.com"]
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: app2-route
namespace: application
spec:
parentRefs:
- name: web
namespace: application
sectionName: http
hostnames: ["app2.com"]
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: app3-route
namespace: application
spec:
parentRefs:
- name: web
namespace: application
sectionName: http
rules:
- backendRefs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: web
namespace: application
spec:
gatewayClassName: traefik
listeners:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../base
- gateway.yaml
- app1-route.yaml
- app2-route.yaml
- app3-route.yaml
18 changes: 13 additions & 5 deletions p2/tools/k3s_server.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail
IP=${1:?provide server IP}
MODE_IN=${2:-ingress}

shopt -s nocasematch
case "${MODE_IN}" in
gwa|gw|gateway) MODE="gateway" ;;
ing|ingress) MODE="ingress" ;;
*) MODE="ingress" ;;
esac
shopt -u nocasematch

GWA_VER="v1.3.0"
TRAEFIK_NS="application"

echo "▶️ 1. Install k3s without built-in Traefik"
curl -sfL https://get.k3s.io | \
Expand Down Expand Up @@ -33,7 +41,7 @@ helm uninstall traefik -n kube-system || true
helm version --short
helm repo add traefik https://traefik.github.io/charts && helm repo update
helm upgrade --install traefik traefik/traefik \
--namespace "${TRAEFIK_NS}" --create-namespace --wait \
--create-namespace --wait \
--set providers.kubernetesGateway.enabled=true \
--set providers.kubernetesIngress.enabled=true \
--set ingressClass.enabled=true \
Expand All @@ -45,7 +53,7 @@ helm upgrade --install traefik traefik/traefik \
--set gateway.enabled=false

echo "▶️ 6. Wait for Traefik to be Ready"
kubectl rollout status deploy/traefik -n ${TRAEFIK_NS} --timeout=180s
kubectl rollout status deploy/traefik --timeout=180s

echo "▶️ 7. Apply GatewayClass/Gateway and routes"
kubectl apply -k /vagrant/manifests # your app + HTTPRoutes
echo "▶️ 7. Apply manifests overlays (${MODE})"
kubectl apply -k /vagrant/manifests/overlays/${MODE}