From 564cab6453b0c219fd174e59abf07fe9044eaaa3 Mon Sep 17 00:00:00 2001 From: LarryGF Date: Tue, 15 Aug 2023 19:51:50 +0200 Subject: [PATCH] Trying to add home assistant --- argocd/home-assistant/Chart.yaml | 7 ++ .../home-assistant/files/configuration.yaml | 19 +++ .../home-assistant/templates/configmap.yaml | 7 ++ .../templates/install-plugins.yaml | 25 ++++ argocd/home-assistant/values.common.yaml | 108 ++++++++++++++++++ terraform/applications.yaml | 18 +++ .../applications/home-assistant/values.yaml | 35 ++++++ 7 files changed, 219 insertions(+) create mode 100644 argocd/home-assistant/Chart.yaml create mode 100644 argocd/home-assistant/files/configuration.yaml create mode 100644 argocd/home-assistant/templates/configmap.yaml create mode 100644 argocd/home-assistant/templates/install-plugins.yaml create mode 100644 argocd/home-assistant/values.common.yaml create mode 100644 terraform/modules/argocd_application/applications/home-assistant/values.yaml diff --git a/argocd/home-assistant/Chart.yaml b/argocd/home-assistant/Chart.yaml new file mode 100644 index 00000000..441e95aa --- /dev/null +++ b/argocd/home-assistant/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: home-assistant-umbrella +version: 0.0.1 +dependencies: + - name: home-assistant + repository: https://geek-cookbook.github.io/charts + version: 13.5.0 \ No newline at end of file diff --git a/argocd/home-assistant/files/configuration.yaml b/argocd/home-assistant/files/configuration.yaml new file mode 100644 index 00000000..0b60bf70 --- /dev/null +++ b/argocd/home-assistant/files/configuration.yaml @@ -0,0 +1,19 @@ + +# Loads default set of integrations. Do not remove. +default_config: + +# Load frontend themes from the themes folder +frontend: + themes: !include_dir_merge_named themes + +# Text to speech +tts: + - platform: google_translate + +# automation: !include automations.yaml +# script: !include scripts.yaml +# scene: !include scenes.yaml + +http: + use_x_forwarded_for: true + trusted_proxies: 0.0.0.0/0 \ No newline at end of file diff --git a/argocd/home-assistant/templates/configmap.yaml b/argocd/home-assistant/templates/configmap.yaml new file mode 100644 index 00000000..62981e37 --- /dev/null +++ b/argocd/home-assistant/templates/configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .Release.Name }}-configmap +data: + datafile.yaml: | +{{ .Files.Get "files/configuration.yaml" | indent 4 }} diff --git a/argocd/home-assistant/templates/install-plugins.yaml b/argocd/home-assistant/templates/install-plugins.yaml new file mode 100644 index 00000000..ae26e5fa --- /dev/null +++ b/argocd/home-assistant/templates/install-plugins.yaml @@ -0,0 +1,25 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: install-ha-plugins +spec: + template: + metadata: + name: install-ha-plugins + spec: + volumes: + - name: ha-config + persistentVolumeClaim: + claimName: ha-config + containers: + - name: install-ha-plugins + image: bash + command: + - bash + - "-c" + - "cd /config && wget -O - https://get.hacs.xyz | bash -" + volumeMounts: + - name: ha-config + mountPath: "/config" + restartPolicy: Never + backoffLimit: 1 diff --git a/argocd/home-assistant/values.common.yaml b/argocd/home-assistant/values.common.yaml new file mode 100644 index 00000000..25ad6ce4 --- /dev/null +++ b/argocd/home-assistant/values.common.yaml @@ -0,0 +1,108 @@ +home-assistant: + # home-assistant.yaml + image: + repository: lscr.io/linuxserver/homeassistant + tag: 2023.4.4 + + initContainers: + copy-configmap: + image: busybox + command: + - "sh" + - "-c" + - | + cp /ha-config/configuration.yaml /config/configuration.yaml + volumeMounts: + - name: config + mountPath: /config + - name: config-custom + mountPath: /ha-config + + securityContext: + runAsUser: 0 + + # install-hasc: + # image: bash + # command: + # - "bash" + # - "-c" + # - | + # cd /config && ls && wget -O - https://get.hacs.xyz | bash - + # volumeMounts: + # - name: config + # mountPath: /config + + # securityContext: + # runAsUser: 0 + + ingress: + main: + ingressClassName: traefik + annotations: + cert-manager.io/cluster-issuer: letsencrypt + traefik.ingress.kubernetes.io/router.entrypoints: websecure + enabled: true + hosts: + - host: "ha.${duckdns_domain}.duckdns.org" + paths: + - path: / + tls: + - hosts: + - "ha.${duckdns_domain}.duckdns.org" + secretName: tls-ha-ingress + + hostNetwork: true + dnsPolicy: ClusterFirstWithHostNet + + persistence: + config: + enabled: true + existingClaim: ha-config + config-custom: + enabled: true + type: configMap + name: config-file + # usb: + # enabled: true + # type: hostPath + # hostPath: /dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2434151-if00 + # mountPath: /dev/ttyUSB0 + + nodeSelector: + # kubernetes.io/hostname: ${master_hostname} + kubernetes.io/arch : amd64 + + + securityContext: + privileged: true + + addons: + codeserver: + image: + repository: codercom/code-server + tag: 4.11.0 + enabled: true + ingress: + enabled: true + annotations: + cert-manager.io/issuer: letsencrypt + hosts: + - host: code.ha.${duckdns_domain}.duckdns.org + paths: + - path: / + tls: + - secretName: tls-code-ha-ingress + hosts: + - code.ha.${duckdns_domain}.duckdns.org + + args: + - --auth + - none + - --user-data-dir + - "/config/.vscode" + + workingDir: "/config" + + volumeMounts: + - name: config + mountPath: /config diff --git a/terraform/applications.yaml b/terraform/applications.yaml index c8c0a223..f52b80fa 100644 --- a/terraform/applications.yaml +++ b/terraform/applications.yaml @@ -216,6 +216,24 @@ renovate: gh_username: ${gh_username} gh_token: ${gh_token} + +home-assistant: + name: home-assistant + namespace: services + deploy: true + volumes: + config: + enabled: true + name: ha-config + size: 5Gi + access_modes: + - ReadWriteOnce + override: + timezone: ${timezone} + duckdns_domain: ${duckdns_domain} + gh_username: ${gh_username} + gh_token: ${gh_token} + sonarr: name: sonarr namespace: services diff --git a/terraform/modules/argocd_application/applications/home-assistant/values.yaml b/terraform/modules/argocd_application/applications/home-assistant/values.yaml new file mode 100644 index 00000000..ce8b5030 --- /dev/null +++ b/terraform/modules/argocd_application/applications/home-assistant/values.yaml @@ -0,0 +1,35 @@ +grafana: + datasources: + datasources.yaml: + apiVersion: 1 + datasources: + - name: Prometheus + type: prometheus + url: http://prometheus-prometheus:9090 + access: proxy + isDefault: true + - name: Alertmanager + type: alertmanager + url: http://prometheus-alertmanager:9093 + access: proxy + jsonData: + implementation: prometheus + handleGrafanaManagedAlerts: false + - name: Loki + type: loki + access: proxy + url: http://loki-gateway + jsonData: + maxLines: 1000 + + grafana.ini: + auth.anonymous: + enabled: true + org_name: Main Org. + org_role: Admin + panels: + disable_sanitize_html: true + + persistence: + enabled: true + existingClaim: grafana-config \ No newline at end of file