Skip to content

Commit

Permalink
Merge pull request #3 from kamu-data/minio-devel
Browse files Browse the repository at this point in the history
Add minio-devel chart
  • Loading branch information
cutwater authored Oct 26, 2023
2 parents ea1103d + ad80cce commit d198189
Show file tree
Hide file tree
Showing 13 changed files with 475 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/minio-devel/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions charts/minio-devel/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: minio-devel
description: Local development minio installation
type: application
version: 0.1.1
appVersion: "RELEASE.2023-10-25T06-33-25Z"
17 changes: 17 additions & 0 deletions charts/minio-devel/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Chart: {{ .Chart.Version }}

Get the application URL by running these commands:
{{ if .Values.ingress.enabled }}
{{- if .Values.ingress.api.host }}
API: http://{{ .Values.ingress.api.host }}
{{- end }}
{{- if .Values.ingress.console.host }}
Console: http://{{ .Values.ingress.console.host }}
{{- end }}
{{- else if (eq .Values.service.type "NodePort") }}
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
export API_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "minio-devel.fullname" . }})
export CONSOLE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[1].nodePort}" services {{ include "minio-devel.fullname" . }})
echo "API: http://$NODE_IP:$API_PORT"
echo "Console: http://$NODE_IP:$CONSOLE_PORT"
{{- end }}
63 changes: 63 additions & 0 deletions charts/minio-devel/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "minio-devel.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 "minio-devel.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 }}

