fix(web-static): improve to miniserv config

This commit is contained in:
WrenIX 2023-08-26 13:16:22 +02:00
parent 40c86767a2
commit 687f5aaf42
Signed by: wrenix
GPG key ID: 7AFDB012974B1BB5
5 changed files with 223 additions and 16 deletions

View file

@ -2,6 +2,6 @@ apiVersion: v2
name: web-static name: web-static
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
type: application type: application
version: 0.1.0 version: 0.2.0
appVersion: "0.24.0" appVersion: "0.24.0"

View file

@ -0,0 +1,67 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "web-static.fullname" . }}
labels:
{{- include "web-static.labels" . | nindent 4 }}
annotations:
hash-config: "{{ toYaml .Values.data | sha256sum | trunc 32 }}"
data:
{{- with .Values.data }}
{{ with .path }}
MINISERVE_PATH: {{ . | quote }}
{{- end }}
MINISERVE_VERBOSE: {{ .verbose | quote }}
{{- with .index }}
MINISERVE_INDEX: {{ . | quote }}
{{- end }}
MINISERVE_SPA: {{ .spa | quote }}
MINISERVE_PRETTY_URLS: {{ .prettyURLs | quote }}
MINISERVE_PORT: {{ $.Values.service.port | quote }}
{{ with .auth }}
MINISERVE_AUTH: {{ . | quote }}
{{- end }}
# MINISERVE_AUTH_FILE:
{{- with .routePrefix }}
MINISERVE_ROUTE_PREFIX: {{ . | quote }}
{{- end }}
# MINISERVE_RANDOM_ROUTE: <- not usefull in k8s
MINISERVE_NO_SYMLINKS: {{ .noSymlinks | quote }}
MINISERVE_HIDDEN: {{ .hidden | quote }}
MINISERVE_COLOR_SCHEME: {{ .colorScheme | quote }}
MINISERVE_COLOR_SCHEME_DARK: {{ .colorSchemeDark | quote }}
MINISERVE_QRCODE: {{ .qrcode | quote }}
{{- with .upload }}
{{- if .allowedDir }}
MINISERVE_ALLOWED_UPLOAD_DIR: {{ .allowedDir | quote }}
MINISERVE_MKDIR_ENABLED: {{ .mkdir | quote }}
{{- with .mediaType }}
MINISERVE_MEDIA_TYPE: {{ . | quote }}
{{- end }}
{{- with .rawMediaType }}
MINISERVE_RAW_MEDIA_TYPE: {{ .rawMediaType | quote }}
{{- end }}
OVERWRITE_FILES: {{ .overwriteFiles | quote }}
{{- end }}
{{- end }}
{{- with .enable }}
MINISERVE_ENABLE_TAR: {{ .tar | quote }}
MINISERVE_ENABLE_TAR_GZ: {{ .tarGZ | quote }}
MINISERVE_ENABLE_ZIP: {{ .zip | quote }}
{{- end }}
MINISERVE_DIRS_FIRST: {{ .dirsFirst | quote }}
{{- with .title }}
MINISERVE_TITLE: {{ . | quote }}
{{- end }}
# MINISERVE_HEADER:
MINISERVE_SHOW_SYMLINK_INFO: {{ .showSymlinkInfo | quote }}
MINISERVE_HIDE_VERSION_FOOTER: {{ .hideVersionFooter | quote }}
MINISERVE_HIDE_THEME_SELECTOR: {{ .hideThemeSelector | quote }}
MINISERVE_SHOW_WGET_FOOTER: {{ .showWGETFooter | quote }}
# MINISERVE_TLS_CERT:
# MINISERVE_TLS_KEY:
MINISERVE_README: {{ .readme | quote }}
{{- end}}

View file

@ -13,8 +13,9 @@ spec:
{{- include "web-static.selectorLabels" . | nindent 6 }} {{- include "web-static.selectorLabels" . | nindent 6 }}
template: template:
metadata: metadata:
{{- with .Values.podAnnotations }}
annotations: annotations:
hash-config: "{{ toYaml .Values.data | sha256sum | trunc 32 }}"
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
labels: labels:
@ -33,8 +34,13 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "web-static.fullname" . }}
{{- with .Values.data.args }}
args: args:
{{- toYaml .Values.data.args | nindent 12 }} {{- toYaml . | nindent 12 }}
{{- end }}
ports: ports:
- name: http - name: http
containerPort: {{ .Values.service.port }} containerPort: {{ .Values.service.port }}
@ -50,8 +56,8 @@ spec:
resources: resources:
{{- toYaml .Values.resources | nindent 12 }} {{- toYaml .Values.resources | nindent 12 }}
volumeMounts: volumeMounts:
- name: "html" - name: "data"
mountPath: "/html" mountPath: "/data"
{{- with .Values.nodeSelector }} {{- with .Values.nodeSelector }}
nodeSelector: nodeSelector:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
@ -65,6 +71,15 @@ spec:
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
volumes: volumes:
- name: "html" - name: "data"
{{- if .Values.persistence.enabled }}
{{- if and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual" ) }}
hostPath: hostPath:
path: {{ .Values.data.hostPath }} path: {{ .Values.persistence.hostPath }}
{{- else }}
persistentVolumeClaim:
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ template "web-static.fullname" . }}{{- end }}
{{- end }}
{{- else }}
emptyDir: {}
{{- end }}

