-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip(charts): mapcache uses a statefulset when using local cache [pack…
… mapcache]
- Loading branch information
1 parent
51d4fad
commit 5311d99
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
{{- if hasKey .Values "localCache" }} | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: {{ include "common.names.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: {{- include "common.labels.standard" . | nindent 4 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }} | ||
{{- end }} | ||
{{- if .Values.commonAnnotations }} | ||
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} | ||
{{- end }} | ||
spec: | ||
replicas: {{ .Values.replicaCount }} | ||
serviceName: {{ include "common.names.fullname" . }} | ||
selector: | ||
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
labels: {{- include "common.labels.standard" . | nindent 8 }} | ||
{{- if .Values.commonLabels }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
initContainers: | ||
{{- if .Values.envsubstConfig }} | ||
{{- include "common.envsubstConfig.renderInitContainer" ( dict "args" .Values.envsubstConfig "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
# seed local caches | ||
# script runs with root privileges, so we fix permissions after that | ||
{{- if .Values.localCache.seedLayers }} | ||
- name: seed-local-cache | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
command: | ||
- sh | ||
- -c | ||
- if [ $(hostname | awk -F '-' '{ print $NF }') -eq 0 ]; then for LAYER in {{ .Values.localCache.seedLayers }}; do echo "Seeding layer $LAYER ..." && mapcache_seed -c /etc/mapcache/mapcache.xml -t $LAYER -z {{ .Values.localCache.fromZ }},{{ .Values.localCache.toZ }} -n 8; done; fi | ||
volumeMounts: | ||
- mountPath: /etc/mapcache | ||
readOnly: true | ||
name: mapcache-config | ||
- mountPath: /mnt/data | ||
name: local-cache | ||
- name: rclone-local-cache | ||
image: rclone/rclone | ||
command: | ||
- sh | ||
- -c | ||
- if [ $(hostname | awk -F '-' '{ print $NF }') -eq 0 ]; then cd /cache && tar -cf /scratch/{{ .Release.Namespace }}-mapcache-local-cache.tar . && rclone copy /scratch/{{ .Release.Namespace }}-mapcache-local-cache.tar kaptain:helm-volatile --progress; else cd /cache && rclone copy kaptain:helm-volatile/{{ .Release.Namespace }}-mapcache-local-cache.tar /scratch --progress && tar xf /scratch/{{ .Release.Namespace }}-mapcache-local-cache.tar; fi | ||
volumeMounts: | ||
- mountPath: /cache | ||
name: local-cache | ||
- mountPath: /scratch | ||
name: scratch-space | ||
- mountPath: /config/rclone/rclone.conf | ||
name: rclone-config | ||
subPath: rclone.conf | ||
readOnly: true | ||
{{- end }} | ||
# fix permissions on volume where is located local cache | ||
# www-data:www-data as numeric ids is 33:33 | ||
- name: fix-local-cache-owner | ||
image: busybox | ||
command: [ 'chown', '-R', '33:33', '/cache' ] | ||
volumeMounts: | ||
- mountPath: /cache | ||
name: local-cache | ||
{{- if .Values.initContainers }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.initContainers "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
containers: | ||
- name: {{ include "common.names.name" . }} | ||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" | ||
imagePullPolicy: {{ .Values.image.pullPolicy }} | ||
env: | ||
- name: HTTP_PROXY | ||
- name: HTTPS_PROXY | ||
- name: NO_PROXY | ||
ports: | ||
- name: {{ include "common.names.name" . }} | ||
containerPort: 80 | ||
resources: | ||
{{- toYaml .Values.resources | nindent 12 }} | ||
volumeMounts: | ||
- mountPath: /etc/mapcache | ||
readOnly: true | ||
name: mapcache-config | ||
- mountPath: /mnt/data | ||
name: local-cache | ||
volumes: | ||
- name: mapcache-config | ||
{{- if .Values.envsubstConfig }} | ||
emptyDir: {} | ||
{{- else if .Values.configVolume }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.configVolume "context" $ ) | nindent 10 }} | ||
{{- end }} | ||
{{- if .Values.envsubstConfig }} | ||
{{- include "common.envsubstConfig.renderVolume" ( dict "args" .Values.envsubstConfig "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
{{- if .Values.localCache.seedLayers }} | ||
- name: rclone-config | ||
secret: | ||
secretName: {{ .Release.Namespace }}-rclone-config | ||
- name: scratch-space | ||
emptyDir: {} | ||
{{- end }} | ||
{{- if .Values.extraVolumes }} | ||
{{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumes "context" $ ) | nindent 8 }} | ||
{{- end }} | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: local-cache | ||
spec: | ||
accessModes: [ "ReadWriteOnce" ] | ||
resources: | ||
requests: | ||
storage: {{ .Values.localCache.size }} | ||
{{- end }} |