mirror of
https://github.com/khuedoan/homelab.git
synced 2024-12-22 16:04:32 +07:00
refactor: move dev cluster to master
Easier to test and less maintenance
This commit is contained in:
parent
03c0a3278f
commit
1c586813a2
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,5 +5,5 @@ book/
|
||||
*.log
|
||||
*.png
|
||||
*.tgz
|
||||
*kubeconfig.yaml
|
||||
*kubeconfig*.yaml
|
||||
Chart.lock
|
||||
|
19
Makefile
19
Makefile
@ -2,23 +2,26 @@
|
||||
.PHONY: *
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
KUBECONFIG = $(shell pwd)/metal/kubeconfig.yaml
|
||||
env ?= dev
|
||||
KUBECONFIG = $(shell pwd)/metal/kubeconfig-${env}.yaml
|
||||
KUBE_CONFIG_PATH = $(KUBECONFIG)
|
||||
|
||||
default: metal system external smoke-test post-install clean
|
||||
default: metal system external smoke-test post-install
|
||||
|
||||
configure:
|
||||
./scripts/configure
|
||||
git status
|
||||
|
||||
metal:
|
||||
make -C metal
|
||||
[ "$(env)" = "dev" ] \
|
||||
&& make k3d \
|
||||
|| make -C metal
|
||||
|
||||
system:
|
||||
make -C system
|
||||
|
||||
external:
|
||||
make -C external
|
||||
[ "$(env)" != "dev" ] && make -C external
|
||||
|
||||
smoke-test:
|
||||
make -C test filter=Smoke
|
||||
@ -40,9 +43,17 @@ test:
|
||||
|
||||
clean:
|
||||
docker compose --project-directory ./metal/roles/pxe_server/files down
|
||||
k3d cluster delete homelab-dev
|
||||
|
||||
docs:
|
||||
mkdocs serve
|
||||
|
||||
git-hooks:
|
||||
pre-commit install
|
||||
|
||||
info:
|
||||
kubectl cluster-info
|
||||
|
||||
k3d:
|
||||
k3d cluster start homelab-dev || k3d cluster create --config metal/k3d-${env}.yaml
|
||||
k3d kubeconfig get homelab-dev > metal/kubeconfig-${env}.yaml
|
||||
|
@ -6,7 +6,7 @@ Save the following files to a safe location like a password manager (if you're u
|
||||
|
||||
- `~/.ssh/id_ed25519`
|
||||
- `~/.ssh/id_ed25519.pub`
|
||||
- `./metal/kubeconfig.yaml`
|
||||
- `./metal/kubeconfig-prod.yaml`
|
||||
- `~/.terraform.d/credentials.tfrc.json`
|
||||
- `./external/terraform.tfvars`
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
.POSIX:
|
||||
|
||||
env ?= prod
|
||||
export KUBECONFIG = $(shell pwd)/kubeconfig.yaml
|
||||
export KUBECONFIG = $(shell pwd)/kubeconfig-${env}.yaml
|
||||
|
||||
default: boot cluster
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
all:
|
||||
vars:
|
||||
env: prod
|
||||
control_plane_endpoint: 192.168.1.100
|
||||
load_balancer_ip_pool:
|
||||
- 192.168.1.224/27
|
||||
|
@ -91,7 +91,7 @@
|
||||
- name: Write Kubernetes config file with the correct cluster address
|
||||
ansible.builtin.copy:
|
||||
content: "{{ kubeconfig_base64.content | b64decode | replace('127.0.0.1', control_plane_endpoint) }}"
|
||||
dest: "{{ playbook_dir }}/kubeconfig.yaml"
|
||||
dest: "{{ playbook_dir }}/kubeconfig-{{ env }}.yaml"
|
||||
mode: 0600
|
||||
delegate_to: localhost
|
||||
run_once: true
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
echo "WARNING: ArgoCD admin can do anything in the cluster, only use it for just enough initial setup or in emergencies." >&2
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
kubectl get ingress --all-namespaces --no-headers --output custom-columns="ADDRESS:.status.loadBalancer.ingress[0].ip,HOST:.spec.rules[0].host"
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
|
||||
kubectl get applicationsets --namespace argocd
|
||||
kubectl get applications --namespace argocd
|
||||
|
@ -4,7 +4,7 @@ set -eu
|
||||
|
||||
PEER="${1}"
|
||||
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
|
||||
kubectl -n wireguard exec -it deployment/wireguard -- /app/show-peer "${PEER}"
|
||||
kubectl -n wireguard exec -it deployment/wireguard -- cat "/config/peer_${PEER}/peer_${PEER}.conf"
|
||||
|
@ -5,5 +5,5 @@ set -eu
|
||||
account="${1}"
|
||||
|
||||
echo "WARNING: Kanidm admin can do anything in the cluster, only use it for just enough initial setup or in emergencies." >&2
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
kubectl exec -it -n kanidm statefulset/kanidm -- kanidmd recover-account "${account}"
|
||||
|
@ -4,7 +4,7 @@ username="${1}"
|
||||
fullname="${2}"
|
||||
mail="${3}"
|
||||
|
||||
export KUBECONFIG=./metal/kubeconfig.yaml
|
||||
export KUBECONFIG=./metal/kubeconfig-${env}.yaml
|
||||
host="$(kubectl get ingress --namespace kanidm kanidm --output jsonpath='{.spec.rules[0].host}')"
|
||||
|
||||
kanidm person create "${username}" "${fullname}" --url "https://${host}" --name idm_admin
|
||||
|
@ -1,8 +1,9 @@
|
||||
.POSIX:
|
||||
|
||||
export KUBECONFIG = $(shell pwd)/../metal/kubeconfig.yaml
|
||||
export KUBECONFIG = $(shell pwd)/../metal/kubeconfig-${env}.yaml
|
||||
|
||||
.PHONY: bootstrap
|
||||
bootstrap:
|
||||
ansible-playbook \
|
||||
--extra-vars "env=${env}" \
|
||||
bootstrap.yml
|
||||
|
13
system/argocd/values-dev.yaml
Normal file
13
system/argocd/values-dev.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
argo-cd:
|
||||
global:
|
||||
domain: argocd.127-0-0-1.nip.io
|
||||
argocd-apps:
|
||||
applicationsets:
|
||||
root:
|
||||
template:
|
||||
spec:
|
||||
source:
|
||||
helm:
|
||||
valueFiles:
|
||||
- values-dev.yaml
|
||||
ignoreMissingValueFiles: true
|
13
system/argocd/values-prod.yaml
Normal file
13
system/argocd/values-prod.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
argo-cd:
|
||||
global:
|
||||
domain: argocd.khuedoan.com
|
||||
argocd-apps:
|
||||
applicationsets:
|
||||
root:
|
||||
template:
|
||||
spec:
|
||||
source:
|
||||
helm:
|
||||
valueFiles:
|
||||
- values-dev.yaml
|
||||
ignoreMissingValueFiles: true
|
@ -53,6 +53,8 @@ argocd-apps:
|
||||
repoURL: *repoURL
|
||||
path: '{{path}}'
|
||||
targetRevision: *revision
|
||||
helm:
|
||||
ignoreMissingValueFiles: true
|
||||
syncPolicy:
|
||||
automated:
|
||||
prune: true
|
||||
|
@ -25,6 +25,7 @@
|
||||
release_namespace: argocd
|
||||
dependency_update: true
|
||||
values_files:
|
||||
- "argocd/values-{{ env }}.yaml"
|
||||
- "argocd/{{ (first_install.resources | length == 0) | ternary('values-seed.yaml', 'values.yaml') }}"
|
||||
register: argocd_manifests
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user