diff --git a/apps/homeassistant/deployment.yaml b/apps/homeassistant/base/deployment.yaml similarity index 99% rename from apps/homeassistant/deployment.yaml rename to apps/homeassistant/base/deployment.yaml index acaff0d..1537a08 100644 --- a/apps/homeassistant/deployment.yaml +++ b/apps/homeassistant/base/deployment.yaml @@ -34,4 +34,3 @@ spec: - name: config-dir persistentVolumeClaim: claimName: config - diff --git a/apps/homeassistant/ingress.yaml b/apps/homeassistant/base/ingress.yaml similarity index 66% rename from apps/homeassistant/ingress.yaml rename to apps/homeassistant/base/ingress.yaml index 7cb14ff..fbbdfc3 100644 --- a/apps/homeassistant/ingress.yaml +++ b/apps/homeassistant/base/ingress.yaml @@ -1,17 +1,17 @@ apiVersion: traefik.io/v1alpha1 kind: IngressRoute metadata: - name: homeassistant-ingress + name: homeassistant spec: entryPoints: - websecure routes: - - match: Host(`home.kluster.moll.re`) && !Path(`/api/prometheus`) + - match: Host(`homeassistant.kluster.moll.re`) middlewares: - - name: homeassistant-websocket + - name: homeassistant kind: Rule services: - - name: homeassistant-web + - name: homeassistant port: 8123 tls: certResolver: default-tls @@ -19,7 +19,7 @@ spec: apiVersion: traefik.io/v1alpha1 kind: Middleware metadata: - name: homeassistant-websocket + name: homeassistant spec: headers: customRequestHeaders: diff --git a/apps/homeassistant/base/kustomization.yaml b/apps/homeassistant/base/kustomization.yaml new file mode 100644 index 0000000..c677179 --- /dev/null +++ b/apps/homeassistant/base/kustomization.yaml @@ -0,0 +1,20 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + # - namespace.yaml # not managed by kustomize but created as needed by the argo app. creates conflicts otherwise since both overlays share the same namespace + - ingress.yaml + - pvc.yaml + - service.yaml + - deployment.yaml + - servicemonitor.yaml + + +images: + - name: homeassistant + newName: homeassistant/home-assistant + newTag: "2025.10" + +configurations: + # allow nameReference to work with different mentions of the same resource as well + - name_reference.yaml diff --git a/apps/homeassistant/base/name_reference.yaml b/apps/homeassistant/base/name_reference.yaml new file mode 100644 index 0000000..c17bd6d --- /dev/null +++ b/apps/homeassistant/base/name_reference.yaml @@ -0,0 +1,32 @@ +nameReference: + # Tie target Service metadata.name to other ingressroute fields + - kind: Service + fieldSpecs: + # rewrite the backend service name + - kind: IngressRoute + group: traefik.io + version: v1alpha1 + path: spec/routes/services/name + + # adapt the ingress url + # DOES NOT WORK + - kind: IngressRoute + group: traefik.io + version: v1alpha1 + path: /spec/routes/match + create: false + + # adapt any middleware names + - kind: IngressRoute + group: traefik.io + version: v1alpha1 + path: spec/routes/middlewares/name + + # Update deployment volume mounts according to name changes in the sealedsecret + - kind: SealedSecret + fieldSpecs: + # volume mounts: + - kind: Deployment + group: apps + version: v1 + path: spec/template/spec/volumes/secret/secretName diff --git a/apps/homeassistant/namespace.yaml b/apps/homeassistant/base/namespace.yaml similarity index 100% rename from apps/homeassistant/namespace.yaml rename to apps/homeassistant/base/namespace.yaml diff --git a/apps/homeassistant/pvc.yaml b/apps/homeassistant/base/pvc.yaml similarity index 100% rename from apps/homeassistant/pvc.yaml rename to apps/homeassistant/base/pvc.yaml diff --git a/apps/homeassistant/service.yaml b/apps/homeassistant/base/service.yaml similarity index 79% rename from apps/homeassistant/service.yaml rename to apps/homeassistant/base/service.yaml index 5916e74..f93dcea 100644 --- a/apps/homeassistant/service.yaml +++ b/apps/homeassistant/base/service.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: Service metadata: - name: homeassistant-web + name: homeassistant labels: app: homeassistant spec: @@ -10,4 +10,4 @@ spec: ports: - port: 8123 targetPort: 8123 - name: http \ No newline at end of file + name: http diff --git a/apps/homeassistant/servicemonitor.yaml b/apps/homeassistant/base/servicemonitor.yaml similarity index 100% rename from apps/homeassistant/servicemonitor.yaml rename to apps/homeassistant/base/servicemonitor.yaml diff --git a/apps/homeassistant/kustomization.yaml b/apps/homeassistant/kustomization.yaml deleted file mode 100644 index b329b67..0000000 --- a/apps/homeassistant/kustomization.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -namespace: homeassistant - -resources: - - namespace.yaml - - ingress.yaml - - pvc.yaml - - service.yaml - - deployment.yaml - - servicemonitor.yaml - - -images: - - name: homeassistant - newName: homeassistant/home-assistant - newTag: "2025.10" diff --git a/apps/homeassistant/overlays/flat/ingress.patch.yaml b/apps/homeassistant/overlays/flat/ingress.patch.yaml new file mode 100644 index 0000000..92a8c7e --- /dev/null +++ b/apps/homeassistant/overlays/flat/ingress.patch.yaml @@ -0,0 +1,3 @@ +- op: replace + path: /spec/routes/0/match + value: Host(`home.kluster.moll.re`) diff --git a/apps/homeassistant/overlays/flat/kustomization.yaml b/apps/homeassistant/overlays/flat/kustomization.yaml new file mode 100644 index 0000000..1ffaeb6 --- /dev/null +++ b/apps/homeassistant/overlays/flat/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../base + +namespace: homeassistant +nameSuffix: -flat +labels: + - includeSelectors: true + pairs: + env: flat + +patches: + - path: ingress.patch.yaml + target: + kind: IngressRoute diff --git a/apps/homeassistant/overlays/house/ingress.patch.yaml b/apps/homeassistant/overlays/house/ingress.patch.yaml new file mode 100644 index 0000000..ce101e7 --- /dev/null +++ b/apps/homeassistant/overlays/house/ingress.patch.yaml @@ -0,0 +1,3 @@ +- op: replace + path: /spec/routes/0/match + value: Host(`home-house.kluster.moll.re`) diff --git a/apps/homeassistant/overlays/house/kustomization.yaml b/apps/homeassistant/overlays/house/kustomization.yaml new file mode 100644 index 0000000..aafb583 --- /dev/null +++ b/apps/homeassistant/overlays/house/kustomization.yaml @@ -0,0 +1,28 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../../base + - wireguard-config.sealedsecret.yaml + + +namespace: homeassistant +nameSuffix: -house +labels: + - includeSelectors: true + pairs: + env: house + +images: + - name: wireguard + newName: ghcr.io/linuxserver/wireguard + newTag: "1.0.20250521" + +patches: + - path: wireguard.deployment.yaml + target: + kind: Deployment + name: homeassistant + - path: ingress.patch.yaml + target: + kind: IngressRoute diff --git a/apps/homeassistant/overlays/house/wireguard-config.sealedsecret.yaml b/apps/homeassistant/overlays/house/wireguard-config.sealedsecret.yaml new file mode 100644 index 0000000..d681677 --- /dev/null +++ b/apps/homeassistant/overlays/house/wireguard-config.sealedsecret.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: bitnami.com/v1alpha1 +kind: SealedSecret +metadata: + creationTimestamp: null + # WARNING - the originial secret was named wireguard-config-house, but we remove the suffix here, anticipating that it will be created by the kustomization overlay + name: wireguard-config + namespace: homeassistant +spec: + encryptedData: + wireguard.conf: AgAz726k7X6IsabWUPX8kQ8r19mBq/N+YytlFS1gW2LUiYqc6H/O5/tqma5lLcazuxtsQhebeoitp2SkH7jTU8vRxn2tDWpyzcJr+BW4vKnghw5NhMbkNOzl7mvc7QIJk6rmRyD1umu33v6x8u3St9TVsUOI1zXJyXHxlbLdHVCORhgV79CGLjghpi23KyyFu6LzNrE5rhpB0Q7NzPUmbm5MHPNbtLsmImd/CZ9XjbyXSq0be8BgpUtGDE/NMx65G2+lLIw3EgbNwlirw/XKrM+pUIvEI6CxuNhbEM7KxCYlq2Du6bm7XsKHRzNu9oSfH+P4DaDoDt+M5k5miv4B8TIKXg7piy5mThXSTcVf5YpLJCiTfMDZOriG1ygr9gbJPYY1jumZA+vsZCvBx1o21BlNycWZWKBeYZZh47Hz9FGI/Smn8dOs5exZ34MrQtM4OuEqC/cJY8fdQ+nmGMezL0IKdbtpWgq5UqNH/wWv3F9kItB4KlSD4YtEGaY2z68BJG6t+9igSJCWmVca0EbOzhV0s5rI39ASVXOO50x774EEWUueoyfI+l5vwtQhc96I5Qn3kbFhwov0tHMg/IGBtS/7XdBBtOBx9KbcUHq1GlwWzQdw8WnRB6yyUVCqXyuExRhMPz5orqkTQwiUM2Fjse7xxnaEA0mbi0TVPKV/sFgWixvHqy3VAc1Jj6MEAWFAu+kPVlOFFCckEC5kPhNPFhBMeYX/3IblRjly/EHvrbrW/eFjNYE7bqpSCVhkB8bOXbJqt29V3+ffM1z/RkdSusgqdwid9CXhQw6SKAI/vcAqqxXdzcsbG1wsgP9bJ1Gk/i9ch8zUn7MwcFe6Tla86+xeiDIAmQmA7rhtmWhyyuxXdw+HXAFNhrbxHaUw3LZOExM+RzhWNepjSLnCBqnrtPkzFrHE02JKebWzX+IRZIOsEXJVhKTiSSjoB2v8h956kO+C7bdHz8GbxoJKJ7anrqFG13A//XLy5PvKr50qs/gQptrl9UtR7oj981bSDTVVa8h3OXbGLkZXly/qxsh5DlEjwnw2/2UqS+5yTT4FO/dNVtHryJ2tbc8ZuIHb6C/pQygqpseagthkm5T+Dv0T2xWpXFrvuktGNm58Cwg9bwNMcC6iofcjQP5JeNcat3RwzbJ9xwU4Nm8xLRMMc0ul6xUHRrL3ZjDfWHLuSuTp28HqXZ6xSKLlrRVjwZ6Mp/hhxj58SfVfLVIQxatGkwnIaHEFWE2n3S7m/iQO9tZIWCx5Yfs15atb1Ze8HjKjQ4o3sfaMD8Eokj9aFnXQQxpnOuSI3NLETe79QQ== + template: + metadata: + creationTimestamp: null + name: wireguard-config-house + namespace: homeassistant + type: Opaque diff --git a/apps/homeassistant/overlays/house/wireguard.deployment.yaml b/apps/homeassistant/overlays/house/wireguard.deployment.yaml new file mode 100644 index 0000000..3a23987 --- /dev/null +++ b/apps/homeassistant/overlays/house/wireguard.deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: homeassistant +spec: + template: + spec: + containers: + - name: wireguard-sidecar + image: wireguard + securityContext: + privileged: true + + + volumeMounts: + - name: wireguard-config + mountPath: /config/wg_confs/ + + volumes: + - name: wireguard-config + secret: + secretName: wireguard-config + + diff --git a/kluster-deployments/homeassistant/application.yaml b/kluster-deployments/homeassistant/application.yaml index ed70b4e..0dbdbb9 100644 --- a/kluster-deployments/homeassistant/application.yaml +++ b/kluster-deployments/homeassistant/application.yaml @@ -1,18 +1,20 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: - name: homeassistant-application + name: homeassistant-flat-application namespace: argocd spec: project: apps source: repoURL: ssh://git@git.kluster.moll.re:2222/remoll/k3s-infra.git targetRevision: main - path: apps/homeassistant + path: apps/homeassistant/overlays/flat destination: server: https://kubernetes.default.svc namespace: homeassistant syncPolicy: + syncOptions: + - CreateNamespace=true automated: prune: true - selfHeal: true \ No newline at end of file + selfHeal: true diff --git a/kluster-deployments/homeassistant/house.application.yaml b/kluster-deployments/homeassistant/house.application.yaml new file mode 100644 index 0000000..79e7aeb --- /dev/null +++ b/kluster-deployments/homeassistant/house.application.yaml @@ -0,0 +1,23 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: homeassistant-house-application + namespace: argocd +spec: + project: apps + source: + repoURL: ssh://git@git.kluster.moll.re:2222/remoll/k3s-infra.git + targetRevision: main + path: apps/homeassistant/overlays/house + destination: + server: https://kubernetes.default.svc + namespace: homeassistant + syncPolicy: + managedNamespaceMetadata: + labels: + pod-security.kubernetes.io/enforce: privileged + syncOptions: + - CreateNamespace=true + automated: + prune: true + selfHeal: true diff --git a/kluster-deployments/homeassistant/kustomization.yaml b/kluster-deployments/homeassistant/kustomization.yaml index 0b082ba..79ad226 100644 --- a/kluster-deployments/homeassistant/kustomization.yaml +++ b/kluster-deployments/homeassistant/kustomization.yaml @@ -1,4 +1,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: -- application.yaml \ No newline at end of file +- application.yaml +- house.application.yaml