diff --git a/charts/esphome/Chart.yaml b/charts/esphome/Chart.yaml index 4228407..527ef62 100644 --- a/charts/esphome/Chart.yaml +++ b/charts/esphome/Chart.yaml @@ -3,7 +3,7 @@ apiVersion: v2 appVersion: 2024.5.4 description: ESPHome name: esphome -version: 0.0.4 +version: 0.0.5 keywords: - esphome type: application diff --git a/charts/esphome/templates/deployment.yaml b/charts/esphome/templates/deployment.yaml index 22fb420..d6696ef 100644 --- a/charts/esphome/templates/deployment.yaml +++ b/charts/esphome/templates/deployment.yaml @@ -128,7 +128,7 @@ spec: {{- if .Values.persistence.enabled }} {{- if .Values.persistence.hostPath }} hostPath: - path: {{.Values.persistence.hostPath}} + path: {{.Values.persistence.hostPath}} type: Directory {{- else }} persistentVolumeClaim: diff --git a/charts/esphome/templates/hpa.yaml b/charts/esphome/templates/hpa.yaml new file mode 100644 index 0000000..de3889c --- /dev/null +++ b/charts/esphome/templates/hpa.yaml @@ -0,0 +1,34 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "app.fullname" . }} + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "app.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.averageCPUUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: cpu + container: {{ include "app.fullname" . }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.averageCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.averageMemoryUtilizationPercentage }} + - type: ContainerResource + containerResource: + name: memory + container: {{ include "app.fullname" . }} + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.averageMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/esphome/templates/service.yaml b/charts/esphome/templates/service.yaml index 290595a..a4545d4 100644 --- a/charts/esphome/templates/service.yaml +++ b/charts/esphome/templates/service.yaml @@ -14,10 +14,6 @@ metadata: annotations: {{ toYaml . | indent 4 }} {{- end }} - - - - spec: type: {{ .Values.service.type }} {{- if .Values.service.externalIPs }} diff --git a/charts/esphome/values.yaml b/charts/esphome/values.yaml index a44da88..ce28a9d 100644 --- a/charts/esphome/values.yaml +++ b/charts/esphome/values.yaml @@ -162,3 +162,10 @@ persistence: hostMounts: [] # - name: zha # hostPath: /dev/serial/by-id/usb-Silicon_Labs_HubZ_Smart_Home_Controller_6120245D-if01-port0 + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 10 + averageCPUUtilizationPercentage: 50 + averageMemoryUtilizationPercentage: 50