Skip to content

Commit

Permalink
Merge pull request #16 from JacekZubielik/home-assistant
Browse files Browse the repository at this point in the history
chore(init): init
  • Loading branch information
JacekZubielik authored May 22, 2024
2 parents 7aa7a5d + 3567cb8 commit dd6af95
Show file tree
Hide file tree
Showing 10 changed files with 573 additions and 0 deletions.
16 changes: 16 additions & 0 deletions charts/home-assistant/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: v2
appVersion: 2024.4.0
description: Home Assistant automation
name: home-assistant
version: 0.0.1
keywords:
- home-assistant
- automation
type: application
home: https://github.com/JacekZubielik/jz-helm-charts/tree/master/charts/home-assistant
icon: https://raw.githubusercontent.com/home-assistant/assets/master/misc/logo-icon_template.png
sources:
- https://github.com/home-assistant/home-assistant
maintainers:
- name: jacekzubielik
2 changes: 2 additions & 0 deletions charts/home-assistant/ci/ci-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
provider:
name: inmemory
50 changes: 50 additions & 0 deletions charts/home-assistant/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{/* Expand the name of the chart. */}}
{{- define "app.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/* Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name. */}}
{{- define "app.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/* Create chart name and version as used by the chart label. */}}
{{- define "app.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/* Common labels */}}
{{- define "app.labels" -}}
helm.sh/chart: {{ include "app.chart" . }}
{{ include "app.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/* Selector labels */}}
{{- define "app.selectorLabels" -}}
app.kubernetes.io/name: {{ include "app.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/* Create the name of the service account to use */}}
{{- define "app.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "app.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
40 changes: 40 additions & 0 deletions charts/home-assistant/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if and .Values.ingress .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
# helm.sh/chart: {{ include "app.chart" . }}
# app.kubernetes.io/instance: {{ .Release.Name }}
# app.kubernetes.io/managed-by: {{ .Release.Service }}
# app.kubernetes.io/name: {{ include "app.name" . }}
{{- with .Values.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
ingressClassName: {{ $.Values.ingress.ingressClassName }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . }}
http:
paths:
- path: {{ .Values.ingress.path }}
pathType: Prefix
backend:
serviceName: {{ include "app.fullname" . }}
servicePort: {{ .Values.service.port }}
{{- end }}

{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/home-assistant/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if and .Values.persistence.pvc.enabled (not .Values.persistence.configstorage.hostPath) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.pvc.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.pvc.size }}
{{- if .Values.persistence.pvc.storageClass }}
{{- if (eq "-" .Values.persistence.pvc.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: "{{ .Values.persistence.pvc.storageClass }}"
{{- end }}
{{- end }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/home-assistant/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: v1
kind: Service
metadata:
{{- if .Values.service.annotations }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
{{- if .Values.service.labels }}
{{ toYaml .Values.service.labels | indent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{- toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- toYaml .Values.service.loadBalancerSourceRanges | nindent 4 }}
{{- end }}
publishNotReadyAddresses: {{ .Values.service.publishNotReadyAddresses }}
ports:
- name: http
port: {{ .Values.service.httpPort }}
protocol: TCP
targetPort: http
- name: metrics
port: {{ .Values.service.metricsPort }}
targetPort: metrics

selector:
{{- include "app.selectorLabels" . | nindent 4 }}
16 changes: 16 additions & 0 deletions charts/home-assistant/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
{{- if .Values.serviceAccount.annotations }}
annotations:
{{- toYaml .Values.serviceAccount.annotations | nindent 4 }}
{{- end }}
name: {{ template "app.fullname" . }}
labels:
{{- include "app.labels" . | nindent 4 }}
{{- if .Values.serviceAccount.labels }}
{{ toYaml .Values.serviceAccount.labels | indent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
68 changes: 68 additions & 0 deletions charts/home-assistant/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{- if and ( .Values.monitoring.serviceMonitor.enabled ) ( .Values.monitoring.enabled ) }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "app.fullname" . }}-prometheus-exporter
labels:
{{- include "app.labels" . | nindent 4 }}
{{- with .Values.monitoring.serviceMonitor.selector }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.monitoring.serviceMonitor.namespace }}
namespace: {{ .Values.monitoring.serviceMonitor.namespace }}
{{- end }}

spec:
selector:
matchLabels:
{{- include "app.selectorLabels" . | nindent 6 }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 6 }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
endpoints:
- targetPort: {{ .Values.service.metricsPort }}
path: /metrics
{{- with .Values.monitoring.serviceMonitor.honorLabels }}
honorLabels: {{ . }}
{{- end }}
{{- if .Values.monitoring.serviceMonitor.interval }}
interval: {{ .Values.monitoring.serviceMonitor.interval }}
{{- end }}
{{- if .Values.monitoring.serviceMonitor.scrapeTimeout}}
scrapeTimeout: {{ .Values.monitoring.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.scheme }}
scheme: {{ . }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.tlsConfig }}
tlsConfig:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.relabelings }}
relabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with .Values.monitoring.serviceMonitor.metricRelabelings }}
metricRelabelings:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- if .Values.monitoring.serviceMonitor.bearerTokenFile }}
bearerTokenFile: {{ .Values.monitoring.serviceMonitor.bearerTokenFile }}
{{- end }}
{{- if .Values.monitoring.serviceMonitor.bearerTokenSecret }}
bearerTokenSecret:
name: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.name }}
key: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.key }}
{{- if .Values.monitoring.serviceMonitor.bearerTokenSecret.optional }}
optional: {{ .Values.monitoring.serviceMonitor.bearerTokenSecret.optional }}
{{- end }}
{{- end }}
jobLabel: {{ template "app.fullname" . }}-prometheus-exporter
{{- end }}
Loading

0 comments on commit dd6af95

Please sign in to comment.