{{/*
Selector labels
*/}}
{{- define "minio-devel.selectorLabels" -}}
app.kubernetes.io/name: {{ include "minio-devel.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "minio-devel.secretName" -}}
{{- if .Values.auth.existingSecret }}
{{- .Values.auth.existingSecret }}
{{- else }}
{{- printf "%s-creds" (include "minio-devel.fullname" .) }}
{{- end }}
{{- end }}

{{- define "minio-devel.generateRootPassword" -}}
{{- if .Values.auth.rootPassword }}
{{- .Values.auth.rootPassword }}
{{- else }}
{{- $secret := (lookup "v1" "Secret" .Release.Namespace (include "minio-devel.secretName" .)).data }}
{{- if $secret }}
{{- get $secret "root_password" | b64dec }}
{{- else }}
{{- randAlphaNum 16 }}
{{- end }}
{{- end }}
{{- end }}

{{- define "minio-devel.image" -}}
{{- $sep := ":" -}}
{{- $tag := default .Values.image.tag .Chart.AppVersion -}}
{{- if .Values.image.digest -}}
{{- $sep = "@" -}}
{{- $tag = .Values.image.digest -}}
{{- end -}}
{{- printf "%s%s%s" .Values.image.repository $sep $tag -}}
{{- end -}}
86 changes: 86 additions & 0 deletions charts/minio-devel/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "minio-devel.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
{{- include "minio-devel.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
template:
metadata:
labels:
{{- include "minio-devel.selectorLabels" . | nindent 8 }}
annotations:
{{- if (not .Values.auth.existingSecret) }}
checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
{{- end }}
spec:
enableServiceLinks: false
{{- with .Values.image.pullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: {{ include "minio-devel.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- server
- --console-address
- :9090
- /data
env:
- name: MINIO_ROOT_USER
valueFrom:
secretKeyRef:
name: {{ include "minio-devel.secretName" . }}
key: root_user
- name: MINIO_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "minio-devel.secretName" . }}
key: root_password
ports:
- name: api
containerPort: 9000
- name: console
containerPort: 9090
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: data
mountPath: /data
livenessProbe:
httpGet:
path: /minio/health/live
port: api
scheme: HTTP
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
readinessProbe:
httpGet:
path: /minio/health/ready
port: api
scheme: HTTP
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- if .Values.securityContext.enabled }}
securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
volumes:
- name: data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ include "minio-devel.fullname" . }}
{{- else }}
emptyDir: {}
{{- end }}
35 changes: 35 additions & 0 deletions charts/minio-devel/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "minio-devel.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ $fullName }}
namespace: {{ .Release.Namespace }}
spec:
ingressClassName: {{ .Values.ingress.className }}
rules:
{{- if .Values.ingress.api }}
- host: {{ .Values.ingress.api.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
name: api
{{- end }}
{{- if .Values.ingress.console }}
- host: {{ .Values.ingress.console.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
name: console
{{- end }}
{{- end }}
80 changes: 80 additions & 0 deletions charts/minio-devel/templates/job-provisioning.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{{- if .Values.provisioning.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ printf "%s-provisioning" (include "minio-devel.fullname" .) }}
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation
spec:
template:
spec:
enableServiceLinks: false
initContainers:
- name: wait-until-ready
image: {{ include "minio-devel.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/bash
- -c
- |
set -euxo pipefail
namespace="{{ .Release.Namespace }}"
minio_service="{{ include "minio-devel.fullname" . }}"
minio_port="{{ .Values.service.ports.api }}"
minio_url="http://${minio_service}.${namespace}.svc.cluster.local:${minio_port}"
until curl -sSf "${minio_url}/minio/health/ready"; do
sleep 10
done
resources:
{{- toYaml .Values.provisioning.resources | nindent 12 }}
containers:
- name: provision
image: {{ include "minio-devel.image" . | quote }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /bin/bash
- -c
- |
set -euo pipefail
namespace="{{ .Release.Namespace }}"
minio_service="{{ include "minio-devel.fullname" . }}"
minio_port="{{ .Values.service.ports.api }}"
minio_url="http://${minio_service}.${namespace}.svc.cluster.local:${minio_port}"
mc alias set minio "$minio_url" "$MINIO_ROOT_USER" "$MINIO_ROOT_PASSWORD"
{{- range $bucket := .Values.provisioning.buckets }}
mc mb --ignore-existing minio/{{ $bucket.name }}
{{- end }}
env:
- name: HOME
value: /var/lib/minio
- name: MINIO_ROOT_USER
valueFrom:
secretKeyRef:
name: {{ include "minio-devel.secretName" . }}
key: root_user
- name: MINIO_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "minio-devel.secretName" . }}
key: root_password
resources:
{{- toYaml .Values.provisioning.resources | nindent 12 }}
volumeMounts:
- name: home
mountPath: /var/lib/minio
restartPolicy: Never
{{- if .Values.securityContext.enabled }}
securityContext: {{- omit .Values.securityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
volumes:
- name: home
emptyDir: {}
{{- end }}
16 changes: 16 additions & 0 deletions charts/minio-devel/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "minio-devel.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
accessModes:
{{- range .Values.persistence.accessModes }}
- {{ . }}
{{- end }}
resources:
requests:
storage: {{ .Values.persistence.size }}
{{- if .Values.persistence.storageClass }}
storageClassName: {{ .Values.persistence.storageClass }}
{{- end }}
11 changes: 11 additions & 0 deletions charts/minio-devel/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if (not .Values.auth.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "minio-devel.secretName" . }}
namespace: {{ .Release.Namespace }}
type: Opaque
data:
root_user: {{ .Values.auth.rootUser | b64enc }}
root_password: {{ include "minio-devel.generateRootPassword" . | b64enc }}
{{- end }}
24 changes: 24 additions & 0 deletions charts/minio-devel/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "minio-devel.fullname" . }}
namespace: {{ .Release.Namespace }}
spec:
type: {{ .Values.service.type }}
ports:
- name: api
protocol: TCP
port: {{ .Values.service.ports.api }}
targetPort: api
{{- if (and (eq .Values.service.type "NodePort") .Values.service.nodePorts.api) }}
nodePort: {{ .Values.service.nodePorts.api }}
{{- end }}
- name: console
protocol: TCP
targetPort: console
port: {{ .Values.service.ports.console }}
{{- if (and (eq .Values.service.type "NodePort") .Values.service.nodePorts.console) }}
nodePort: {{ .Values.service.nodePorts.console }}
{{- end }}
selector:
{{- include "minio-devel.selectorLabels" . | nindent 4 }}
14 changes: 14 additions & 0 deletions charts/minio-devel/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "minio-devel.fullname" . }}-test-connection"
annotations:
"helm.sh/hook": test
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "minio-devel.fullname" . }}:{{ .Values.service.ports.api }}/minio/health/ready']
restartPolicy: Never
Loading

0 comments on commit d198189

Please sign in to comment.