ansible role update

This commit is contained in:
havelight-ee
2022-12-09 13:38:44 +09:00
parent 8391ca915d
commit 3af7e034fc
890 changed files with 79234 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
{{- if .Values.mongos.config }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.names.fullname" . }}-mongos
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: mongos
data:
mongodb.conf: |-
{{- include "common.tplvalues.render" (dict "value" .Values.mongos.config "context" $) | nindent 4 }}
{{- end }}

View File

@@ -0,0 +1,319 @@
apiVersion: {{ if .Values.mongos.useStatefulSet }}{{ include "common.capabilities.statefulset.apiVersion" . }}{{- else }}{{ include "common.capabilities.deployment.apiVersion" . }}{{- end }}
kind: {{ if .Values.mongos.useStatefulSet }}StatefulSet{{- else }}Deployment{{- end }}
metadata:
name: {{ include "common.names.fullname" . }}-mongos
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: mongos
spec:
{{- if .Values.mongos.useStatefulSet }}
serviceName: {{ include "mongodb-sharded.serviceName" . }}
podManagementPolicy: {{ .Values.mongos.podManagementPolicy }}
updateStrategy:
{{- else }}
strategy:
{{- end }}
{{- toYaml .Values.mongos.updateStrategy | nindent 4 }}
replicas: {{ .Values.mongos.replicas }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: mongos
template:
metadata:
labels: {{- include "common.labels.standard" . | nindent 8 }}
app.kubernetes.io/component: mongos
{{- if .Values.mongos.podLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.mongos.podLabels "context" $ ) | nindent 8 }}
{{- end }}
{{- if or .Values.common.podAnnotations .Values.mongos.podAnnotations .Values.metrics.enabled }}
annotations:
{{- if .Values.common.podAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.common.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.podAnnotations }}
{{- include "common.tplvalues.render" ( dict "value" .Values.mongos.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- if .Values.metrics.enabled }}
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
spec:
{{- if .Values.common.schedulerName }}
schedulerName: {{ .Values.common.schedulerName | quote }}
{{- end }}
serviceAccountName: {{ include "mongodb-sharded.serviceAccountName" (dict "value" $.Values.mongos.serviceAccount "context" $) }}
{{- if .Values.mongos.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.affinity }}
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.mongos.podAffinityPreset "component" "mongos" "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.mongos.podAntiAffinityPreset "component" "mongos" "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.mongos.nodeAffinityPreset.type "key" .Values.mongos.nodeAffinityPreset.key "values" .Values.mongos.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.mongos.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.tolerations "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.mongos.priorityClassName }}
priorityClassName: {{ .Values.mongos.priorityClassName | quote }}
{{- end }}
{{- if .Values.securityContext.enabled }}
securityContext:
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- end }}
{{- include "mongodb-sharded.imagePullSecrets" . | nindent 6 }}
{{- if or $.Values.mongos.initContainers $.Values.common.initContainers }}
initContainers:
{{- with $.Values.mongos.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.initContainers }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- end }}
containers:
- name: mongos
image: {{ include "mongodb-sharded.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env:
- name: MONGODB_ENABLE_NUMACTL
value: {{ ternary "yes" "no" $.Values.common.mongodbEnableNumactl | quote }}
- name: BITNAMI_DEBUG
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
- name: MONGODB_SHARDING_MODE
value: "mongos"
- name: MONGODB_MAX_TIMEOUT
value: {{ .Values.common.mongodbMaxWaitTimeout | quote }}
{{- if .Values.usePasswordFile }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
- name: MONGODB_REPLICA_SET_KEY_FILE
value: "/bitnami/mongodb/secrets/mongodb-replica-set-key"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
- name: MONGODB_REPLICA_SET_KEY
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-replica-set-key
{{- end }}
- name: MONGODB_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
{{- if .Values.common.useHostnames }}
- name: MONGODB_ADVERTISED_HOSTNAME
value: "$(MONGODB_POD_NAME)"
{{- end }}
- name: MONGODB_PORT_NUMBER
value: {{ $.Values.common.containerPorts.mongo | quote }}
- name: MONGODB_CFG_PRIMARY_HOST
value: {{ include "mongodb-sharded.configServer.primaryHost" . }}
- name: MONGODB_CFG_REPLICA_SET_NAME
value: {{ include "mongodb-sharded.configServer.rsName" . }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG
{{- if .Values.mongodbDisableSystemLog }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_IPV6
{{- if .Values.common.mongodbEnableIPv6 }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
- name: MONGODB_ENABLE_DIRECTORY_PER_DB
{{- if .Values.common.mongodbDirectoryPerDB }}
value: "yes"
{{- else }}
value: "no"
{{- end }}
{{- if .Values.mongos.mongodbExtraFlags }}
- name: MONGODB_EXTRA_FLAGS
value: {{ .Values.mongos.mongodbExtraFlags | join " " | quote }}
{{- end }}
{{- if .Values.common.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if .Values.mongos.extraEnvVars }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraEnvVars "context" $ ) | nindent 12 }}
{{- end }}
{{- if or .Values.common.extraEnvVarsCM .Values.common.extraEnvVarsSecret .Values.mongos.extraEnvVarsCM .Values.mongos.extraEnvVarsSecret }}
envFrom:
{{- if .Values.common.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.common.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.common.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- if .Values.configsvr.extraEnvVarsCM }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.mongos.extraEnvVarsCM "context" $ ) }}
{{- end }}
{{- if .Values.mongos.extraEnvVarsSecret }}
- configMapRef:
name: {{ include "common.tplvalues.render" ( dict "value" .Values.mongos.extraEnvVarsSecret "context" $ ) }}
{{- end }}
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- end }}
ports:
- name: mongodb
containerPort: {{ $.Values.common.containerPorts.mongo }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
exec:
command:
- mongo
- --disableImplicitSessions
- --eval
- "db.adminCommand('ping')"
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
exec:
command:
- mongo
- --disableImplicitSessions
- --eval
- "db.adminCommand('ping')"
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
{{- end }}
{{- end }}
volumeMounts:
{{- if .Values.usePasswordFile }}
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
{{- if or .Values.mongos.config .Values.mongos.configCM }}
- name: config
mountPath: /bitnami/mongodb/conf/
{{- end }}
{{- if $.Values.common.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
{{- if $.Values.mongos.extraVolumeMounts }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraVolumeMounts "context" $ ) | nindent 12 }}
{{- end }}
resources: {{- toYaml .Values.mongos.resources | nindent 12 }}
{{- if .Values.metrics.enabled }}
- name: metrics
image: {{ include "mongodb-sharded.metrics.image" . }}
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
{{- if .Values.securityContext.enabled }}
securityContext:
runAsNonRoot: {{ .Values.securityContext.runAsNonRoot }}
runAsUser: {{ .Values.securityContext.runAsUser }}
{{- end }}
env:
{{- if .Values.usePasswordFile }}
- name: MONGODB_ROOT_PASSWORD_FILE
value: "/bitnami/mongodb/secrets/mongodb-root-password"
{{- else }}
- name: MONGODB_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "mongodb-sharded.secret" . }}
key: mongodb-root-password
{{- end }}
{{- if .Values.diagnosticMode.enabled }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
{{- else }}
command:
- sh
- -ec
- |-
#!/bin/sh
{{- if .Values.usePasswordFile }}
export MONGODB_ROOT_PASSWORD="$(cat "${MONGODB_ROOT_PASSWORD_FILE}")"
{{- end }}
/bin/mongodb_exporter --web.listen-address ":{{ .Values.metrics.containerPort }}" --mongodb.uri mongodb://root:`echo $MONGODB_ROOT_PASSWORD | sed -r "s/@/%40/g;s/:/%3A/g"`@localhost:{{ .Values.service.port }}/admin{{ ternary "?ssl=true" "" $.Values.metrics.useTLS }} {{ .Values.metrics.extraArgs }}
{{- end }}
{{- if .Values.usePasswordFile }}
volumeMounts:
- name: secrets
mountPath: /bitnami/mongodb/secrets/
{{- end }}
ports:
- name: metrics
containerPort: {{ .Values.metrics.containerPort }}
{{- if not .Values.diagnosticMode.enabled }}
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /metrics
port: metrics
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
{{- end }}
{{- end }}
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
{{- end }}
{{- with $.Values.mongos.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
{{- with $.Values.common.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.usePasswordFile }}
- name: secrets
secret:
secretName: {{ include "mongodb-sharded.secret" . }}
{{- end }}
{{- if or .Values.mongos.config .Values.mongos.configCM }}
- name: config
configMap:
name: {{ include "mongodb-sharded.mongos.configCM" . }}
{{- end }}
{{- if $.Values.common.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.common.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.mongos.extraVolumes }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.mongos.extraVolumes "context" $ ) | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,18 @@
{{- if .Values.mongos.pdb.enabled -}}
kind: PodDisruptionBudget
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
metadata:
name: {{ include "common.names.fullname" . }}-mongos
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: mongos
spec:
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: mongos
{{- if .Values.mongos.pdb.minAvailable }}
minAvailable: {{ .Values.mongos.pdb.minAvailable | int }}
{{- end }}
{{- if .Values.mongos.pdb.maxUnavailable }}
maxUnavailable: {{ .Values.mongos.pdb.maxUnavailable | int }}
{{- end }}
{{- end -}}

View File

@@ -0,0 +1,32 @@
{{- if and .Values.metrics.enabled .Values.metrics.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
name: {{ include "common.names.fullname" . }}-mongos
{{- if .Values.metrics.podMonitor.namespace }}
namespace: {{ .Values.metrics.podMonitor.namespace }}
{{- else }}
namespace: {{ .Release.Namespace }}
{{- end }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: mongos
{{- if .Values.metrics.podMonitor.additionalLabels }}
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }}
{{- end }}
spec:
podMetricsEndpoints:
- port: metrics
path: /metrics
{{- if .Values.metrics.podMonitor.interval }}
interval: {{ .Values.metrics.podMonitor.interval }}
{{- end }}
{{- if .Values.metrics.podMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.metrics.podMonitor.scrapeTimeout }}
{{- end }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
selector:
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
app.kubernetes.io/component: mongos
{{- end }}

View File

@@ -0,0 +1,48 @@
{{- if and .Values.mongos.useStatefulSet .Values.mongos.servicePerReplica.enabled }}
{{- range $i := until (.Values.mongos.replicas | int) }}
{{- $context := deepCopy $ | merge (dict "index" $i) }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "mongodb-sharded.serviceName" $ }}-{{ $i }}
labels: {{ include "common.labels.standard" $ | nindent 4 }}
app.kubernetes.io/component: mongos
annotations: {{- include "common.tplvalues.render" (dict "value" $.Values.mongos.servicePerReplica.annotations "context" $context) | nindent 4 }}
spec:
type: {{ $.Values.mongos.servicePerReplica.type }}
{{- if and $.Values.mongos.servicePerReplica.loadBalancerIP (eq $.Values.mongos.servicePerReplica.type "LoadBalancer") }}
loadBalancerIP: {{ $.Values.mongos.servicePerReplica.loadBalancerIP }}
{{- end }}
{{- if and (eq $.Values.mongos.servicePerReplica.type "LoadBalancer") $.Values.mongos.servicePerReplica.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ with $.Values.mongos.servicePerReplica.loadBalancerSourceRanges }}
{{ include "common.tplvalues.render" . | nindent 4 }}
{{- end }}
{{- end }}
{{- if and (eq $.Values.mongos.servicePerReplica.type "ClusterIP") $.Values.mongos.servicePerReplica.clusterIP }}
clusterIP: {{ $.Values.mongos.servicePerReplica.clusterIP }}
{{- end }}
ports:
- name: mongodb
port: {{ $.Values.mongos.servicePerReplica.port }}
targetPort: mongodb
{{- if $.Values.mongos.servicePerReplica.nodePort }}
nodePort: {{ $.Values.mongos.servicePerReplica.nodePort }}
{{- else if eq $.Values.mongos.servicePerReplica.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if $.Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- end }}
{{- if $.Values.mongos.servicePerReplica.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" $.Values.mongos.servicePerReplica.extraPorts "context" $context) | nindent 4 }}
{{- end }}
selector: {{ include "common.labels.matchLabels" $ | nindent 4 }}
app.kubernetes.io/component: mongos
statefulset.kubernetes.io/pod-name: {{ include "common.names.fullname" $ }}-mongos-{{ $i }}
sessionAffinity: {{ default "None" $.Values.mongos.servicePerReplica.sessionAffinity }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,41 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "mongodb-sharded.serviceName" . }}
labels: {{ include "common.labels.standard" . | nindent 4 }}
app.kubernetes.io/component: mongos
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.service.annotations "context" $ ) | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }}
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{ with .Values.service.loadBalancerSourceRanges }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- end }}
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
clusterIP: {{ .Values.service.clusterIP }}
{{- end }}
ports:
- name: mongodb
port: {{ .Values.service.port }}
targetPort: mongodb
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- else if eq .Values.service.type "ClusterIP" }}
nodePort: null
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: 9216
targetPort: metrics
{{- end }}
{{- if .Values.service.extraPorts }}
{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
{{- end }}
selector: {{ include "common.labels.matchLabels" . | nindent 4 }}
app.kubernetes.io/component: mongos
sessionAffinity: {{ default "None" .Values.service.sessionAffinity }}