github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/mongodb/templates/clusterdefinition.yaml (about)

     1  apiVersion: apps.kubeblocks.io/v1alpha1
     2  kind: ClusterDefinition
     3  metadata:
     4    name: mongodb
     5    labels:
     6      {{- include "mongodb.labels" . | nindent 4 }}
     7  spec:
     8    type: mongodb
     9    connectionCredential:
    10      username: root
    11      password: {{ (include "mongodb.password" .) | quote  }}
    12      endpoint: "$(SVC_FQDN):$(SVC_PORT_mongodb)"
    13      host: "$(SVC_FQDN)"
    14      port: "$(SVC_PORT_mongodb)"
    15      headlessEndpoint: "$(KB_CLUSTER_COMP_NAME)-0.$(HEADLESS_SVC_FQDN):$(SVC_PORT_mongodb)"
    16      headlessHost: "$(KB_CLUSTER_COMP_NAME)-0.$(HEADLESS_SVC_FQDN)"
    17      headlessPort: "$(SVC_PORT_mongodb)"
    18    componentDefs:
    19      - name: mongodb
    20        characterType: mongodb
    21        scriptSpecs:
    22          - name: mongodb-scripts
    23            templateRef: mongodb-scripts
    24            volumeName: scripts
    25            namespace: {{ .Release.Namespace }}
    26            defaultMode: 0555
    27        configSpecs:
    28          - name: mongodb-config
    29            templateRef: mongodb5.0-config-template
    30            namespace: {{ .Release.Namespace }}
    31            volumeName: mongodb-config
    32            constraintRef: mongodb-config-constraints
    33            keys:
    34              - mongodb.conf
    35            defaultMode: 256
    36          - name: mongodb-metrics-config-new
    37            templateRef: mongodb-metrics-config-new
    38            namespace: {{ .Release.Namespace }}
    39            volumeName: mongodb-metrics-config
    40            defaultMode: 0444
    41        monitor:
    42          builtIn: false
    43          exporterConfig:
    44            scrapePath: /metrics
    45            scrapePort: 9216
    46        logConfigs:
    47          {{- range $name,$pattern := .Values.logConfigs }}
    48          - name: {{ $name }}
    49            filePathPattern: {{ $pattern }}
    50          {{- end }}
    51        workloadType: Consensus
    52        consensusSpec:
    53          leader:
    54            name: "primary"
    55            accessMode: ReadWrite
    56          followers:
    57            - name: "secondary"
    58              accessMode: Readonly
    59          updateStrategy: Serial
    60        probes:
    61          roleProbeTimeoutAfterPodsReady: 300
    62          roleProbe:
    63            failureThreshold: {{ .Values.roleProbe.failureThreshold }}
    64            periodSeconds: {{ .Values.roleProbe.periodSeconds }}
    65            timeoutSeconds: {{ .Values.roleProbe.timeoutSeconds }}
    66        switchoverSpec:
    67          withCandidate:
    68            cmdExecutorConfig:
    69              image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ default .Values.image.tag }}
    70              command:
    71                - /scripts/switchover-with-candidate.sh
    72            scriptSpecSelectors:
    73              - name: mongodb-scripts
    74          withoutCandidate:
    75            cmdExecutorConfig:
    76              image: {{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ default .Values.image.tag }}
    77              command:
    78                - /scripts/switchover-without-candidate.sh
    79            scriptSpecSelectors:
    80              - name: mongodb-scripts
    81        service:
    82          ports:
    83            - name: mongodb
    84              protocol: TCP
    85              port: 27017
    86        volumeTypes:
    87          - name: data
    88            type: data
    89        podSpec:
    90          containers:
    91            - name: mongodb
    92              ports:
    93                - name: mongodb
    94                  protocol: TCP
    95                  containerPort: 27017
    96              command:
    97                - /scripts/replicaset-setup.sh
    98              env:
    99                - name: SERVICE_PORT
   100                  value: "27017"
   101                - name: MONGODB_ROOT_USER
   102                  valueFrom:
   103                    secretKeyRef:
   104                      name: $(CONN_CREDENTIAL_SECRET_NAME)
   105                      key: username
   106                      optional: false
   107                - name: MONGODB_ROOT_PASSWORD
   108                  valueFrom:
   109                    secretKeyRef:
   110                      name: $(CONN_CREDENTIAL_SECRET_NAME)
   111                      key: password
   112                      optional: false
   113              volumeMounts:
   114                - mountPath: {{ .Values.dataMountPath }}
   115                  name: data
   116                - mountPath: /etc/mongodb/mongodb.conf
   117                  name: mongodb-config
   118                  subPath: mongodb.conf
   119                - mountPath: /etc/mongodb/keyfile
   120                  name: mongodb-config
   121                  subPath: keyfile
   122                - name: scripts
   123                  mountPath: /scripts
   124            - name: metrics
   125              image: {{ .Values.metrics.image.registry | default "docker.io" }}/{{ .Values.metrics.image.repository }}:{{ .Values.metrics.image.tag }}
   126              imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
   127              securityContext:
   128                runAsNonRoot: true
   129                runAsUser: 1001
   130              env:
   131                - name: MONGODB_ROOT_USER
   132                  valueFrom:
   133                    secretKeyRef:
   134                      name: $(CONN_CREDENTIAL_SECRET_NAME)
   135                      key: username
   136                      optional: false
   137                - name: MONGODB_ROOT_PASSWORD
   138                  valueFrom:
   139                    secretKeyRef:
   140                      name: $(CONN_CREDENTIAL_SECRET_NAME)
   141                      key: password
   142                      optional: false
   143              command:
   144                - "/bin/agamotto"
   145                - "--config=/opt/conf/metrics-config.yaml"
   146              ports:
   147                - name: http-metrics
   148                  containerPort: 9216
   149              volumeMounts:
   150                - name: mongodb-metrics-config
   151                  mountPath: /opt/conf