apiVersion: v1
kind: PersistentVolumeClaim
metadata:
    labels:
       type: yukon
    #pvc名称，${appsetId}在创建过程中会被替换
    name: pvc-nfs-yukon-data-${appsetId}
spec:
   #storageClass名称，固定为appset-storage-class-${GROUP_TYPE}。${GROUP_TYPE}在创建过程中会被替换。
   storageClassName: appset-storage-class-${GROUP_TYPE}
   accessModes:
      - ReadWriteMany
   resources:
      requests:
         storage: 1Gi
---
apiVersion: v1
kind: Service
metadata:
    labels:
       type: yukon
    name: yukon-server
    annotations:
       #服务地址,${SERVICE_IP}和${NODE_PORT}在创建过程中会被替换
       addressReg: "jdbc:postgres://${SERVICE_IP}:${NODE_PORT}"
       #服务地址对应的targetPort为5432
       showPorts: "[5432]"
spec:
   ports:
   - port: 5432
     targetPort: 5432
     nodePort: ${custom_node_port_mysql}
   selector:
      app: yukon-server
   type: NodePort
---
apiVersion: v1
kind: Service
metadata:
    labels:
      type: yukon
      #将pgadmin服务地址作为访问入口
      entrance: "true"
      #访问入口地址对应的targetPort为80
      entrance-port: "80"
    name: pgadmin4
spec:
   ports:
   - port: 89
     targetPort: 80
   selector:
      app: pgadmin4
   type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
   labels:
      app: yukon-server
   name: yukon-server
   annotations:
      #不支持伸缩
      scale: unscalable
      #Yukon 描述信息
      description: Yukon 空间数据库
      #Yukon 账户信息
      accountInfo: "<p>用户/密码:</p><p> postgres/Bigdata@123</p>"
spec:
   replicas: 1
   selector:
      matchLabels:
          app: yukon-server
   template:
      metadata:
          labels:
            app: yukon-server
      spec:
         containers:
          - env:
            - name: POSTGRES_PASSWORD
              value: Bigdata@123            
            #${REGISTRY_URL}在创建过程中会被替换
            image: ${REGISTRY_URL}supermap/yukon:1.0-postgresql13-x86_64
            name: yukonforpostgres13
            #镜像拉取策略，${IMAGE_PULL_POLICY}在创建过程中会被替换
            imagePullPolicy: ${IMAGE_PULL_POLICY}
            #镜像拉取Secret，${IMAGE_PULL_SECRET}在创建过程中会被替换
            imagePullSecrets:
            - name: "${IMAGE_PULL_SECRET}"
            #cpu资源限制，${GIS_APP_LIMIT_CPU}在创建过程中会被替换
            resources:
                limits:
                   cpu: ${GIS_APP_LIMIT_CPU}
                requests:
                   cpu: 300m
            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
    name: pgadmin4
    annotations:
       #不支持伸缩
       scale: unscalable
       #不显示命令行
       console: noconsole
       #pgadmin描述信息
       description: Yukon 的 WEB 客户端
       #初始账户信息
       accountInfo: "<p>用户/密码:</p><p>test@123.com/123456</p>"
spec:
   replicas: 1
   selector:
      matchLabels:
          app: pgadmin4
   template:
      metadata:
          labels:
            app: pgadmin4
      spec:
         containers:
         - env:
           - name: PGADMIN_DEFAULT_EMAIL
             value: test@123.com
           - name: PGADMIN_DEFAULT_PASSWORD
             value: 123456
           image: ${REGISTRY_URL}dpage/pgadmin4
           name: pgadmin4
           imagePullPolicy: ${IMAGE_PULL_POLICY}
           ports:
             - containerPort: 80
         restartPolicy: Always