[homebridge] New chart (#59)

* [homebridge] New chart

* [homebridge] Additional variables in README

* [homebridge] Set default service type to ClusterIP

Co-authored-by: Jeff Billimek <jeff@billimek.com>
This commit is contained in:
Bernd Schörgers 2020-09-22 14:56:43 +02:00 committed by GitHub
parent 85c7673e31
commit 628e2f6842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 622 additions and 0 deletions

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,15 @@
apiVersion: v2
appVersion: 3.1.0
version: 1.0.0
name: homebridge
description: A lightweight NodeJS server that emulates the iOS HomeKit API
type: application
keywords:
- homebridge
- homekit
home: https://homebridge.io/
sources:
- https://github.com/oznu/docker-homebridge
maintainers:
- name: bjw-s
email: bjw-s@users.noreply.github.com

100
charts/homebridge/README.md Normal file
View File

@ -0,0 +1,100 @@
# Homebridge
This is a helm chart for [Homebridge](https://homebridge.io) based on [Docker Homebridge](https://github.com/oznu/docker-homebridge).
## TL;DR;
```shell
helm repo add k8s-at-home https://k8s-at-home.com/charts/
helm install k8s-at-home/homebridge
```
## Installing the Chart
To install the chart with the release name `my-release`:
```shell
helm install --name my-release k8s-at-home/homebridge
```
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```shell
helm delete my-release --purge
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following tables lists the configurable parameters of the Home Assistant chart and their default values.
| Parameter | Description | Default |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- |
| `image.repository` | Image repository | `oznu/homebridge` |
| `image.tag` | Image tag. Possible values listed [here](https://hub.docker.com/r/oznu/homebridge/tags). | `3.1.0` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.pullSecrets` | Secrets to use when pulling the image | `[]` |
| `strategyType` | Specifies the strategy used to replace old Pods by new ones | `Recreate` |
| `timezone` | Specify the container timezone | `UTC` |
| `puid` | process userID the instance should run as | `1000` |
| `pgid` | process groupID the instance should run as | `1000` |
| `config.enableUI` | Enable the Homebridge UI plugin | `true` |
| `config.plugins` | Additional Homebridge plugins to install at container startup | `[]` |
| `config.additionalPackages` | Additional Alpine packages to install at container statup | `[] ` |
| `probes.liveness.enabled` | Use the livenessProbe? | `true` |
| `probes.liveness.initialDelaySeconds` | Specify liveness `initialDelaySeconds` parameter for the deployment | `60` |
| `probes.liveness.failureThreshold` | Specify liveness `failureThreshold` parameter for the deployment | `5` |
| `probes.liveness.timeoutSeconds` | Specify liveness `timeoutSeconds` parameter for the deployment | `10` |
| `probes.readiness.enabled` | Use the readinessProbe? | `true` |
| `probes.readiness.initialDelaySeconds` | Specify readiness `initialDelaySeconds` parameter for the deployment | `60` |
| `probes.readiness.failureThreshold` | Specify readiness `failureThreshold` parameter for the deployment | `5` |
| `probes.readiness.timeoutSeconds` | Specify readiness `timeoutSeconds` parameter for the deployment | `10` |
| `probes.startup.enabled` | Use the startupProbe? (new in kubernetes 1.16) | `false` |
| `probes.startup.failureThreshold` | Specify startup `failureThreshold` parameter for the deployment | `5` |
| `probes.startup.periodSeconds` | Specify startup `periodSeconds` parameter for the deployment | `10` |
| `service.type` | Kubernetes service type for the homebridge GUI | `ClusterIP` |
| `service.httpPort` | Kubernetes port where the homebridge GUI is exposed | `8123` |
| `service.annotations` | Service annotations for the homebridge GUI | `{}` |
| `service.clusterIP` | Cluster IP for the homebridge GUI | `` |
| `service.externalIPs` | External IPs for the homebridge GUI | `[]` |
| `service.loadBalancerIP` | Loadbalancer IP for the homebridge GUI | `` |
| `service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the homebridge GUI | `[]` |
| `service.externalTrafficPolicy` | Loadbalancer externalTrafficPolicy | `` |
| `hostNetwork` | Enable hostNetwork - needed for discovery to work | `false` |
| `service.nodePort` | nodePort to listen on for the homebridge GUI | `` |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.path` | Ingress path | `/` |
| `ingress.hosts` | Ingress accepted hostnames | `chart-example.local` |
| `ingress.tls` | Ingress TLS configuration | `[]` |
| `persistence.enabled` | Use persistent volume to store data | `true` |
| `persistence.size` | Size of persistent volume claim | `1Gi` |
| `persistence.existingClaim` | Use an existing PVC to persist data | `nil` |
| `persistence.storageClass` | Type of persistent volume claim | `-` |
| `persistence.accessMode` | Persistence access modes | `ReadWriteMany` |
| `persistence.skipuninstall` | Do not delete the pvc upon helm uninstall | `false` |
| `extraEnvs` | Extra ENV vars to pass to the homebridge container | `[]` |
| `resources` | CPU/Memory resource requests/limits or the homebridge GUI | `{}` |
| `nodeSelector` | Node labels for pod assignment or the homebridge GUI | `{}` |
| `tolerations` | Toleration labels for pod assignment or the homebridge GUI | `[]` |
| `affinity` | Affinity settings for pod assignment or the homebridge GUI | `{}` |
| `podAnnotations` | Key-value pairs to add as pod annotations | `{}` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```shell
helm install --name my-release \
--set timezone="UTC" \
k8s-at-home/homebridge
```
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,
```shell
helm install --name my-release -f values.yaml k8s-at-home/homebridge
```
Read through the [values.yaml](values.yaml) file. It has several commented out suggested values.

View File

@ -0,0 +1,22 @@
{{- if .Values.config.enableUI }}
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- $ingressPath := .Values.ingress.path -}}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ $ingressPath }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "homebridge.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "homebridge.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "homebridge.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.httpPort }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "homebridge.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:{{ .Values.service.httpPort }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "homebridge.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 "homebridge.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 "homebridge.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "homebridge.labels" -}}
helm.sh/chart: {{ include "homebridge.chart" . }}
{{ include "homebridge.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "homebridge.selectorLabels" -}}
app.kubernetes.io/name: {{ include "homebridge.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "homebridge.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "homebridge.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "homebridge.fullname" . }}
labels:
{{ include "homebridge.labels" . | indent 4 }}
data:
startup.sh: |
#!/bin/sh
# Docker Homebridge startup.sh overriden by Helm Chart
# Plugins
{{- range .Values.config.plugins }}
npm install {{ . }}
{{- end }}
# Packages
{{- range .Values.config.additionalPackages }}
apk add --no-cache {{ . }}
{{- end }}

View File

@ -0,0 +1,134 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "homebridge.fullname" . }}
labels:
{{- include "homebridge.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "homebridge.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "homebridge.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "homebridge.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.hostNetwork }}
hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- end }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- if .Values.timezone }}
- name: TZ
value: {{ .Values.timezone | quote }}
{{- end }}
{{- if .Values.puid }}
- name: PUID
value: "{{ .Values.puid }}"
{{- end }}
{{- if .Values.pgid }}
- name: PGID
value: "{{ .Values.pgid }}"
{{- end }}
{{- if .Values.config.enableUI }}
- name: HOMEBRIDGE_CONFIG_UI
value: "1"
- name: HOMEBRIDGE_CONFIG_UI_PORT
value: {{ .Values.service.httpPort | quote }}
{{- end }}
{{- with .Values.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: homebridge
containerPort: {{ .Values.service.homebridgePort }}
protocol: TCP
{{- if .Values.config.enableUI }}
- name: http
containerPort: {{ .Values.service.httpPort }}
protocol: TCP
{{- end }}
volumeMounts:
- mountPath: /homebridge
name: config
- mountPath: /homebridge/startup.sh
name: homebridge-configmap
subPath: startup.sh
{{- if .Values.config.enableUI }}
{{- if .Values.probes.liveness.enabled }}
livenessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.liveness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.liveness.timeoutSeconds }}
{{- end }}
{{- if .Values.probes.readiness.enabled }}
readinessProbe:
httpGet:
path: /
port: http
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}
timeoutSeconds: {{ .Values.probes.readiness.timeoutSeconds }}
{{- end }}
{{- if .Values.probes.startup.enabled }}
startupProbe:
httpGet:
path: /
port: http
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumes:
- name: config
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "homebridge.fullname" . }}-config{{- end }}
{{- else }}
emptyDir: {}
{{- end }}
- name: homebridge-configmap
projected:
defaultMode: 0444
sources:
- configMap:
name: {{ template "homebridge.fullname" . }}
items:
- key: startup.sh
path: startup.sh
mode: 0755
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -0,0 +1,39 @@
{{- if and .Values.config.enableUI .Values.ingress.enabled -}}
{{- $fullName := include "homebridge.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "homebridge.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ . | quote }}
http:
paths:
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}

