Add esphome.
All checks were successful
ci/woodpecker/push/esphome Pipeline was successful
ci/woodpecker/push/mastodon Pipeline was successful

This commit is contained in:
Alex Manning 2023-02-28 20:42:51 +00:00
parent 839ab6d6e3
commit 931ef940d4
11 changed files with 226 additions and 17 deletions

View file

@ -1,6 +1,6 @@
--- ---
when: when:
path: "charts/common/*" path: "charts/esphome/*"
branches: branches:
- main - main
pipeline: pipeline:
@ -10,4 +10,4 @@ pipeline:
commands: commands:
- helm plugin install https://github.com/chartmuseum/helm-push - helm plugin install https://github.com/chartmuseum/helm-push
- helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD - helm repo add therepo $HELM_REPO --username $HELM_USER --password $HELM_PASSWORD
- helm cm-push charts/common therepo - helm cm-push charts/esphome therepo

View file

@ -1,5 +0,0 @@
---
apiVersion: v2
name: a09-common
type: library
version: 0.1.1

View file

@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View file

@ -0,0 +1,6 @@
apiVersion: v2
name: esphome
description: A Helm chart for esphome.
type: application
version: 0.1.0
appVersion: "2023.2.4"

View file

@ -1,7 +1,7 @@
{{/* {{/*
Expand the name of the chart. Expand the name of the chart.
*/}} */}}
{{- define "a09-common.name" -}} {{- define "esphome.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }} {{- end }}
@ -10,7 +10,7 @@ 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). 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. If release name contains chart name it will be used as a full name.
*/}} */}}
{{- define "a09-common.fullname" -}} {{- define "esphome.fullname" -}}
{{- if .Values.fullnameOverride }} {{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }} {{- else }}
@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name.
{{/* {{/*
Create chart name and version as used by the chart label. Create chart name and version as used by the chart label.
*/}} */}}
{{- define "a09-common.chart" -}} {{- define "esphome.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }} {{- end }}
{{/* {{/*
Common labels Common labels
*/}} */}}
{{- define "a09-common.labels" -}} {{- define "esphome.labels" -}}
helm.sh/chart: {{ include "a09-common.chart" . }} helm.sh/chart: {{ include "esphome.chart" . }}
{{ include "a09-common.selectorLabels" . }} {{ include "esphome.selectorLabels" . }}
{{- if .Chart.AppVersion }} {{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }} {{- end }}
@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{/* {{/*
Selector labels Selector labels
*/}} */}}
{{- define "a09-common.selectorLabels" -}} {{- define "esphome.selectorLabels" -}}
app.kubernetes.io/name: {{ include "a09-common.name" . }} app.kubernetes.io/name: {{ include "esphome.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }} {{- end }}
{{/* {{/*
Create the name of the service account to use Create the name of the service account to use
*/}} */}}
{{- define "a09-common.serviceAccountName" -}} {{- define "esphome.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }} {{- if .Values.serviceAccount.create }}
{{- default (include "a09-common.fullname" .) .Values.serviceAccount.name }} {{- default (include "esphome.fullname" .) .Values.serviceAccount.name }}
{{- else }} {{- else }}
{{- default "default" .Values.serviceAccount.name }} {{- default "default" .Values.serviceAccount.name }}
{{- end }} {{- end }}

View file

@ -0,0 +1,70 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "esphome.fullname" . }}
labels:
{{- include "esphome.labels" . | nindent 4 }}
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
hass.kube.a09.uk/automationService: esphome
{{- include "esphome.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
hass.kube.a09.uk/automationService: esphome
{{- include "esphome.selectorLabels" . | nindent 8 }}
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "esphome.serviceAccountName" . }}-esphome
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
priorityClassName: {{ .Values.priorityClassName }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 6052
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config
mountPath: /config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: config
persistentVolumeClaim:
claimName: {{ include "esphome.fullname" . }}-config

View file

@ -0,0 +1,20 @@
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "esphome.fullname" . }}
labels:
{{- include "esphome.labels" . | nindent 4 }}
spec:
rules:
- host: {{ .Values.ingress.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "esphome.fullname" . }}
port:
name: http
{{- end }}

View file

@ -0,0 +1,17 @@
{{- if not .Values.pvc.existingClaim -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "esphome.fullname" . }}-config
labels:
{{- include "esphome.labels" . | nindent 4 }}
annotations:
helm.sh/resource-policy: "keep"
spec:
accessModes:
- ReadWriteOnce
storageClassName: {{ .Values.pvc.storageClassName | quote }}
resources:
requests:
storage: {{ .Values.pvc.storage | quote }}
{{- end }}

View file

@ -0,0 +1,21 @@
{{- if .Values.esphome.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "esphome.fullname" . }}
labels:
{{- include "esphome.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: 6052
targetPort: http
protocol: TCP
name: http
{{- with .Values.service.nodePort }}
nodePort: {{ . }}
{{- end }}
selector:
hass.kube.a09.uk/automationService: esphome
{{- include "esphome.selectorLabels" . | nindent 4 }}
{{- end }}

View file

@ -0,0 +1,57 @@
# Default values for esphome.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
image:
repository: ghcr.io/esphome/esphome
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
host: ""
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
pvc:
existingClaim: false
storageClassName: ""
storage: 5Gi