create a hook for setting up users

This commit is contained in:
Max Roby 2023-11-23 11:27:40 +01:00 committed by Chris Lu
parent d9e06d8481
commit 9ff010d15b

View file

@ -0,0 +1,90 @@
{{- if .Values.master.enabled }}
{{- if .Values.filer.s3.enabled }}
{{- if .Values.filer.s3.createUsers}}
---
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ $.Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: "{{ .Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
spec:
restartPolicy: Never
containers:
- name: post-install-job
image: {{ template "master.image" . }}
env:
- name: WEED_CLUSTER_DEFAULT
value: "sw"
- name: WEED_CLUSTER_SW_MASTER
value: "{{ template "seaweedfs.name" . }}-master.{{ .Release.Namespace }}:9333"
- name: WEED_CLUSTER_SW_FILER
value: "{{ template "seaweedfs.name" . }}-filer-client.{{ .Release.Namespace }}:8888"
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: SEAWEEDFS_FULLNAME
value: "{{ template "seaweedfs.name" . }}"
{{- range $reg, $props := $.Values.filer.s3.createUsers }}
- name: "{{ $props.secretName | upper }}-ID"
valueFrom:
secretKeyRef:
name: {{ $props.secretName }}
key: ACCESS_KEY_ID
- name: "{{ $props.secretName | upper }}-KEY"
valueFrom:
secretKeyRef:
name: {{ $props.secretName }}
key: ACCESS_SECRET_KEY
{{- end }}
command:
- "/bin/sh"
- "-ec"
- |
{{- range $reg, $props := $.Values.filer.s3.createUsers }}
exec /bin/echo \
"s3.configure --user {{ $props.name }} \
--buckets {{ $props.buckets }} \
--actions {{ $props.actions }} \
--access_key "{{ $props.secretName | upper }}-ID" \
--secret_key "{{ $props.secretName | upper }}-KEY" \
--apply true" |\
/usr/bin/weed shell
{{- end }}
ports:
- containerPort: {{ .Values.master.port }}
name: swfs-master
{{- if and .Values.global.monitoring.enabled .Values.master.metricsPort }}
- containerPort: {{ .Values.master.metricsPort }}
name: metrics
{{- end }}
- containerPort: {{ .Values.master.grpcPort }}
#name: swfs-master-grpc
{{- if .Values.master.readinessProbe.enabled }}
{{- $hostpath_exists := include "master.hostpath_exists" . -}}
{{- $existing_claims := include "master.existing_claims" . -}}
{{- end }}
{{- end }}
{{- end }}
{{- end }}