commit f9189482e75248ca65a3e8320ec980d2156d26c8 Author: Sirius DevOps Date: Thu Sep 10 23:38:04 2026 -0400 Initial HomeK8s tree matching lab GitOps layout. Storage and Gateway apply with kubectl -k until Forgejo+Flux. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..233b573 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +kubeconfig +age.agekey +*.age +secrets/ +**/*secret*.yaml +!**/kustomization.yaml +.DS_Store +*.swp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0889404 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +.PHONY: apply diff storage gateway + +apply: + kubectl apply -k infrastructure/home + +diff: + kubectl diff -k infrastructure/home + +storage: + kubectl apply -k infrastructure/storage + +gateway: + kubectl apply -k infrastructure/networking/gateway diff --git a/README.md b/README.md new file mode 100644 index 0000000..999dac5 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# HomeK8s + +Home Kubernetes cluster (kubeadm), same GitOps layout as `lab/`. + +Flux CD will take over once Forgejo is back. Until then apply with kustomize: + +```bash +kubectl apply -k infrastructure/home +``` + +## Cluster + +| Node | WG IP | Roles | Notes | +|-------------|------------|--------------------------|--------------------------------------------| +| siriussec | 10.10.0.2 | control-plane, worker | default scheduling | +| rpi | 10.10.0.1 | traffic, worker | `dedicated=network:PreferNoSchedule` | + +- CNI: Cilium 1.18.13, kube-proxy replacement, Gateway API hostNetwork on `dedicated=network` +- Overlay: WireGuard `10.10.0.0/24` (API only on WG) +- Ingress: Cloudflare tunnel → `127.0.0.1:8080` on rpi → Gateway `gateway-system/public` +- Storage: local-path on siriussec (`/opt/local-path-provisioner`) + +Pin traffic / light workloads to the Pi: + +```yaml +nodeSelector: + dedicated: network +``` + +## Layout + +``` +homek8s/ +├── apps/ +│ ├── base/ # app definitions +│ └── home/ # overlay applied to this cluster +├── clusters/ +│ └── home/ # Flux Kustomizations (bootstrap later) +│ ├── flux-system/ # flux bootstrap (after Forgejo) +│ ├── apps.yaml +│ ├── infrastructure.yaml +│ └── monitoring.yaml +├── infrastructure/ +│ ├── home/ # kubectl apply -k target (no HelmRelease) +│ ├── networking/ +│ │ ├── cilium/ # HelmRelease for Flux +│ │ └── gateway/ # Cilium Gateway API +│ ├── storage/ # local-path provisioner +│ ├── controllers/ +│ └── databases/ +└── monitoring/ +``` + +## Apply (now) + +```bash +kubectl apply -k infrastructure/home +``` + +That installs storage + the public Gateway. Cilium is already running; its HelmRelease is only for Flux. + +## Flux (later) + +When Forgejo is up: + +```bash +flux bootstrap git \ + --url=ssh://git@forgejo.siriusdevops.com:222/sirius/homek8s.git \ + --branch=master \ + --path=clusters/home +``` + +`clusters/home/*.yaml` already point at `./apps/home`, `./infrastructure/home`, and `./monitoring/controllers/home`. diff --git a/apps/base/README.md b/apps/base/README.md new file mode 100644 index 0000000..1d8847e --- /dev/null +++ b/apps/base/README.md @@ -0,0 +1,11 @@ +# apps/base + +One directory per app (namespace, workload, service, HTTPRoute). Overlays in `apps/home` select what this cluster runs. + +HTTPRoutes should `parentRefs` the Gateway: + +```yaml +parentRefs: + - name: public + namespace: gateway-system +``` diff --git a/apps/home/kustomization.yaml b/apps/home/kustomization.yaml new file mode 100644 index 0000000..b273efd --- /dev/null +++ b/apps/home/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] +# - ../base/forgejo diff --git a/clusters/home/apps.yaml b/clusters/home/apps.yaml new file mode 100644 index 0000000..e0ca682 --- /dev/null +++ b/clusters/home/apps.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: apps + namespace: flux-system +spec: + interval: 1m0s + retryInterval: 1m + timeout: 5m + sourceRef: + kind: GitRepository + name: flux-system + path: ./apps/home + prune: true + dependsOn: + - name: infrastructure diff --git a/clusters/home/flux-system/README.md b/clusters/home/flux-system/README.md new file mode 100644 index 0000000..f63625d --- /dev/null +++ b/clusters/home/flux-system/README.md @@ -0,0 +1,10 @@ +# Flux bootstrap — after Forgejo is up + +```bash +flux bootstrap git \ + --url=ssh://git@forgejo.siriusdevops.com:222/sirius/homek8s.git \ + --branch=master \ + --path=clusters/home +``` + +That writes `gotk-components.yaml` and `gotk-sync.yaml` here. Do not hand-edit those files. diff --git a/clusters/home/infrastructure.yaml b/clusters/home/infrastructure.yaml new file mode 100644 index 0000000..d01d48d --- /dev/null +++ b/clusters/home/infrastructure.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: infrastructure + namespace: flux-system +spec: + interval: 1m0s + retryInterval: 1m + timeout: 5m + sourceRef: + kind: GitRepository + name: flux-system + path: ./infrastructure/home + prune: true diff --git a/clusters/home/kustomization.yaml b/clusters/home/kustomization.yaml new file mode 100644 index 0000000..8a56d26 --- /dev/null +++ b/clusters/home/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - apps.yaml + - infrastructure.yaml + - monitoring.yaml diff --git a/clusters/home/monitoring.yaml b/clusters/home/monitoring.yaml new file mode 100644 index 0000000..9f00005 --- /dev/null +++ b/clusters/home/monitoring.yaml @@ -0,0 +1,16 @@ +apiVersion: kustomize.toolkit.fluxcd.io/v1 +kind: Kustomization +metadata: + name: monitoring + namespace: flux-system +spec: + interval: 1m0s + retryInterval: 1m + timeout: 5m + sourceRef: + kind: GitRepository + name: flux-system + path: ./monitoring/controllers/home + prune: true + dependsOn: + - name: infrastructure diff --git a/infrastructure/controllers/home/kustomization.yaml b/infrastructure/controllers/home/kustomization.yaml new file mode 100644 index 0000000..b83b23e --- /dev/null +++ b/infrastructure/controllers/home/kustomization.yaml @@ -0,0 +1,3 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/infrastructure/databases/base/kustomization.yaml b/infrastructure/databases/base/kustomization.yaml new file mode 100644 index 0000000..b83b23e --- /dev/null +++ b/infrastructure/databases/base/kustomization.yaml @@ -0,0 +1,3 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: [] diff --git a/infrastructure/home/kustomization.yaml b/infrastructure/home/kustomization.yaml new file mode 100644 index 0000000..874f364 --- /dev/null +++ b/infrastructure/home/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../storage + - ../networking/gateway +# Cilium HelmRelease lives in networking/cilium and is applied by Flux +# after the helm-controller exists. Do not kubectl-apply it. diff --git a/infrastructure/networking/cilium/kustomization.yaml b/infrastructure/networking/cilium/kustomization.yaml new file mode 100644 index 0000000..1c91239 --- /dev/null +++ b/infrastructure/networking/cilium/kustomization.yaml @@ -0,0 +1,12 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: kube-system +resources: + - repository.yaml + - release.yaml +configMapGenerator: + - name: cilium-values + files: + - values.yaml=values.yaml +configurations: + - kustomizeconfig.yaml diff --git a/infrastructure/networking/cilium/kustomizeconfig.yaml b/infrastructure/networking/cilium/kustomizeconfig.yaml new file mode 100644 index 0000000..a80be15 --- /dev/null +++ b/infrastructure/networking/cilium/kustomizeconfig.yaml @@ -0,0 +1,6 @@ +nameReference: + - kind: ConfigMap + version: v1 + fieldSpecs: + - path: spec/valuesFrom/name + kind: HelmRelease diff --git a/infrastructure/networking/cilium/release.yaml b/infrastructure/networking/cilium/release.yaml new file mode 100644 index 0000000..d225934 --- /dev/null +++ b/infrastructure/networking/cilium/release.yaml @@ -0,0 +1,19 @@ +apiVersion: helm.toolkit.fluxcd.io/v2beta2 +kind: HelmRelease +metadata: + name: cilium + namespace: kube-system +spec: + releaseName: cilium + interval: 15m + chart: + spec: + chart: cilium + version: "1.18.13" + sourceRef: + kind: HelmRepository + name: cilium + namespace: kube-system + valuesFrom: + - kind: ConfigMap + name: cilium-values diff --git a/infrastructure/networking/cilium/repository.yaml b/infrastructure/networking/cilium/repository.yaml new file mode 100644 index 0000000..a34a57a --- /dev/null +++ b/infrastructure/networking/cilium/repository.yaml @@ -0,0 +1,8 @@ +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: cilium + namespace: kube-system +spec: + interval: 24h + url: https://helm.cilium.io/ diff --git a/infrastructure/networking/cilium/values.yaml b/infrastructure/networking/cilium/values.yaml new file mode 100644 index 0000000..51ece41 --- /dev/null +++ b/infrastructure/networking/cilium/values.yaml @@ -0,0 +1,30 @@ +kubeProxyReplacement: true +k8sServiceHost: "10.10.0.2" +k8sServicePort: "6443" + +l7Proxy: true + +gatewayAPI: + enabled: true + hostNetwork: + enabled: true + nodes: + matchLabels: + dedicated: network + +envoy: + enabled: true + +operator: + replicas: 1 + nodeSelector: + kubernetes.io/hostname: siriussec + +ipam: + mode: cluster-pool + operator: + clusterPoolIPv4PodCIDRList: + - 10.244.0.0/16 + +routingMode: tunnel +tunnelProtocol: vxlan diff --git a/infrastructure/networking/gateway/gateway.yaml b/infrastructure/networking/gateway/gateway.yaml new file mode 100644 index 0000000..2e74d4d --- /dev/null +++ b/infrastructure/networking/gateway/gateway.yaml @@ -0,0 +1,16 @@ +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: public + namespace: gateway-system + labels: + dedicated: network +spec: + gatewayClassName: cilium + listeners: + - name: http + protocol: HTTP + port: 8080 + allowedRoutes: + namespaces: + from: All diff --git a/infrastructure/networking/gateway/kustomization.yaml b/infrastructure/networking/gateway/kustomization.yaml new file mode 100644 index 0000000..a64a0c8 --- /dev/null +++ b/infrastructure/networking/gateway/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + - gateway.yaml diff --git a/infrastructure/networking/gateway/namespace.yaml b/infrastructure/networking/gateway/namespace.yaml new file mode 100644 index 0000000..3dbea03 --- /dev/null +++ b/infrastructure/networking/gateway/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: gateway-system diff --git a/infrastructure/storage/kustomization.yaml b/infrastructure/storage/kustomization.yaml new file mode 100644 index 0000000..e317fb0 --- /dev/null +++ b/infrastructure/storage/kustomization.yaml @@ -0,0 +1,4 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - local-path-storage.yaml diff --git a/infrastructure/storage/local-path-storage.yaml b/infrastructure/storage/local-path-storage.yaml new file mode 100644 index 0000000..c09371a --- /dev/null +++ b/infrastructure/storage/local-path-storage.yaml @@ -0,0 +1,163 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: local-path-storage +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: local-path-provisioner-service-account + namespace: local-path-storage +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: local-path-provisioner-role + namespace: local-path-storage +rules: + - apiGroups: [""] + resources: ["pods"] + verbs: ["get", "list", "watch", "create", "patch", "update", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: local-path-provisioner-role +rules: + - apiGroups: [""] + resources: ["nodes", "persistentvolumeclaims", "configmaps", "pods", "pods/log"] + verbs: ["get", "list", "watch"] + - apiGroups: [""] + resources: ["persistentvolumes"] + verbs: ["get", "list", "watch", "create", "patch", "update", "delete"] + - apiGroups: [""] + resources: ["events"] + verbs: ["create", "patch"] + - apiGroups: ["storage.k8s.io"] + resources: ["storageclasses"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: local-path-provisioner-bind + namespace: local-path-storage +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: local-path-provisioner-role +subjects: + - kind: ServiceAccount + name: local-path-provisioner-service-account + namespace: local-path-storage +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: local-path-provisioner-bind +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: local-path-provisioner-role +subjects: + - kind: ServiceAccount + name: local-path-provisioner-service-account + namespace: local-path-storage +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: local-path-provisioner + namespace: local-path-storage +spec: + replicas: 1 + selector: + matchLabels: + app: local-path-provisioner + template: + metadata: + labels: + app: local-path-provisioner + spec: + serviceAccountName: local-path-provisioner-service-account + nodeSelector: + kubernetes.io/hostname: siriussec + containers: + - name: local-path-provisioner + image: rancher/local-path-provisioner:v0.0.31 + imagePullPolicy: IfNotPresent + command: + - local-path-provisioner + - --debug + - start + - --config + - /etc/config/config.json + volumeMounts: + - name: config-volume + mountPath: /etc/config/ + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: CONFIG_MOUNT_PATH + value: /etc/config/ + volumes: + - name: config-volume + configMap: + name: local-path-config +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-path + annotations: + storageclass.kubernetes.io/is-default-class: "true" +provisioner: rancher.io/local-path +volumeBindingMode: WaitForFirstConsumer +reclaimPolicy: Delete +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: local-path-config + namespace: local-path-storage +data: + config.json: |- + { + "nodePathMap":[ + { + "node":"DEFAULT_PATH_FOR_NON_LISTED_NODES", + "paths":["/opt/local-path-provisioner"] + }, + { + "node":"siriussec", + "paths":["/opt/local-path-provisioner"] + } + ] + } + setup: |- + #!/bin/sh + set -eu + mkdir -m 0777 -p "$VOL_DIR" + teardown: |- + #!/bin/sh + set -eu + rm -rf "$VOL_DIR" + helperPod.yaml: |- + apiVersion: v1 + kind: Pod + metadata: + name: helper-pod + spec: + priorityClassName: system-node-critical + nodeSelector: + kubernetes.io/hostname: siriussec + tolerations: + - key: node.kubernetes.io/disk-pressure + operator: Exists + effect: NoSchedule + containers: + - name: helper-pod + image: busybox + imagePullPolicy: IfNotPresent diff --git a/monitoring/controllers/home/kustomization.yaml b/monitoring/controllers/home/kustomization.yaml new file mode 100644 index 0000000..b83b23e --- /dev/null +++ b/monitoring/controllers/home/kustomization.yaml @@ -0,0 +1,3 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: []