From ce9718b8875675ddc74c556fcccc980577f784f1 Mon Sep 17 00:00:00 2001 From: Yuki Seino Date: Thu, 18 Jul 2024 20:42:41 +0900 Subject: [PATCH] add minio. --- charts/neon-minio/.helmignore | 23 +++++ charts/neon-minio/Chart.yaml | 10 ++ charts/neon-minio/templates/_helpers.tpl | 62 ++++++++++++ charts/neon-minio/templates/deployment.yaml | 94 ++++++++++++++++++ .../neon-minio/templates/extra-manifests.yaml | 4 + charts/neon-minio/templates/job.yaml | 26 +++++ charts/neon-minio/templates/service.yaml | 24 +++++ .../neon-minio/templates/serviceaccount.yaml | 12 +++ charts/neon-minio/values.yaml | 95 +++++++++++++++++++ 9 files changed, 350 insertions(+) create mode 100644 charts/neon-minio/.helmignore create mode 100644 charts/neon-minio/Chart.yaml create mode 100644 charts/neon-minio/templates/_helpers.tpl create mode 100644 charts/neon-minio/templates/deployment.yaml create mode 100644 charts/neon-minio/templates/extra-manifests.yaml create mode 100644 charts/neon-minio/templates/job.yaml create mode 100644 charts/neon-minio/templates/service.yaml create mode 100644 charts/neon-minio/templates/serviceaccount.yaml create mode 100644 charts/neon-minio/values.yaml diff --git a/charts/neon-minio/.helmignore b/charts/neon-minio/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/neon-minio/.helmignore @@ -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/ diff --git a/charts/neon-minio/Chart.yaml b/charts/neon-minio/Chart.yaml new file mode 100644 index 0000000..9d90bc3 --- /dev/null +++ b/charts/neon-minio/Chart.yaml @@ -0,0 +1,10 @@ +apiVersion: v2 +name: neon-minio +description: Neon MinIO +type: application +version: 1.0.0 +appVersion: "0.1.0" +kubeVersion: "^1.18.x-x" +home: https://neon.tech +sources: + - https://github.com/neondatabase/neon diff --git a/charts/neon-minio/templates/_helpers.tpl b/charts/neon-minio/templates/_helpers.tpl new file mode 100644 index 0000000..a3bd0c8 --- /dev/null +++ b/charts/neon-minio/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "neon-minio.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 "neon-minio.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 }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "neon-minio.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common for Service and Deployment labels +*/}} +{{- define "neon-minio.labels" -}} +helm.sh/chart: {{ include "neon-minio.chart" . }} +{{ include "neon-minio.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "neon-minio.selectorLabels" -}} +app.kubernetes.io/name: {{ include "neon-minio.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "neon-minio.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "neon-minio.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/neon-minio/templates/deployment.yaml b/charts/neon-minio/templates/deployment.yaml new file mode 100644 index 0000000..3854c1e --- /dev/null +++ b/charts/neon-minio/templates/deployment.yaml @@ -0,0 +1,94 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "neon-minio.fullname" . }} + labels: + {{- include "neon-minio.labels" . | nindent 4 }} +spec: + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + replicas: 1 + # Which pods the Deployment is managing (duplicates template.metadata.labels). + selector: + matchLabels: + {{- include "neon-minio.selectorLabels" . | nindent 6 }} + # Pod template. + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + # Labels set on created pods. + labels: + {{- include "neon-minio.selectorLabels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "neon-minio.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ["minio"] + args: ["server", "/data", "--address", ":{{ .Values.service.port }}", "--console-address", ":{{ .Values.service.httpPort }}"] + {{- if .Values.settings }} + env: + - name: MINIO_ROOT_PASSWORD + value: {{ .Values.settings.accessKey.rootPassword }} + - name: MINIO_ROOT_USER + value: {{ .Values.settings.accessKey.rootUser }} + {{- end }} + ports: + - name: minio + containerPort: {{ .Values.service.port }} + protocol: TCP + - name: console + containerPort: {{ .Values.service.httpPort }} + protocol: TCP + startupProbe: + httpGet: + path: /minio/health/live + port: minio + initialDelaySeconds: 10 + timeoutSeconds: 5 + periodSeconds: 10 + failureThreshold: 30 + livenessProbe: + httpGet: + path: /minio/health/live + port: minio + periodSeconds: 15 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: /minio/health/ready + port: minio + periodSeconds: 15 + timeoutSeconds: 10 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/neon-minio/templates/extra-manifests.yaml b/charts/neon-minio/templates/extra-manifests.yaml new file mode 100644 index 0000000..0e5456b --- /dev/null +++ b/charts/neon-minio/templates/extra-manifests.yaml @@ -0,0 +1,4 @@ +{{- range .Values.extraManifests }} +--- +{{ tpl (toYaml .) $ }} +{{- end }} diff --git a/charts/neon-minio/templates/job.yaml b/charts/neon-minio/templates/job.yaml new file mode 100644 index 0000000..1c7ce37 --- /dev/null +++ b/charts/neon-minio/templates/job.yaml @@ -0,0 +1,26 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ printf "%s-%s" (include "neon-minio.fullname" .) "create-buckets" | trunc 63 | trimSuffix "-" }} +spec: + template: + spec: + containers: + - name: minio-mc + image: minio/mc + env: + - name: MINIO_ROOT_USER + value: {{ .Values.settings.accessKey.rootUser }} + - name: MINIO_ROOT_PASSWORD + value: {{ .Values.settings.accessKey.rootPassword }} + - name: MINIO_URL + value: {{ printf "http://%s:%d" ( include "neon-minio.fullname" .) (int .Values.service.port) }} + command: + - "/bin/sh" + - "-c" + - | + until (/usr/bin/mc alias set minio ${MINIO_URL} ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}) do + echo 'Waiting to start minio...' && sleep 1; + done; + /usr/bin/mc mb minio/neon --region=eu-north-1; + restartPolicy: OnFailure \ No newline at end of file diff --git a/charts/neon-minio/templates/service.yaml b/charts/neon-minio/templates/service.yaml new file mode 100644 index 0000000..4651e66 --- /dev/null +++ b/charts/neon-minio/templates/service.yaml @@ -0,0 +1,24 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "neon-minio.fullname" . }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} + labels: + {{- include "neon-minio.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + ports: + - port: {{ .Values.service.port }} + targetPort: minio + protocol: TCP + name: minio + - port: {{ .Values.service.httpPort }} + targetPort: console + protocol: TCP + name: console + selector: + {{- include "neon-minio.selectorLabels" . | nindent 4 }} diff --git a/charts/neon-minio/templates/serviceaccount.yaml b/charts/neon-minio/templates/serviceaccount.yaml new file mode 100644 index 0000000..8be3fdd --- /dev/null +++ b/charts/neon-minio/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "neon-minio.serviceAccountName" . }} + labels: + {{- include "neon-minio.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/neon-minio/values.yaml b/charts/neon-minio/values.yaml new file mode 100644 index 0000000..1453a02 --- /dev/null +++ b/charts/neon-minio/values.yaml @@ -0,0 +1,95 @@ +# Default values for neon-minio. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + # -- minio image repository + repository: quay.io/minio/minio + # -- image pull policy + pullPolicy: Always + # -- Overrides the image tag whose default is the chart appVersion. + tag: "RELEASE.2022-10-20T00-55-09Z" + +# -- Specify docker-registry secret names as an array +imagePullSecrets: [] + +# -- String to partially override neon-minio.fullname template (will maintain the release name) +nameOverride: "" +# -- String to fully override neon-minio.fullname template +fullnameOverride: "" + +# Neon broker settings +settings: + # -- Minio access key + accessKey: + rootUser: "minio" + rootPassword: "password" + + +serviceAccount: + # serviceAccount.create - Specifies whether a service account should be created + create: true + # serviceAccount.annotations -- Annotations to add to the service account + annotations: {} + # serviceAccount.name - The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# -- Annotations for neon-storage-broker pods +podAnnotations: {} + +# -- Additional labels for neon-storage-broker pods +podLabels: {} + # neon_service: minio + # neon_env: staging + # neon_region: us-west-1 + # neon_region_slug: virginia + +# -- neon-storage-broker's pods Security Context +podSecurityContext: {} + # fsGroup: 2000 + +# -- neon-storage-broker's containers Security Context +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + # service.annotations -- Annotations to add to the service + annotations: {} + type: ClusterIP + # service.port -- minio listen port + port: 9000 + httpPort: 9001 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # + # resources.limits -- The resources limits for the container + # resources.requests The requested resources for the container + # + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# -- Node labels for pod assignment. +nodeSelector: {} + +# -- Tolerations for pod assignment. +tolerations: [] + +# -- Affinity for pod assignment +affinity: {} + +# -- Additional manifests that are created with the chart +extraManifests: []