package c_middle

const CmiiMongoTemplate = `
apiVersion: v1
kind: Service
metadata:
  name: helm-mongo
  namespace: {{ .Namespace }}
  labels:
    cmii.app: helm-mongo
    cmii.type: middleware
    helm.sh/chart: mongo-1.1.0
    app.kubernetes.io/managed-by: octopus-control
    app.kubernetes.io/version: "{{ .TagVersion }}"
spec:
  type: NodePort
  selector:
    cmii.app: helm-mongo
    cmii.type: middleware
  ports:
    - port: 27017
      name: server-27017
      targetPort: 27017
      nodePort: {{ .MongoNodePort }}
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: helm-mongo
  namespace: {{ .Namespace }}
  labels:
    cmii.app: helm-mongo
    cmii.type: middleware
    helm.sh/chart: mongo-1.1.0
    app.kubernetes.io/managed-by: octopus-control
    app.kubernetes.io/version: "{{ .TagVersion }}"
spec:
  serviceName: helm-mongo
  replicas: 1
  selector:
    matchLabels:
      cmii.app: helm-mongo
      cmii.type: middleware
  template:
    metadata:
      labels:
        cmii.app: helm-mongo
        cmii.type: middleware
        helm.sh/chart: mongo-1.1.0
        app.kubernetes.io/managed-by: octopus-control
        app.kubernetes.io/version: "{{ .TagVersion }}"
      annotations:
        pod.alpha.kubernetes.io/initialized: "true"
    spec:
      imagePullSecrets:
        - name: harborsecret
      affinity: {}
      containers:
        - name: helm-mongo
          {{- if .HarborPort }}
          image: {{ .HarborIPOrCustomImagePrefix }}:{{ .HarborPort }}/cmii/mongo:5.0
          {{- else }}
          image: {{ .HarborIPOrCustomImagePrefix }}mongo:5.0
          {{- end }}
          resources: {}
          ports:
            - containerPort: 27017
              name: mongo27017
              protocol: TCP
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              value: cmlc
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: {{ .MongoPassword }}
          volumeMounts:
            - name: mongo-data
              mountPath: /data/db
              readOnly: false
              subPath: default/helm-mongo/data/db
      volumes:
        - name: mongo-data
          persistentVolumeClaim:
            claimName: helm-mongo
---
`
