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
appVersion: 1.14.5
appVersion: 1.15.2
description: ESPHome
name: esphome
version: 2.0.0
version: 2.2.0
keywords:
- esphome
home: https://github.com/k8s-at-home/charts/tree/master/charts/esphome

View File

@ -35,7 +35,7 @@ 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.
| Parameter | Description | Default |
|----------------------------|-------------------------------------|---------------------------------------------------------|
|----------------------------------------|--------------------------------------------------------------------------------------------------------------------|-----------------------|
| `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.pullPolicy` | Image pull policy | `IfNotPresent` |
@ -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.publishNotReadyAddresses` | Set to true if the notReadyAddresses should be published | `false` |
| `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 | `` |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
@ -79,6 +79,12 @@ The following tables lists the configurable parameters of the ESPHome chart and
| `persistence.hostPath` | The path to the config directory on the host, instead of a PVC | `nil` |
| `persistence.storageClass` | Type of persistent volume claim | `-` |
| `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.name` | Name of the volume | `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,
```shell

View File

@ -37,6 +37,56 @@ spec:
hostNetwork: {{ .Values.hostNetwork }}
dnsPolicy: ClusterFirstWithHostNet
{{- 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:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
@ -144,6 +194,13 @@ spec:
type: {{ .type }}
{{- 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 }}
{{- with .Values.nodeSelector }}
nodeSelector:

View File

@ -4,7 +4,7 @@
image:
repository: esphome/esphome
tag: 1.14.5
tag: 1.15.2
pullPolicy: IfNotPresent
pullSecrets: []
@ -152,3 +152,25 @@ extraVolumes: []
extraVolumeMounts: []
# - name: example-name
# 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