View File

@ -0,0 +1,25 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "homebridge.fullname" . }}-config
{{- if .Values.persistence.skipuninstall }}
annotations:
"helm.sh/resource-policy": keep
{{- end }}
labels:
{{- include "homebridge.labels" . | nindent 4 }}
spec:
accessModes:
- {{ .Values.persistence.accessMode | quote }}
resources:
requests:
storage: {{ .Values.persistence.size | quote }}
{{- if .Values.persistence.storageClass }}
{{- if (eq "-" .Values.persistence.storageClass) }}
storageClassName: ""
{{- else }}
storageClassName: {{ .Values.persistence.storageClass | quote }}
{{- end }}
{{- end }}
{{- end -}}

View File

@ -0,0 +1,48 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "homebridge.fullname" . }}
{{- if .Values.service.annotations }}
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- end }}
labels:
{{- include "homebridge.labels" . | nindent 4 }}
spec:
{{- if (or (eq .Values.service.type "ClusterIP") (empty .Values.service.type)) }}
type: ClusterIP
{{- else if eq .Values.service.type "LoadBalancer" }}
type: {{ .Values.service.type }}
{{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ toYaml .Values.service.loadBalancerSourceRanges | indent 4 }}
{{- end -}}
{{- else }}
type: {{ .Values.service.type }}
{{- end }}
{{- if .Values.service.externalIPs }}
externalIPs:
{{- toYaml .Values.service.externalIPs | nindent 4 }}
{{- end }}
{{- if .Values.service.externalTrafficPolicy }}
externalTrafficPolicy: {{ .Values.service.externalTrafficPolicy }}
{{- end }}
ports:
- port: {{ .Values.service.homebridgePort }}
targetPort: homebridge
protocol: TCP
name: homebridge
{{- if .Values.config.enableUI }}
- port: {{ .Values.service.httpPort }}
targetPort: http
protocol: TCP
name: http
{{- end }}
{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{.Values.service.nodePort}}
{{ end }}
selector:
{{- include "homebridge.selectorLabels" . | nindent 4 }}

