Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: load home assisntant kustomizations #3395

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Conversation

blackjid
Copy link
Owner

No description provided.

@blackjid blackjid force-pushed the add_home_assistant_2 branch from dc6cec7 to 145a612 Compare June 19, 2024 18:59
Copy link

--- kubernetes/apps Kustomization: flux-system/cluster-apps Kustomization: flux-system/home-assistant

+++ kubernetes/apps Kustomization: flux-system/cluster-apps Kustomization: flux-system/home-assistant

@@ -0,0 +1,45 @@

+---
+apiVersion: kustomize.toolkit.fluxcd.io/v1
+kind: Kustomization
+metadata:
+  labels:
+    kustomize.toolkit.fluxcd.io/name: cluster-apps
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant
+  namespace: flux-system
+spec:
+  commonMetadata:
+    labels:
+      app.kubernetes.io/name: home-assistant
+  decryption:
+    provider: sops
+    secretRef:
+      name: sops-age
+  dependsOn:
+  - name: external-secrets-stores
+  interval: 30m
+  path: ./kubernetes/apps/home/home-assistant/app
+  postBuild:
+    substitute:
+      APP: home-assistant
+      VOLSYNC_CAPACITY: 5Gi
+    substituteFrom:
+    - kind: ConfigMap
+      name: cluster-settings
+    - kind: Secret
+      name: cluster-secrets
+    - kind: ConfigMap
+      name: cluster-user-settings
+      optional: true
+    - kind: Secret
+      name: cluster-user-secrets
+      optional: true
+  prune: true
+  retryInterval: 1m
+  sourceRef:
+    kind: GitRepository
+    name: home-kubernetes
+  targetNamespace: home
+  timeout: 5m
+  wait: false
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ExternalSecret: home/home-assistant

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ExternalSecret: home/home-assistant

@@ -0,0 +1,36 @@

+---
+apiVersion: external-secrets.io/v1beta1
+kind: ExternalSecret
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant
+  namespace: home
+spec:
+  dataFrom:
+  - extract:
+      key: hass-postgres
+      property: hass_password
+  - extract:
+      key: hass-postgres
+      property: hass_username
+  - extract:
+      key: home-assistant
+  secretStoreRef:
+    kind: ClusterSecretStore
+    name: onepassword-connect
+  target:
+    name: home-assistant-secret
+    template:
+      data:
+        SECRET_EXTERNAL_URL: '{{ .secret_external_url }}'
+        SECRET_INTERNAL_URL: '{{ .secret_internal_url }}'
+        SECRET_RECORDER_DB_URL: postgresql://{{ .hass_username }}:{{ .hass_password
+          }}@hass-postgresql/hass
+        SECRET_ZONE_HOME_ELEVATION: '{{ .secret_zone_home_elevation }}'
+        SECRET_ZONE_HOME_LATITUDE: '{{ .secret_zone_home_latitude }}'
+        SECRET_ZONE_HOME_LONGITUDE: '{{ .secret_zone_home_longitude }}'
+      engineVersion: v2
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant HelmRelease: home/home-assistant

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant HelmRelease: home/home-assistant

@@ -0,0 +1,92 @@

