diff --git a/web-static/Chart.yaml b/web-static/Chart.yaml index a979f73..ca1a6fd 100644 --- a/web-static/Chart.yaml +++ b/web-static/Chart.yaml @@ -2,6 +2,6 @@ apiVersion: v2 name: web-static description: A Helm chart for Kubernetes type: application -version: 0.1.0 +version: 0.2.0 appVersion: "0.24.0" diff --git a/web-static/templates/configmap.yaml b/web-static/templates/configmap.yaml new file mode 100644 index 0000000..0091087 --- /dev/null +++ b/web-static/templates/configmap.yaml @@ -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}} diff --git a/web-static/templates/deployment.yaml b/web-static/templates/deployment.yaml index 7688171..10ce65d 100644 --- a/web-static/templates/deployment.yaml +++ b/web-static/templates/deployment.yaml @@ -13,10 +13,11 @@ spec: {{- include "web-static.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + hash-config: "{{ toYaml .Values.data | sha256sum | trunc 32 }}" + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} labels: {{- include "web-static.selectorLabels" . | nindent 8 }} spec: @@ -33,8 +34,13 @@ spec: {{- toYaml .Values.securityContext | nindent 12 }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - configMapRef: + name: {{ include "web-static.fullname" . }} + {{- with .Values.data.args }} args: - {{- toYaml .Values.data.args | nindent 12 }} + {{- toYaml . | nindent 12 }} + {{- end }} ports: - name: http containerPort: {{ .Values.service.port }} @@ -50,8 +56,8 @@ spec: resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: - - name: "html" - mountPath: "/html" + - name: "data" + mountPath: "/data" {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} @@ -65,6 +71,15 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} volumes: - - name: "html" + - name: "data" + {{- if .Values.persistence.enabled }} + {{- if and .Values.persistence.hostPath (ne .Values.persistence.storageClass "manual" ) }} 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 }} diff --git a/web-static/templates/pvc.yaml b/web-static/templates/pvc.yaml new file mode 100644 index 0000000..af3dd02 --- /dev/null +++ b/web-static/templates/pvc.yaml @@ -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 -}} \ No newline at end of file diff --git a/web-static/values.yaml b/web-static/values.yaml index 94d5370..47bb9f3 100644 --- a/web-static/values.yaml +++ b/web-static/values.yaml @@ -15,14 +15,89 @@ nameOverride: "" fullnameOverride: "" data: - args: - - "--index" - - "index.html" - - "-F" - - "-D" - - "-l" - - "/html" - hostPath: "/tmp/a" + # -- Which path to serve + path: "/data" + # -- Be verbose, includes emitting access logs + verbose: false + # -- 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. + index: "index.html" + # -- Activate SPA (Single Page Application) mode + 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: + ## 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: # Specifies whether a service account should be created