View File

@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "homebridge.serviceAccountName" . }}
labels:
{{- include "homebridge.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,121 @@
# Default values for homebridge.
replicaCount: 1
image:
repository: oznu/homebridge
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "3.1.0"
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
timezone: "UTC"
puid: 1000
pgid: 1000
config:
enableUI: true
plugins: []
# - homebridge-hue
additionalPackages: []
# - bash
extraEnvs: []
serviceAccount:
# Specifies whether a service account should be created
create: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
homebridgePort: 51826
httpPort: 8080
ingress:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
path: /
hosts:
- chart-example.local
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
hostNetwork: false
persistence:
enabled: true
## homebridge data Persistent Volume Storage Class
## If defined, storageClassName: <storageClass>
## If set to "-", storageClassName: "", which disables dynamic provisioning
## If undefined (the default) or set to null, no storageClassName spec is
## set, choosing the default provisioner. (gp2 on AWS, standard on
## GKE, AWS & OpenStack)
##
# storageClass: "-"
##
## If you want to reuse an existing claim, you can pass the name of the PVC using
## the existingClaim variable
# existingClaim: your-claim
accessMode: ReadWriteOnce
size: 1Gi
## Do not delete the pvc upon helm uninstall
skipuninstall: false
probes:
liveness:
enabled: true
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
readiness:
enabled: true
initialDelaySeconds: 60
failureThreshold: 5
timeoutSeconds: 10
startup:
enabled: false
failureThreshold: 30
periodSeconds: 10
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: {}