+---
+apiVersion: helm.toolkit.fluxcd.io/v2
+kind: HelmRelease
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant
+  namespace: home
+spec:
+  chart:
+    spec:
+      chart: app-template
+      sourceRef:
+        kind: HelmRepository
+        name: bjw-s
+        namespace: flux-system
+      version: 3.2.1
+  dependsOn:
+  - name: rook-ceph-cluster
+    namespace: rook-ceph
+  - name: volsync
+    namespace: volsync-system
+  install:
+    remediation:
+      retries: 3
+  interval: 30m
+  upgrade:
+    cleanupOnFail: true
+    remediation:
+      retries: 3
+      strategy: rollback
+  values:
+    controllers:
+      home-assistant:
+        annotations:
+          reloader.stakater.com/auto: 'true'
+        containers:
+          app:
+            env:
+              TZ: America/Santiago
+            envFrom:
+            - secretRef:
+                name: home-assistant-secret
+            image:
+              repository: ghcr.io/onedr0p/home-assistant
+              tag: 2024.1.6@sha256:3ae078c549ba6a0d2c6f2921aab53e492cd688956da6a51867e999f87ed59d13
+            resources:
+              limits:
+                memory: 1Gi
+              requests:
+                cpu: 10m
+            securityContext:
+              allowPrivilegeEscalation: false
+              capabilities:
+                drop:
+                - ALL
+              readOnlyRootFilesystem: true
+    defaultPodOptions:
+      securityContext:
+        fsGroup: 568
+        fsGroupChangePolicy: OnRootMismatch
+        runAsGroup: 568
+        runAsNonRoot: true
+        runAsUser: 568
+        seccompProfile:
+          type: RuntimeDefault
+    ingress:
+      app:
+        annotations:
+          external-dns.alpha.kubernetes.io/target: external.donoso.family
+        className: external
+        hosts:
+        - host: hass.donoso.family
+          paths:
+          - path: /
+            service:
+              identifier: app
+              port: http
+    persistence:
+      config:
+        existingClaim: home-assistant
+      tmp:
+        type: emptyDir
+    service:
+      app:
+        controller: home-assistant
+        ports:
+          http:
+            port: 8123
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant PersistentVolumeClaim: home/home-assistant

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant PersistentVolumeClaim: home/home-assistant

@@ -0,0 +1,22 @@

+---
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant
+  namespace: home
+spec:
+  accessModes:
+  - ReadWriteOnce
+  dataSourceRef:
+    apiGroup: volsync.backube
+    kind: ReplicationDestination
+    name: home-assistant-bootstrap
+  resources:
+    requests:
+      storage: 5Gi
+  storageClassName: longhorn
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ExternalSecret: home/home-assistant-volsync

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ExternalSecret: home/home-assistant-volsync

@@ -0,0 +1,30 @@

+---
+apiVersion: external-secrets.io/v1beta1
+kind: ExternalSecret
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant-volsync
+  namespace: home
+spec:
+  dataFrom:
+  - extract:
+      key: volsync-bucket
+  - extract:
+      key: volsync-minio-template
+      property: RESTIC_REPOSITORY
+  secretStoreRef:
+    kind: ClusterSecretStore
+    name: bitwarden-secrets-manager
+  target:
+    name: home-assistant-volsync
+    template:
+      data:
+        AWS_ACCESS_KEY_ID: '{{ .AWS_ACCESS_KEY_ID }}'
+        AWS_SECRET_ACCESS_KEY: '{{ .AWS_SECRET_ACCESS_KEY }}'
+        RESTIC_PASSWORD: '{{ .RESTIC_PASSWORD }}'
+        RESTIC_REPOSITORY: '{{ .REPOSITORY_TEMPLATE }}/home-assistant'
+      engineVersion: v2
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ReplicationDestination: home/home-assistant-bootstrap

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ReplicationDestination: home/home-assistant-bootstrap

@@ -0,0 +1,30 @@

+---
+apiVersion: volsync.backube/v1alpha1
+kind: ReplicationDestination
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant-bootstrap
+  namespace: home
+spec:
+  restic:
+    accessModes:
+    - ReadWriteOnce
+    cacheAccessModes:
+    - ReadWriteOnce
+    cacheCapacity: 8Gi
+    cacheStorageClassName: longhorn-cache
+    capacity: 5Gi
+    copyMethod: Snapshot
+    moverSecurityContext:
+      fsGroup: 568
+      runAsGroup: 568
+      runAsUser: 568
+    repository: home-assistant-volsync
+    storageClassName: longhorn-snapshot
+    volumeSnapshotClassName: longhorn-snapclass
+  trigger:
+    manual: restore-once
+
--- kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ReplicationSource: home/home-assistant

+++ kubernetes/apps/home/home-assistant/app Kustomization: flux-system/home-assistant ReplicationSource: home/home-assistant

@@ -0,0 +1,35 @@

+---
+apiVersion: volsync.backube/v1alpha1
+kind: ReplicationSource
+metadata:
+  labels:
+    app.kubernetes.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/name: home-assistant
+    kustomize.toolkit.fluxcd.io/namespace: flux-system
+  name: home-assistant
+  namespace: home
+spec:
+  restic:
+    accessModes:
+    - ReadWriteOnce
+    cacheAccessModes:
+    - ReadWriteOnce
+    cacheCapacity: 8Gi
+    cacheStorageClassName: longhorn-cache
+    copyMethod: Snapshot
+    moverSecurityContext:
+      fsGroup: 568
+      runAsGroup: 568
+      runAsUser: 568
+    pruneIntervalDays: 10
+    repository: home-assistant-volsync
+    retain:
+      daily: 10
+      hourly: 24
+      weekly: 5
+    storageClassName: longhorn-snapshot
+    volumeSnapshotClassName: longhorn-snapclass
+  sourcePVC: home-assistant
+  trigger:
+    schedule: 0 * * * *
+

