apiVersion: v1
kind: Secret
metadata:
  name: yukon-secret
  labels:
    type: yukon-for-postgres
data:
  yukon.password: U3VwZXJtYXBAMTIz
  pgadmin.password: c3VwZXJtYXA=
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    type: yukon-for-postgres
  name: pvc-nfs-yukon-data-${appsetId}
spec:
  storageClassName: appset-storage-class-database
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 100Gi
---
apiVersion: v1
kind: Service
metadata:
  labels:
    type: yukon-for-postgres
  name: yukon-server
  annotations:
    addressReg: "jdbc:postgres://${SERVICE_IP}:${NODE_PORT}"
    showPorts: "[5432]"
    description: yukon_for_postgres_rule_custom_node_port_yukon
spec:
  ports:
    - port: 5432
      targetPort: 5432
      nodePort: ${custom_node_port_yukon}
  selector:
    app: yukon-server
  type: NodePort
---
apiVersion: v1
kind: Service
metadata:
  labels:
    type: yukon-for-postgres
    entrance: "true"
    entrance-port: "80"
  name: pgadmin4
spec:
  ports:
    - port: 80
      targetPort: 80
  selector:
    app: pgadmin4
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: yukon-server
    type: yukon-for-postgres
  name: yukon-server
  annotations:
    scale: unscalable
    description: yukon_for_postgres_yukon_server_description
    topoProperty: "{'name':'yukon-server','isPivot':'false','index':1,'parents':[{'name':'pgadmin4','description':'yukon_for_postgres_yukon_topoProperty_pgadmin_description'}]}"
    accountInfo: "{'type':'fromSecret','filters':[{'name':'yukon-secret','key':'yukon.password'}],'text':'<p>yukon_for_postgres_accountInfo_username<span style=\"margin-left:10px\">gaussdb</span></p><p>yukon_for_postgres_accountInfo_password<span style=\"margin-left:10px\">${yukon.password}</span></p><p>yukon_for_postgres_accountInfo_defaultDB<span style=\"margin-left:10px\">postgres</span></p>'}"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: yukon-server
  template:
    metadata:
      labels:
        app: yukon-server
    spec:
      imagePullSecrets:
        - name: "${IMAGE_PULL_SECRET}"
      containers:
        - env:
            - name: GS_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: yukon-secret
                  key: yukon.password
          image: ${REGISTRY_URL}${IMAGE_NAMESPACE}yukon:1.0.1-postgresql13-amd64
          name: yukon-server
          imagePullPolicy: ${IMAGE_PULL_POLICY}
          resources:
            limits:
              cpu: 2
              memory: 4Gi
            requests:
              cpu: 100m
              memory: 200Mi
          ports:
            - containerPort: 5432
          livenessProbe:
            tcpSocket:
              port: 5432
            failureThreshold: 5
            initialDelaySeconds: 20
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 20
          readinessProbe:
            tcpSocket:
              port: 5432
            failureThreshold: 5
            initialDelaySeconds: 20
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 20
          volumeMounts:
            - mountPath: /var/lib/postgres
              name: yukon-volume
      restartPolicy: Always
      volumes:
        - name: yukon-volume
          persistentVolumeClaim:
            claimName: pvc-nfs-yukon-data-${appsetId}
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: pgadmin4
    type: yukon-for-postgres
  name: pgadmin4
  annotations:
    scale: unscalable
    console: noconsole
    description: yukon_for_postgres_pgadmin_description
    accountInfo: "{'type':'fromSecret','filters':[{'name':'yukon-secret','key':'pgadmin.password'}],'text':'<p>yukon_for_postgres_accountInfo_username<span style=\"margin-left:10px\">admin@supermap.com</span></p><p>yukon_for_postgres_accountInfo_password<span style=\"margin-left:10px\">${pgadmin.password}</span></p>'}"
    topoProperty: "{'name':'pgadmin4','isPivot':'false','index':2,'parents':[]}"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgadmin4
  template:
    metadata:
      labels:
        app: pgadmin4
    spec:
      imagePullSecrets:
        - name: "${IMAGE_PULL_SECRET}"
      containers:
        - env:
            - name: PGADMIN_DEFAULT_EMAIL
              value: admin@supermap.com
            - name: PGADMIN_DEFAULT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: yukon-secret
                  key: pgadmin.password
          image: ${REGISTRY_URL}${IMAGE_NAMESPACE}pgadmin4:6.9-amd64
          name: pgadmin4
          imagePullPolicy: ${IMAGE_PULL_POLICY}
          ports:
            - containerPort: 80
          resources:
            limits:
              cpu: 500m
              memory: 512Mi
            requests:
              cpu: 10m
              memory: 20Mi
          livenessProbe:
            httpGet:
              port: 80
            failureThreshold: 5
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 20
          readinessProbe:
            httpGet:
              port: 80
            failureThreshold: 5
            initialDelaySeconds: 10
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 20
      restartPolicy: Always
