Adding a option for a git init container.

Signed-off-by: nolte <nolte07@googlemail.com>
This commit is contained in:
nolte 2020-09-14 21:33:18 +02:00 committed by nolte
parent d90ddd9e2b
commit f00fef03b6
4 changed files with 148 additions and 62 deletions

View File

@ -1,8 +1,8 @@
apiVersion: v2 apiVersion: v2
appVersion: 1.14.5 appVersion: 1.15.2
description: ESPHome description: ESPHome
name: esphome name: esphome
version: 2.0.0 version: 2.2.0
keywords: keywords:
- esphome - esphome
home: https://github.com/k8s-at-home/charts/tree/master/charts/esphome home: https://github.com/k8s-at-home/charts/tree/master/charts/esphome

View File

@ -35,9 +35,9 @@ The command removes all the Kubernetes components associated with the chart and
The following tables lists the configurable parameters of the ESPHome chart and their default values. The following tables lists the configurable parameters of the ESPHome chart and their default values.
| Parameter | Description | Default | | Parameter | Description | Default |
|----------------------------|-------------------------------------|---------------------------------------------------------| |----------------------------------------|--------------------------------------------------------------------------------------------------------------------|-----------------------|
| `image.repository` | Image repository | `esphome/esphome` | | `image.repository` | Image repository | `esphome/esphome` |
| `image.tag` | Image tag. Possible values listed [here](https://hub.docker.com/r/esphome/esphome/tags/).| `0.14.5`| | `image.tag` | Image tag. Possible values listed [here](https://hub.docker.com/r/esphome/esphome/tags/). | `0.14.5` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.pullSecrets` | Secrets to use when pulling the image | `[]` | | `image.pullSecrets` | Secrets to use when pulling the image | `[]` |
| `strategyType` | Specifies the strategy used to replace old Pods by new ones | `Recreate` | | `strategyType` | Specifies the strategy used to replace old Pods by new ones | `Recreate` |
@ -56,7 +56,7 @@ The following tables lists the configurable parameters of the ESPHome chart and
| `probes.startup.failureThreshold` | Specify startup `failureThreshold` parameter for the deployment | `5` | | `probes.startup.failureThreshold` | Specify startup `failureThreshold` parameter for the deployment | `5` |
| `probes.startup.periodSeconds` | Specify startup `periodSeconds` parameter for the deployment | `10` | | `probes.startup.periodSeconds` | Specify startup `periodSeconds` parameter for the deployment | `10` |
| `service.type` | Kubernetes service type for the esphome GUI | `ClusterIP` | | `service.type` | Kubernetes service type for the esphome GUI | `ClusterIP` |
| `service.port` | Kubernetes port where the esphome GUI is exposed| `6052` | | `service.port` | Kubernetes port where the esphome GUI is exposed | `6052` |
| `service.portName` | Kubernetes port name where the esphome GUI is exposed | `api` | | `service.portName` | Kubernetes port name where the esphome GUI is exposed | `api` |
| `service.additionalPorts` | Add additional ports exposed by the esphome container integrations. Example homematic needs to expose a proxy port | `{}` | | `service.additionalPorts` | Add additional ports exposed by the esphome container integrations. Example homematic needs to expose a proxy port | `{}` |
| `service.annotations` | Service annotations for the esphome GUI | `{}` | | `service.annotations` | Service annotations for the esphome GUI | `{}` |
@ -66,7 +66,7 @@ The following tables lists the configurable parameters of the ESPHome chart and
| `service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the esphome GUI | `[]` | | `service.loadBalancerSourceRanges` | Loadbalancer client IP restriction range for the esphome GUI | `[]` |
| `service.publishNotReadyAddresses` | Set to true if the notReadyAddresses should be published | `false` | | `service.publishNotReadyAddresses` | Set to true if the notReadyAddresses should be published | `false` |
| `service.externalTrafficPolicy` | Loadbalancer externalTrafficPolicy | `` | | `service.externalTrafficPolicy` | Loadbalancer externalTrafficPolicy | `` |
| `hostNetwork` | Enable hostNetwork - might be needed for discovery to work | `false` | | `hostNetwork` | Enable hostNetwork - might be needed for discovery to work | `false` |
| `service.nodePort` | nodePort to listen on for the esphome GUI | `` | | `service.nodePort` | nodePort to listen on for the esphome GUI | `` |
| `ingress.enabled` | Enables Ingress | `false` | | `ingress.enabled` | Enables Ingress | `false` |
| `ingress.annotations` | Ingress annotations | `{}` | | `ingress.annotations` | Ingress annotations | `{}` |
@ -75,10 +75,16 @@ The following tables lists the configurable parameters of the ESPHome chart and
| `ingress.tls` | Ingress TLS configuration | `[]` | | `ingress.tls` | Ingress TLS configuration | `[]` |
| `persistence.enabled` | Use persistent volume to store data | `true` | | `persistence.enabled` | Use persistent volume to store data | `true` |
| `persistence.size` | Size of persistent volume claim | `5Gi` | | `persistence.size` | Size of persistent volume claim | `5Gi` |
| `persistence.existingClaim`| Use an existing PVC to persist data | `nil` | | `persistence.existingClaim` | Use an existing PVC to persist data | `nil` |
| `persistence.hostPath`| The path to the config directory on the host, instead of a PVC | `nil` | | `persistence.hostPath` | The path to the config directory on the host, instead of a PVC | `nil` |
| `persistence.storageClass` | Type of persistent volume claim | `-` | | `persistence.storageClass` | Type of persistent volume claim | `-` |
| `persistence.accessMode` | Persistence access modes | `ReadWriteMany` | | `persistence.accessMode` | Persistence access modes | `ReadWriteMany` |
| `git.enabled` | Use git-sync in init container | `false` |
| `git.secret` | Git secret to use for git-sync | `git-creds` |
| `git.syncPath` | Git sync path | `/config` |
| `git.keyPath` | Git ssh key path | `/root/.ssh` |
| `git.user.name` | Human-readable name in the “committer” and “author” fields | `` |
| `git.user.email` | Email address for the “committer” and “author” fields | `` |
| `hostMounts` | Array of host directories to mount; can be used for devices | [] | | `hostMounts` | Array of host directories to mount; can be used for devices | [] |
| `hostMounts.name` | Name of the volume | `nil` | | `hostMounts.name` | Name of the volume | `nil` |
| `hostMounts.hostPath` | The path on the host machine | `nil` | | `hostMounts.hostPath` | The path on the host machine | `nil` |
@ -96,6 +102,7 @@ The following tables lists the configurable parameters of the ESPHome chart and
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```shell ```shell

View File

@ -37,6 +37,56 @@ spec:
hostNetwork: {{ .Values.hostNetwork }} hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
{{- end }} {{- end }}
initContainers:
{{- if .Values.git.enabled }}
- name: git-sync
image: "{{ .Values.git.image.repository }}:{{ .Values.git.image.tag }}"
imagePullPolicy: {{ .Values.git.image.pullPolicy }}
{{- if .Values.git.command }}
command:
{{- range .Values.git.command }}
- {{ . | quote }}
{{- end }}
{{- else }}
command: ["/bin/sh", "-c"]
args:
- set -e;
if [ -d "{{ .Values.git.syncPath }}/.git" ];
then
git -C "{{ .Values.git.syncPath }}" pull || true;
else
if [ "$(ls -A {{ .Values.git.syncPath }})" ];
then
git clone --depth 2 "{{ .Values.git.repo }}" /tmp/repo;
cp -rf /tmp/repo/.git "{{ .Values.git.syncPath }}";
cd "{{ .Values.git.syncPath }}";
git checkout -f;
else
git clone --depth 2 "{{ .Values.git.repo }}" "{{ .Values.git.syncPath }}";
fi;
fi;
if [ -f "{{ .Values.git.keyPath }}/git-crypt-key" ];
then
cd {{ .Values.git.syncPath }};
git-crypt unlock "{{ .Values.git.keyPath }}/git-crypt-key";
fi;
{{- end }}
volumeMounts:
- mountPath: /config
name: config
- mountPath: {{ .Values.git.keyPath }}
name: git-secret
{{- if .Values.extraVolumeMounts }}{{ toYaml .Values.extraVolumeMounts | trim | nindent 8 }}{{ end }}
{{- if .Values.usePodSecurityContext }}
securityContext:
runAsUser: {{ default 0 .Values.runAsUser }}
{{- if and (.Values.runAsUser) (.Values.fsGroup) }}
{{- if not (eq .Values.runAsUser 0.0) }}
fsGroup: {{ .Values.fsGroup }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
containers: containers:
- name: {{ .Chart.Name }} - name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@ -144,6 +194,13 @@ spec:
type: {{ .type }} type: {{ .type }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if .Values.git.enabled }}
- name: git-secret
secret:
defaultMode: 256
secretName: {{ .Values.git.secret }}
optional: true
{{ end }}
{{- if .Values.extraVolumes }}{{ toYaml .Values.extraVolumes | trim | nindent 6 }}{{ end }} {{- if .Values.extraVolumes }}{{ toYaml .Values.extraVolumes | trim | nindent 6 }}{{ end }}
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:

View File

@ -4,7 +4,7 @@
image: image:
repository: esphome/esphome repository: esphome/esphome
tag: 1.14.5 tag: 1.15.2
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
pullSecrets: [] pullSecrets: []
@ -152,3 +152,25 @@ extraVolumes: []
extraVolumeMounts: [] extraVolumeMounts: []
# - name: example-name # - name: example-name
# mountPath: /path/in/container # mountPath: /path/in/container
git:
enabled: false
image:
repository: k8sathome/git-crypt
tag: 2020.09.07
pullPolicy: IfNotPresent
## Specify the command that runs in the git-sync container to pull in configuration.
# command: []
# Committer settings
user:
name: ""
email: ""
repo: ""
secret: git-creds
syncPath: /config
keyPath: /root/.ssh