Compare commits
6 Commits
just
...
b47fe8f66b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b47fe8f66b | ||
|
|
c5810661e5 | ||
|
|
7ddc08d622 | ||
|
|
c5aa7f8105 | ||
|
|
0c6cfedcde | ||
| 2be83a977a |
@@ -6,7 +6,7 @@ export EXTERNAL_K8S_HOST := env("EXTERNAL_K8S_HOST", "")
|
|||||||
export KEYCLOAK_HOST := env("KEYCLOAK_HOST", "")
|
export KEYCLOAK_HOST := env("KEYCLOAK_HOST", "")
|
||||||
export KEYCLOAK_REALM := env("KEYCLOAK_REALM", "buunstack")
|
export KEYCLOAK_REALM := env("KEYCLOAK_REALM", "buunstack")
|
||||||
export K8S_OIDC_CLIENT_ID := env('K8S_OIDC_CLIENT_ID', "k8s")
|
export K8S_OIDC_CLIENT_ID := env('K8S_OIDC_CLIENT_ID', "k8s")
|
||||||
export K3S_ENABLE_REGISTRY := env("K3S_ENABLE_REGISTRY", "false")
|
export K3S_ENABLE_REGISTRY := env("K3S_ENABLE_REGISTRY", "true")
|
||||||
export SERVER_IP := env("K3S_SERVER_IP","192.168.178.45")
|
export SERVER_IP := env("K3S_SERVER_IP","192.168.178.45")
|
||||||
export AGENT_IP := env("K3S_AGENT_IP","192.168.178.75")
|
export AGENT_IP := env("K3S_AGENT_IP","192.168.178.75")
|
||||||
export USER := env("K3S_USER","basti")
|
export USER := env("K3S_USER","basti")
|
||||||
@@ -33,16 +33,17 @@ install:
|
|||||||
|
|
||||||
args=(
|
args=(
|
||||||
"install"
|
"install"
|
||||||
"--context" "${K8S_CONTEXT}"
|
"--context" "${context}"
|
||||||
"--host" "${K8S_MASTER_NODE_NAME}"
|
"--host" "${K8S_MASTER_NODE_NAME}"
|
||||||
"--user" "${username}"
|
"--user" "${username}"
|
||||||
|
"--no-extras" #
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ -n "${kubeconfig}" ]; then
|
if [ -n "${kubeconfig}" ]; then
|
||||||
mkdir -p "$(dirname "${kubeconfig}")"
|
mkdir -p "$(dirname "${kubeconfig}")"
|
||||||
args+=("--local-path" "${kubeconfig}" "--merge")
|
args+=("--local-path" "${kubeconfig}" "--merge")
|
||||||
fi
|
fi
|
||||||
echo "Running: k3sup ${args[*]}"
|
echo "Running: k3sup ${args[@]}"
|
||||||
k3sup "${args[@]}"
|
k3sup "${args[@]}"
|
||||||
|
|
||||||
if [ -n "${context}" ]; then
|
if [ -n "${context}" ]; then
|
||||||
@@ -133,3 +134,15 @@ add-agent:
|
|||||||
k3sup "${args[@]}"
|
k3sup "${args[@]}"
|
||||||
echo "Agent node at ${new_agent_ip} added to cluster."
|
echo "Agent node at ${new_agent_ip} added to cluster."
|
||||||
|
|
||||||
|
# Configure k3s to use local registry
|
||||||
|
configure-registry:
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
echo "Configuring k3s registries.yaml..."
|
||||||
|
|
||||||
|
ssh "${K8S_MASTER_NODE_NAME}" "sudo mkdir -p /etc/rancher/k3s"
|
||||||
|
gomplate -f ./registry/registries.gomplate.yaml | ssh "${K8S_MASTER_NODE_NAME}" "sudo tee /etc/rancher/k3s/registries.yaml > /dev/null"
|
||||||
|
|
||||||
|
echo "Restarting k3s to apply registry configuration..."
|
||||||
|
ssh "${K8S_MASTER_NODE_NAME}" "sudo systemctl restart k3s"
|
||||||
|
echo "✓ Registry configuration applied"
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -5,5 +5,4 @@ metadata:
|
|||||||
namespace: metallb-system
|
namespace: metallb-system
|
||||||
spec:
|
spec:
|
||||||
addresses:
|
addresses:
|
||||||
# - 192.168.178.220-192.168.178.225 #pve-82
|
- {{ .Env.METALLB_ADDRESS_RANGE }}
|
||||||
- 192.168.178.160-192.168.178.180 #pve-83
|
|
||||||
47
Metallb_Setup/justfile
Normal file
47
Metallb_Setup/justfile
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
set fallback := true
|
||||||
|
|
||||||
|
export K8S_CONTEXT := env("K8S_CONTEXT", "")
|
||||||
|
export SERVER_IP := env("K3S_SERVER_IP","192.168.178.45")
|
||||||
|
export USER := env("K3S_USER","basti")
|
||||||
|
|
||||||
|
|
||||||
|
[private]
|
||||||
|
default:
|
||||||
|
@just --list --unsorted --list-submodules
|
||||||
|
|
||||||
|
|
||||||
|
install:
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
just env::check
|
||||||
|
|
||||||
|
METALLB_VERSION="v0.15.3"
|
||||||
|
|
||||||
|
username=$(gum input --prompt="SSH username: " --value="${USER}" --width=100)
|
||||||
|
context=""
|
||||||
|
if gum confirm "Update KUBECONFIG?"; then
|
||||||
|
context=$(
|
||||||
|
gum input --prompt="Context name: " --value="${K8S_CONTEXT}" --width=100
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${context}" ]; then
|
||||||
|
kubectl config use-context "${context}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/${METALLB_VERSION}/config/manifests/metallb-native.yaml"
|
||||||
|
gum spin --spinner dot --title "Waiting for MetalLB to be ready..." -- kubectl wait --namespace metallb-system --for=condition=available deployment --all --timeout=120s
|
||||||
|
echo "MetalLB ${METALLB_VERSION} installed successfully."
|
||||||
|
|
||||||
|
gomplate -f address-pool.gomplate.yaml | kubectl apply -f -
|
||||||
|
echo "Address pool configured."
|
||||||
|
|
||||||
|
kubectl apply -f advertisement.yaml
|
||||||
|
echo "Advertisement created."
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
just env::check
|
||||||
|
|
||||||
|
kubectl get namespace metallb-system &>/dev/null && kubectl delete ns metallb-system
|
||||||
@@ -24,13 +24,15 @@ i.e. general issuer for all namespaces in cluster.
|
|||||||
|
|
||||||
|
|
||||||
## Test Deployment
|
## Test Deployment
|
||||||
|
```
|
||||||
k create ns test
|
k create ns test
|
||||||
kubectl create deploy nginx --image=nginx -n test
|
kubectl create deploy nginx --image=nginx -n test
|
||||||
k create svc -n test clusterip nginx --tcp=80
|
k create svc -n test clusterip nginx --tcp=80
|
||||||
k scale --replicas=3 deployment/nginx -n test
|
k scale --replicas=3 deployment/nginx -n test
|
||||||
|
```
|
||||||
|
|
||||||
## Install Traefik & Cert-Manager
|
## Install Traefik & Cert-Manager
|
||||||
|
```
|
||||||
|
|
||||||
helm install traefik traefik/traefik --namespace traefik --create-namespace --values traefik-values.yaml
|
helm install traefik traefik/traefik --namespace traefik --create-namespace --values traefik-values.yaml
|
||||||
|
|
||||||
@@ -40,23 +42,25 @@ helm repo add jetstack https://charts.jetstack.io --force-update
|
|||||||
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --values cert-manager-values.yaml
|
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --values cert-manager-values.yaml
|
||||||
|
|
||||||
|
|
||||||
k apply cert-manager-issuer-secret.yaml
|
k apply -f cert-manager-issuer-secret.yaml
|
||||||
k get secret -n cert-manager
|
k get secret -n cert-manager
|
||||||
|
|
||||||
k apply -f cert-manager-cluster-issuer.yaml
|
k apply -f cert-manager-cluster-issuer.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Switch Test Deployment to https
|
## Switch Test Deployment to https
|
||||||
|
```
|
||||||
k apply -f test/nginx-certificate.yaml
|
k apply -f test/nginx-certificate.yaml
|
||||||
k apply -f test/nginx-ingress.yaml
|
k apply -f test/nginx-ingress.yaml
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Troubleshooting steps
|
## Troubleshooting steps
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
k get po -n test -o wide
|
k get po -n test -o wide
|
||||||
k create svc -n test clusterip nginx
|
k create svc -n test clusterip nginx
|
||||||
k create svc -n test clusterip nginx --tcp=80
|
k create svc -n test clusterip nginx --tcp=80
|
||||||
@@ -70,12 +74,11 @@ k apply -f traefik_lempa/nginx-ingress.yaml
|
|||||||
k get svc -n test
|
k get svc -n test
|
||||||
k get ingress
|
k get ingress
|
||||||
k get ingress -n test
|
k get ingress -n test
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
k get svc ingressRoute
|
k get svc ingressRoute
|
||||||
k get svc ingressRoutes
|
k get svc ingressRoutes
|
||||||
k get svc ingressroutes.traefik.io
|
k get svc ingressroutes.traefik.io
|
||||||
@@ -90,3 +93,4 @@ k apply -f traefik_lempa/cert-manager-issuer-secret.yaml
|
|||||||
k get secret
|
k get secret
|
||||||
k get secrets
|
k get secrets
|
||||||
k get clusterissuers.cert-manager.io
|
k get clusterissuers.cert-manager.io
|
||||||
|
```
|
||||||
1
env/env.local.gomplate
vendored
1
env/env.local.gomplate
vendored
@@ -3,3 +3,4 @@ K8S_CONTEXT={{ .Env.K8S_CONTEXT }}
|
|||||||
K8S_MASTER_NODE_NAME={{ .Env.K8S_MASTER_NODE_NAME }}
|
K8S_MASTER_NODE_NAME={{ .Env.K8S_MASTER_NODE_NAME }}
|
||||||
SERVER_IP={{ .Env.SERVER_IP }}
|
SERVER_IP={{ .Env.SERVER_IP }}
|
||||||
AGENT_IP={{ .Env.AGENT_IP }}
|
AGENT_IP={{ .Env.AGENT_IP }}
|
||||||
|
METALLB_ADDRESS_RANGE={{ .Env.METALLB_ADDRESS_RANGE }}
|
||||||
|
|||||||
12
env/justfile
vendored
12
env/justfile
vendored
@@ -79,5 +79,17 @@ setup:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
while [ -z "${METALLB_ADDRESS_RANGE}" ]; do
|
||||||
|
if ! METALLB_ADDRESS_RANGE=$(
|
||||||
|
gum input --prompt="IP Range for LoadBalancer: " \
|
||||||
|
--width=100 --placeholder="[x.x.x.x-y.y.y.y]"
|
||||||
|
); then
|
||||||
|
echo "Setup cancelled." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
rm -f ../.env.local
|
rm -f ../.env.local
|
||||||
gomplate -f env.local.gomplate -o ../.env.local
|
gomplate -f env.local.gomplate -o ../.env.local
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ flux bootstrap gitea --repository=k3s-homelab --branch=main --personal --owner b
|
|||||||
|
|
||||||
https://bash.ghost.io/secure-kubernetes-secrets-disaster-recovery-with-sops-gitops-fluxcd/
|
https://bash.ghost.io/secure-kubernetes-secrets-disaster-recovery-with-sops-gitops-fluxcd/
|
||||||
|
|
||||||
|
"Make a 4×4 grid starting with the 1880s. In each section, I should appear styled according to that decade (clothing, hairstyle, facial hair, accessories). Use colors, background, & film style accordingly."
|
||||||
Reference in New Issue
Block a user