Copy link

--- HelmRelease: home/home-assistant Service: home/home-assistant

+++ HelmRelease: home/home-assistant Service: home/home-assistant

@@ -0,0 +1,22 @@

+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: home-assistant
+  labels:
+    app.kubernetes.io/instance: home-assistant
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: home-assistant
+    app.kubernetes.io/service: home-assistant
+spec:
+  type: ClusterIP
+  ports:
+  - port: 8123
+    targetPort: 8123
+    protocol: TCP
+    name: http
+  selector:
+    app.kubernetes.io/component: home-assistant
+    app.kubernetes.io/instance: home-assistant
+    app.kubernetes.io/name: home-assistant
+
--- HelmRelease: home/home-assistant Deployment: home/home-assistant

+++ HelmRelease: home/home-assistant Deployment: home/home-assistant

@@ -0,0 +1,76 @@

+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: home-assistant
+  labels:
+    app.kubernetes.io/component: home-assistant
+    app.kubernetes.io/instance: home-assistant
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: home-assistant
+  annotations:
+    reloader.stakater.com/auto: 'true'
+spec:
+  revisionHistoryLimit: 3
+  replicas: 1
+  strategy:
+    type: Recreate
+  selector:
+    matchLabels:
+      app.kubernetes.io/component: home-assistant
+      app.kubernetes.io/name: home-assistant
+      app.kubernetes.io/instance: home-assistant
+  template:
+    metadata:
+      labels:
+        app.kubernetes.io/component: home-assistant
+        app.kubernetes.io/instance: home-assistant
+        app.kubernetes.io/name: home-assistant
+    spec:
+      enableServiceLinks: false
+      serviceAccountName: default
+      automountServiceAccountToken: true
+      securityContext:
+        fsGroup: 568
+        fsGroupChangePolicy: OnRootMismatch
+        runAsGroup: 568
+        runAsNonRoot: true
+        runAsUser: 568
+        seccompProfile:
+          type: RuntimeDefault
+      hostIPC: false
+      hostNetwork: false
+      hostPID: false
+      dnsPolicy: ClusterFirst
+      containers:
+      - env:
+        - name: TZ
+          value: America/Santiago
+        envFrom:
+        - secretRef:
+            name: home-assistant-secret
+        image: ghcr.io/onedr0p/home-assistant:2024.1.6@sha256:3ae078c549ba6a0d2c6f2921aab53e492cd688956da6a51867e999f87ed59d13
+        name: app
+        resources:
+          limits:
+            memory: 1Gi
+          requests:
+            cpu: 10m
+        securityContext:
+          allowPrivilegeEscalation: false
+          capabilities:
+            drop:
+            - ALL
+          readOnlyRootFilesystem: true
+        volumeMounts:
+        - mountPath: /config
+          name: config
+        - mountPath: /tmp
+          name: tmp
+      volumes:
+      - name: config
+        persistentVolumeClaim:
+          claimName: home-assistant
+      - emptyDir: {}
+        name: tmp
+
--- HelmRelease: home/home-assistant Ingress: home/home-assistant

+++ HelmRelease: home/home-assistant Ingress: home/home-assistant

@@ -0,0 +1,25 @@

+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: home-assistant
+  labels:
+    app.kubernetes.io/instance: home-assistant
+    app.kubernetes.io/managed-by: Helm
+    app.kubernetes.io/name: home-assistant
+  annotations:
+    external-dns.alpha.kubernetes.io/target: external.donoso.family
+spec:
+  ingressClassName: external
+  rules:
+  - host: hass.donoso.family
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: home-assistant
+            port:
+              number: 8123
+

@blackjid blackjid merged commit d53b276 into main Jun 19, 2024
4 of 5 checks passed
@blackjid blackjid deleted the add_home_assistant_2 branch June 19, 2024 19:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant