init commit
This commit is contained in:
23
helm/ .helmignore
Normal file
23
helm/ .helmignore
Normal file
@@ -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
helm/Chart.yaml
Normal file
6
helm/Chart.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: mongodb
|
||||
description: A Helm chart for MongoDB
|
||||
type: application
|
||||
version: 0.1.0
|
||||
appVersion: "8.0"
|
||||
26
helm/templates/_helpers.tpl
Normal file
26
helm/templates/_helpers.tpl
Normal file
@@ -0,0 +1,26 @@
|
||||
{{- define "mongo.name" -}}
|
||||
{{- printf "%s" .Chart.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongo.name.headless" -}}
|
||||
{{- printf "%s-headless" .Chart.Name | trunc 54 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongo.name.config" -}}
|
||||
{{- printf "%s-config" .Chart.Name | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongo.name.secret" -}}
|
||||
{{- printf "%s-secret" .Chart.Name | trunc 56 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongo.name.initialize" -}}
|
||||
{{- printf "%s-initialize" .Chart.Name | trunc 52 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongo.labels" -}}
|
||||
app.kubernetes.io/name: {{ include "mongo.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
|
||||
{{- end -}}
|
||||
16
helm/templates/headless-service.yaml
Normal file
16
helm/templates/headless-service.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "mongo.name.headless" . }}
|
||||
labels:
|
||||
{{- include "mongo.labels" . | nindent 4 }}
|
||||
spec:
|
||||
clusterIP: None
|
||||
publishNotReadyAddresses: true
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.port }}
|
||||
protocol: TCP
|
||||
name: mongodb
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "mongo.name" . }}
|
||||
12
helm/templates/secret.yaml
Normal file
12
helm/templates/secret.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ include "mongo.name.secret" . }}
|
||||
labels:
|
||||
{{- include "mongo.labels" . | nindent 4 }}
|
||||
type: Opaque
|
||||
stringData:
|
||||
{{- if .Values.auth.enabled }}
|
||||
MONGO_INITDB_ROOT_PASSWORD: "{{ .Values.auth.rootPassword }}"
|
||||
MONGO_INITDB_ROOT_USERNAME: "{{ .Values.auth.rootUsername }}"
|
||||
{{- end }}
|
||||
18
helm/templates/service.yaml
Normal file
18
helm/templates/service.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "mongo.name" . }}
|
||||
labels:
|
||||
{{- include "mongo.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
{{- if and .Values.service.loadBalancerIP (ne .Values.service.loadBalancerIP "") }}
|
||||
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
|
||||
{{- end }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: {{ .Values.service.port }}
|
||||
protocol: TCP
|
||||
name: mongodb
|
||||
selector:
|
||||
app.kubernetes.io/name: {{ include "mongo.name" . }}
|
||||
78
helm/templates/statefulset.yaml
Normal file
78
helm/templates/statefulset.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ include "mongo.name" . }}
|
||||
labels:
|
||||
{{- include "mongo.labels" . | nindent 4 }}
|
||||
spec:
|
||||
serviceName: {{ include "mongo.name" . }}
|
||||
replicas: {{ .Values.statefulset.replicas }}
|
||||
podManagementPolicy: {{ .Values.statefulset.podManagementPolicy }}
|
||||
updateStrategy:
|
||||
type: {{ .Values.statefulset.updateStrategy.type }}
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: {{ include "mongo.name" . }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: {{ include "mongo.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
spec:
|
||||
{{- if .Values.securityContext.enabled }}
|
||||
securityContext:
|
||||
fsGroup: {{ .Values.securityContext.fsGroup }}
|
||||
runAsUser: {{ .Values.securityContext.runAsUser }}
|
||||
runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
|
||||
{{- end }}
|
||||
containers:
|
||||
- name: mongo
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
args:
|
||||
{{- if .Values.extraCommandLineArgs }}
|
||||
- "{{ .Values.extraCommandLineArgs }}"
|
||||
{{- end }}
|
||||
ports:
|
||||
- containerPort: {{ .Values.service.port }}
|
||||
name: mongodb
|
||||
envFrom:
|
||||
- secretRef:
|
||||
name: {{ include "mongo.name.secret" . }}
|
||||
volumeMounts:
|
||||
- name: data
|
||||
mountPath: /data/db
|
||||
{{- if .Values.readinessProbe.enabled }}
|
||||
readinessProbe:
|
||||
exec:
|
||||
command: {{ toJson .Values.healthCheck.command }}
|
||||
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
||||
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
||||
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
||||
{{- end }}
|
||||
{{- if .Values.livenessProbe.enabled }}
|
||||
livenessProbe:
|
||||
exec:
|
||||
command: {{ toJson .Values.healthCheck.command }}
|
||||
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
||||
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
||||
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
||||
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
||||
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
||||
{{- end }}
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 10 }}
|
||||
volumeClaimTemplates:
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes:
|
||||
{{- toYaml .Values.persistence.accessModes | nindent 10 }}
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .Values.persistence.size }}
|
||||
{{- if .Values.persistence.storageClass }}
|
||||
storageClassName: {{ .Values.persistence.storageClass }}
|
||||
{{- end }}
|
||||
71
helm/values.yaml
Normal file
71
helm/values.yaml
Normal file
@@ -0,0 +1,71 @@
|
||||
image:
|
||||
repository: mongo
|
||||
tag: "8.0"
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
|
||||
statefulset:
|
||||
replicas: 1
|
||||
podManagementPolicy: OrderedReady
|
||||
updateStrategy:
|
||||
type: RollingUpdate
|
||||
|
||||
|
||||
auth:
|
||||
enabled: true
|
||||
rootUsername: root
|
||||
rootPassword: verySecurePassword
|
||||
|
||||
persistence:
|
||||
storageClass:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
size: 8Gi
|
||||
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 27017
|
||||
headless:
|
||||
enabled: true
|
||||
name: "{{ include \"mongo.name.headless\" . }}"
|
||||
|
||||
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
memory: 1Gi
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
|
||||
|
||||
livenessProbe:
|
||||
enabled: true
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 5
|
||||
successThreshold: 1
|
||||
|
||||
readinessProbe:
|
||||
enabled: true
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 5
|
||||
failureThreshold: 3
|
||||
successThreshold: 1
|
||||
|
||||
|
||||
securityContext:
|
||||
enabled: true
|
||||
fsGroup: 65534
|
||||
runAsUser: 65534
|
||||
runAsNonRoot: true
|
||||
|
||||
|
||||
extraCommandLineArgs: ""
|
||||
|
||||
|
||||
healthCheck:
|
||||
command: ["/bin/sh", "-c", "mongosh --quiet --eval 'db.runCommand({ ping: 1 })' --username ${MONGO_INITDB_ROOT_USERNAME} --password ${MONGO_INITDB_ROOT_PASSWORD} --authenticationDatabase admin || exit 1" ]
|
||||
Reference in New Issue
Block a user