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

@ -34,65 +34,72 @@ 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` |
| `probes.liveness.enabled` | Use the livenessProbe? | `true` | | `probes.liveness.enabled` | Use the livenessProbe? | `true` |
| `probes.liveness.scheme ` | Specify liveness `scheme` parameter for the deployment | `HTTP` | | `probes.liveness.scheme ` | Specify liveness `scheme` parameter for the deployment | `HTTP` |
| `probes.liveness.initialDelaySeconds` | Specify liveness `initialDelaySeconds` parameter for the deployment | `60` | | `probes.liveness.initialDelaySeconds` | Specify liveness `initialDelaySeconds` parameter for the deployment | `60` |
| `probes.liveness.failureThreshold` | Specify liveness `failureThreshold` parameter for the deployment | `5` | | `probes.liveness.failureThreshold` | Specify liveness `failureThreshold` parameter for the deployment | `5` |
| `probes.liveness.timeoutSeconds` | Specify liveness `timeoutSeconds` parameter for the deployment | `10` | | `probes.liveness.timeoutSeconds` | Specify liveness `timeoutSeconds` parameter for the deployment | `10` |
| `probes.readiness.enabled` | Use the readinessProbe? | `true` | | `probes.readiness.enabled` | Use the readinessProbe? | `true` |
| `probes.readiness.scheme ` | Specify readiness `scheme` parameter for the deployment | `HTTP` | | `probes.readiness.scheme ` | Specify readiness `scheme` parameter for the deployment | `HTTP` |
| `probes.readiness.initialDelaySeconds` | Specify readiness `initialDelaySeconds` parameter for the deployment | `60` | | `probes.readiness.initialDelaySeconds` | Specify readiness `initialDelaySeconds` parameter for the deployment | `60` |
| `probes.readiness.failureThreshold` | Specify readiness `failureThreshold` parameter for the deployment | `5` | | `probes.readiness.failureThreshold` | Specify readiness `failureThreshold` parameter for the deployment | `5` |
| `probes.readiness.timeoutSeconds` | Specify readiness `timeoutSeconds` parameter for the deployment | `10` | | `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.enabled` | Use the startupProbe? (new in kubernetes 1.16) | `false` |
| `probes.startup.scheme ` | Specify startup `scheme` parameter for the deployment | `HTTP` | | `probes.startup.scheme ` | Specify startup `scheme` parameter for the deployment | `HTTP` |
| `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 | `{}` |
| `service.clusterIP` | Cluster IP for the esphom GUI | `` | | `service.clusterIP` | Cluster IP for the esphom GUI | `` |
| `service.externalIPs` | External IPs for the esphome GUI | `[]` | | `service.externalIPs` | External IPs for the esphome GUI | `[]` |
| `service.loadBalancerIP` | Loadbalancer IP for the esphome GUI | `` | | `service.loadBalancerIP` | Loadbalancer IP for the esphome GUI | `` |
| `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 | `{}` |
| `ingress.path` | Ingress path | `/` | | `ingress.path` | Ingress path | `/` |
| `ingress.hosts` | Ingress accepted hostnames | `chart-example.local` | | `ingress.hosts` | Ingress accepted hostnames | `chart-example.local` |
| `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` |
| `hostMounts` | Array of host directories to mount; can be used for devices | [] | | `git.enabled` | Use git-sync in init container | `false` |
| `hostMounts.name` | Name of the volume | `nil` | | `git.secret` | Git secret to use for git-sync | `git-creds` |
| `hostMounts.hostPath` | The path on the host machine | `nil` | | `git.syncPath` | Git sync path | `/config` |
| `hostMounts.mountPath` | The path at which to mount (optional; assumed same as hostPath) | `nil` | | `git.keyPath` | Git ssh key path | `/root/.ssh` |
| `hostMounts.type` | The type to mount (optional, i.e., `Directory`) | `nil` | | `git.user.name` | Human-readable name in the “committer” and “author” fields | `` |
| `extraEnv` | Extra ENV vars to pass to the esphome container | `{}` | | `git.user.email` | Email address for the “committer” and “author” fields | `` |
| `extraEnvSecrets` | Extra env vars to pass to the esphome container from k8s secrets - see `values.yaml` for an example | `{}` | | `hostMounts` | Array of host directories to mount; can be used for devices | [] |
| `resources` | CPU/Memory resource requests/limits or the esphome GUI | `{}` | | `hostMounts.name` | Name of the volume | `nil` |
| `nodeSelector` | Node labels for pod assignment or the esphome GUI | `{}` | | `hostMounts.hostPath` | The path on the host machine | `nil` |
| `tolerations` | Toleration labels for pod assignment or the esphome GUI | `[]` | | `hostMounts.mountPath` | The path at which to mount (optional; assumed same as hostPath) | `nil` |
| `affinity` | Affinity settings for pod assignment or the esphome GUI | `{}` | | `hostMounts.type` | The type to mount (optional, i.e., `Directory`) | `nil` |
| `podAnnotations` | Key-value pairs to add as pod annotations | `{}` | | `extraEnv` | Extra ENV vars to pass to the esphome container | `{}` |
| `extraVolumes` | Any extra volumes to define for the pod | `{}` | | `extraEnvSecrets` | Extra env vars to pass to the esphome container from k8s secrets - see `values.yaml` for an example | `{}` |
| `extraVolumeMounts` | Any extra volumes mounts to define for each container of the pod | `{}` | | `resources` | CPU/Memory resource requests/limits or the esphome GUI | `{}` |
| `nodeSelector` | Node labels for pod assignment or the esphome GUI | `{}` |
| `tolerations` | Toleration labels for pod assignment or the esphome GUI | `[]` |
| `affinity` | Affinity settings for pod assignment or the esphome GUI | `{}` |
| `podAnnotations` | Key-value pairs to add as pod annotations | `{}` |
| `extraVolumes` | Any extra volumes to define for the pod | `{}` |
| `extraVolumeMounts` | Any extra volumes mounts to define for each container of the pod | `{}` |

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