View file

@ -0,0 +1,50 @@
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) (not (and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual"))) -}}
---
{{- if .Values.persistence.hostPath }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Release.Namespace }}-{{ template "web-static.fullname" . }}
labels:
{{- include "web-static.labels" . | nindent 4 }}
{{- if .Values.persistence.annotations }}
annotations:
{{ toYaml .Values.persistence.annotations | indent 4 }}
{{- end }}
spec:
storageClassName: manual
capacity:
storage: {{ .Values.persistence.size | quote }}
accessModes:
- {{ .Values.persistence.accessMode | quote }}
hostPath:
path: "{{ .Values.persistence.hostPath }}"
---
{{- end }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ template "web-static.fullname" . }}
labels:
{{- include "web-static.labels" . | nindent 4 }}
{{- if .Values.persistence.annotations }}
annotations:
{{ toYaml .Values.persistence.annotations | indent 4 }}
{{- end }}
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 }}"
{{- end }}
{{- end }}
{{- if .Values.persistence.hostPath }}
volumeName: {{ template "web-static.fullname" . }}
{{- end }}
{{- end -}}

View file

@ -15,14 +15,89 @@ nameOverride: ""
fullnameOverride: "" fullnameOverride: ""
data: data:
args: # -- Which path to serve
- "--index" path: "/data"
- "index.html" # -- Be verbose, includes emitting access logs
- "-F" verbose: false
- "-D" # -- Normally, when miniserve serves a directory, it creates a listing for that directory. However, if a directory contains this file, miniserve will serve that file instead.
- "-l" index: "index.html"
- "/html" # -- Activate SPA (Single Page Application) mode
hostPath: "/tmp/a" spa: false
# -- Activate Pretty URLs mode
prettyURLs: false
# -- Set authentication. Currently supported formats: username:password, username:sha256:hash,
# username:sha512:hash (e.g. joe:123,
# joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3)
auth: ""
# -- Use a specific route prefix
routePrefix: ""
# -- Hide symlinks in listing and prevent them from being followed
noSymlinks: false
# -- Show hidden files
hidden: false
# -- Default color scheme
colorScheme: "squirrel"
# -- Default color scheme
colorSchemeDark: "archlinux"
# -- Enable QR code display
qrcode: false
upload:
# -- Enable file uploading (and optionally specify for which directory)
allowedDir: ""
# -- Enable creating directories
mkdir: false
# -- Specify uploadable media types: possible values image, audio, video
mediaType: ""
# -- Directly specify the uploadable media type expression
rawMediaType: ""
# -- Enable overriding existing files during file upload
overwriteFiles: false
enable:
# -- Enable uncompressed tar archive generation
tar: false
# -- Enable gz-compressed tar archive generation
tarGZ: false
# -- Enable zip archive generation
# WARNING: Zipping large directories can result in out-of-memory exception because zip generation is done in memory and cannot be sent on the fly
zip: false
# -- List directories first
dirsFirst: true
# -- Shown instead of host in page title and heading
title: ""
# -- Visualize symlinks in directory listing
showSymlinkInfo: false
# -- Hide version footer
hideVersionFooter: true
# -- Hide theme selector
hideThemeSelector: false
# -- If enabled, display a wget command to recursively download the current directory
showWGETFooter: true
# -- Enable README.md rendering in directories
readme: false
# -- used for commandline flags
args: []
persistence:
enabled: false
annotations: {}
## 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: "-"
## A manually managed Persistent Volume and Claim
## Requires persistence.enabled: true
## If defined, PVC must be created manually before volume will be bound
# existingClaim:
## use container hostPatch or an PV if you set storageClass to manual
# hostPath:
accessMode: ReadWriteOnce
size: 1Gi
serviceAccount: serviceAccount:
# Specifies whether a service account should be created # Specifies whether a service account should be created