[homer] configmap support (#655)

* Add homer ConfigMap

Allows homer to be configured through values.yaml

Signed-off-by: Travis Lyons <travis.lyons@gmail.com>

* Updated README to reflect chart changes.

Signed-off-by: Travis Lyons <travis.lyons@gmail.com>

* Add configmap checksum to podAnnotations dict.

Signed-off-by: Travis Lyons <travis.lyons@gmail.com>

* Make usage of configmap togglable

Signed-off-by: Travis Lyons <travis.lyons@gmail.com>

* Only template configmap sections if enabled

Signed-off-by: Travis Lyons <travis.lyons@gmail.com>

Co-authored-by: ᗪєνιη ᗷυнʟ <onedr0p@users.noreply.github.com>
This commit is contained in:
Travis Lyons 2021-03-11 20:01:53 -05:00 committed by GitHub
parent 8acb00bd4c
commit d4f05ae10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 116 additions and 17 deletions

View File

@ -4,7 +4,7 @@ description: A dead simple static HOMepage for your servER to keep your services
icon: https://raw.githubusercontent.com/bastienwirtz/homer/main/public/logo.png
home: https://github.com/bastienwirtz/homer
name: homer
version: 3.1.0
version: 3.2.0
kubeVersion: ">=1.16.0-0"
sources:
- https://github.com/bastienwirtz/homer

View File

@ -1,6 +1,6 @@
# homer
![Version: 3.0.1](https://img.shields.io/badge/Version-3.0.1-informational?style=flat-square) ![AppVersion: 20.09.1](https://img.shields.io/badge/AppVersion-20.09.1-informational?style=flat-square)
![Version: 3.2.0](https://img.shields.io/badge/Version-3.2.0-informational?style=flat-square) ![AppVersion: 20.09.1](https://img.shields.io/badge/AppVersion-20.09.1-informational?style=flat-square)
A dead simple static HOMepage for your servER to keep your services on hand, from a simple yaml configuration file.
@ -18,7 +18,7 @@ Kubernetes: `>=1.16.0-0`
| Repository | Name | Version |
|------------|------|---------|
| https://k8s-at-home.com/charts/ | common | 3.0.1 |
| https://k8s-at-home.com/charts/ | common | 3.1.0 |
## TL;DR
@ -75,6 +75,8 @@ N/A
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| configmap.config | string | `"externalConfig: https://raw.githubusercontent.com/bastienwirtz/homer/main/public/assets/config.yml.dist\n"` | Homer configuration https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md |
| configmap.enabled | bool | `false` | Store homer configuration as a ConfigMap |
| env | object | `{}` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"b4bz/homer"` | |
@ -92,19 +94,19 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [1.0.0]
### [3.2.0]
#### Added
- N/A
- Added changelog.
- Updated README to reflect common chart dependency version in use.
- Enable homer configuration through values.yaml.
#### Changed
[3.2.0]: https://github.com/k8s-at-home/charts/tree/homer-3.1.0/charts
- N/A
### [1.0.0]
#### Removed
- N/A
No changelog prior to 3.2.0
[1.0.0]: #1.0.0

View File

@ -9,19 +9,19 @@ All notable changes to this application Helm chart will be documented in this fi
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### [1.0.0]
### [3.2.0]
#### Added
- N/A
- Added changelog.
- Updated README to reflect common chart dependency version in use.
- Enable homer configuration through values.yaml.
#### Changed
[3.2.0]: https://github.com/k8s-at-home/charts/tree/homer-3.1.0/charts
- N/A
### [1.0.0]
#### Removed
- N/A
No changelog prior to 3.2.0
[1.0.0]: #1.0.0
{{- end -}}

View File

@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "homer.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 "homer.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 "homer.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -1 +1,42 @@
{{/* Make sure all variables are set properly */}}
{{- include "common.values.setup" . }}
{{/* merge homer specific annotations with podAnnotations*/}}
{{- define "homer.podAnnotations" -}}
configmap/checksum: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
{{- end -}}
{{- if .Values.configmap.enabled -}}
{{- $homerPodAnnotations := include "homer.podAnnotations" . | fromYaml -}}
{{- $podAnnotations := merge .Values.podAnnotations $homerPodAnnotations -}}
{{- $_ := set .Values "podAnnotations" (deepCopy $podAnnotations) -}}
{{- end -}}
{{/* Append the configMap to the additionalVolumes */}}
{{- define "homer.configmap.volume" -}}
name: config
configMap:
name: {{ template "common.names.fullname" . }}-config
{{- end -}}
{{- if .Values.configmap.enabled -}}
{{- $volume := include "homer.configmap.volume" . | fromYaml -}}
{{- $additionalVolumes := append .Values.additionalVolumes $volume }}
{{- $_ := set .Values "additionalVolumes" (deepCopy $additionalVolumes) -}}
{{- end -}}
{{/* Append the configMap volume to the additionalVolumeMounts */}}
{{- define "homer.configmap.volumeMount" -}}
name: config
mountPath: /www/assets/config.yml
subPath: config.yml
{{- end -}}
{{- if .Values.configmap.enabled -}}
{{- $volumeMount := include "homer.configmap.volumeMount" . | fromYaml -}}
{{- $additionalVolumeMounts := append .Values.additionalVolumeMounts $volumeMount }}
{{- $_ := set .Values "additionalVolumeMounts" (deepCopy $additionalVolumeMounts) -}}
{{- end -}}
{{/* Render the templates */}}
{{ include "common.all" . }}

View File

@ -0,0 +1,15 @@
{{- if .Values.configmap.enabled -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "homer.fullname" . }}-config
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "homer.name" . }}
helm.sh/chart: {{ include "homer.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
data:
config.yml: |
{{ .Values.configmap.config | indent 4 }}
{{- end -}}

View File

@ -29,3 +29,12 @@ persistence:
enabled: false
emptyDir: false
mountPath: /www/assets
configmap:
# -- Store homer configuration as a ConfigMap
enabled: false
# -- Homer configuration
# https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md
config: |
externalConfig: https://raw.githubusercontent.com/bastienwirtz/homer/main/public/assets/config.yml.dist