Justfile with nested kustomization to simply apply/deploy
This commit is contained in:
parent
a3852b611c
commit
240ea04de3
25 changed files with 205 additions and 0 deletions
30
deploy/00-infisical.sh
Executable file
30
deploy/00-infisical.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Parse command line arguments
|
||||
RECREATE=false
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--recreate)
|
||||
RECREATE=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Check if the secret already exists
|
||||
SECRET_EXISTS=$(kubectl get secret universal-auth-credentials -n infisical --ignore-not-found -o name)
|
||||
|
||||
if [[ -n "$SECRET_EXISTS" && "$RECREATE" == "true" ]]; then
|
||||
echo "Recreating Infisical bootstrap secret..."
|
||||
kubectl delete secret universal-auth-credentials -n infisical
|
||||
kubectl create secret generic universal-auth-credentials -n infisical \
|
||||
--from-literal clientId=$(gopass show -o homelab/infisical/id) \
|
||||
--from-literal clientSecret=$(gopass show -o homelab/infisical/secret)
|
||||
elif [[ -z "$SECRET_EXISTS" ]]; then
|
||||
echo "Creating Infisical bootstrap secret..."
|
||||
kubectl create secret generic universal-auth-credentials -n infisical \
|
||||
--from-literal clientId=$(gopass show -o homelab/infisical/id) \
|
||||
--from-literal clientSecret=$(gopass show -o homelab/infisical/secret)
|
||||
else
|
||||
echo "Infisical bootstrap secret already exists, skipping creation (use --recreate to force)"
|
||||
fi
|
5
deploy/00-infisical/kustomization.yaml
Normal file
5
deploy/00-infisical/kustomization.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../../namespaces/infisical/
|
6
deploy/01-infra.sh
Executable file
6
deploy/01-infra.sh
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
echo -n "Checking for Infrastructure CRDs... "
|
||||
kubectl wait --for condition=established crd/httproutes.gateway.networking.k8s.io > /dev/null
|
||||
kubectl wait --for condition=established crd/volumes.longhorn.io > /dev/null
|
||||
kubectl wait --for condition=established crd/certificates.cert-manager.io > /dev/null
|
||||
echo "done"
|
8
deploy/01-infra/kustomization.yaml
Normal file
8
deploy/01-infra/kustomization.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../../namespaces/cert-manager/
|
||||
- ../../namespaces/homelab/
|
||||
- ../../namespaces/longhorn/
|
||||
- ../../namespaces/traefik/
|
5
deploy/10-apps/kustomization.yaml
Normal file
5
deploy/10-apps/kustomization.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- ../../namespaces/
|
43
justfile
Normal file
43
justfile
Normal file
|
@ -0,0 +1,43 @@
|
|||
set export := true
|
||||
verbose := "false"
|
||||
diff := "kubectl diff -k"
|
||||
apply := "kubectl apply -k"
|
||||
redirect := if verbose == "true" { "" } else { "> /dev/null" }
|
||||
|
||||
default:
|
||||
@just --list
|
||||
|
||||
infisical_bootstrap_secret recreate="":
|
||||
@echo "-- Adding Infisical Bootstrap secret --"
|
||||
@./deploy/00-infisical.sh {{ recreate }}
|
||||
|
||||
_diff_infisical:
|
||||
@echo "-- Diffing Infisical resources --"
|
||||
@{{ diff }} deploy/00-infisical || [ $? -eq 1 ]
|
||||
_diff_infra:
|
||||
@echo "-- Diffing Infra resources --"
|
||||
@{{ diff }} deploy/01-infra || [ $? -eq 1 ]
|
||||
_diff_apps:
|
||||
@echo "-- Diffing Apps --"
|
||||
@{{ diff }} deploy/10-apps || [ $? -eq 1 ]
|
||||
# @./deploy/10-apps.sh
|
||||
|
||||
_apply_infisical:
|
||||
@echo "-- Applying Infisical resources --"
|
||||
@{{ apply }} deploy/00-infisical {{ redirect }}
|
||||
_apply_infra:
|
||||
@echo "-- Applying Infra resources --"
|
||||
@{{ apply }} deploy/01-infra {{ redirect }}
|
||||
@./deploy/01-infra.sh
|
||||
_apply_apps:
|
||||
@echo "-- Applying Apps --"
|
||||
@{{ apply }} deploy/10-apps {{ redirect }}
|
||||
|
||||
_apply_post: _apply_infra _apply_apps
|
||||
|
||||
diff: _diff_infisical _diff_infra _diff_apps
|
||||
apply: _apply_infisical _apply_post
|
||||
_deploy recreate="": _apply_infisical (infisical_bootstrap_secret recreate) _apply_post
|
||||
deploy: _deploy
|
||||
|
||||
redeploy: (_deploy "--recreate")
|
8
namespaces/ai/kustomization.yaml
Normal file
8
namespaces/ai/kustomization.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- ollama/
|
||||
- tabby/
|
||||
- openwebui/
|
13
namespaces/apps/kustomization.yaml
Normal file
13
namespaces/apps/kustomization.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- smtp-secrets.yaml
|
||||
- atuin/
|
||||
- dolibarr/
|
||||
- forgejo/
|
||||
- linkwarden/
|
||||
- mealie/
|
||||
- paperless/
|
||||
- vaultwarden/
|
7
namespaces/auth/namespace.yaml
Normal file
7
namespaces/auth/namespace.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
labels:
|
||||
homelab-access: "true"
|
||||
name: auth
|
6
namespaces/cert-manager/kustomization.yaml
Normal file
6
namespaces/cert-manager/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- cert-manager/
|
8
namespaces/cert-manager/post-crd/kustomization.yaml
Normal file
8
namespaces/cert-manager/post-crd/kustomization.yaml
Normal file
|
@ -0,0 +1,8 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- cluster-issuer.yaml
|
||||
- consultjlpdotcom-cert.yaml
|
||||
- jlptechdotconsulting-cert.yaml
|
||||
- leechpepindotcom-cert.yaml
|
6
namespaces/charts/kustomization.yaml
Normal file
6
namespaces/charts/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- gpu-runtime.yaml
|
9
namespaces/core/kustomization.yaml
Normal file
9
namespaces/core/kustomization.yaml
Normal file
|
@ -0,0 +1,9 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- postgres/
|
||||
- redis/
|
||||
- tika/
|
||||
- gotenburg/
|
6
namespaces/homelab/kustomization.yaml
Normal file
6
namespaces/homelab/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- gateway.yaml
|
6
namespaces/infisical/kustomization.yaml
Normal file
6
namespaces/infisical/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- infisical/
|
12
namespaces/kustomization.yaml
Normal file
12
namespaces/kustomization.yaml
Normal file
|
@ -0,0 +1,12 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- cert-manager/post-crd
|
||||
- ai/
|
||||
- apps/
|
||||
- auth/
|
||||
- core/
|
||||
- charts/
|
||||
- monitoring/
|
||||
- public/
|
6
namespaces/longhorn/kustomization.yaml
Normal file
6
namespaces/longhorn/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- longhorn/
|
10
namespaces/monitoring/kustomization.yaml
Normal file
10
namespaces/monitoring/kustomization.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- smtp-secrets.yaml
|
||||
- umami/
|
||||
- ntfy/
|
||||
- diun/
|
||||
- healthchecks/
|
5
namespaces/public/kustomization.yaml
Normal file
5
namespaces/public/kustomization.yaml
Normal file
|
@ -0,0 +1,5 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
6
namespaces/traefik/kustomization.yaml
Normal file
6
namespaces/traefik/kustomization.yaml
Normal file
|
@ -0,0 +1,6 @@
|
|||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- traefik/
|
Loading…
Add table
Reference in a new issue