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