
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sys-openldap
  labels:
    app: sys-openldap
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sys-openldap
  template:
    metadata:
      labels:
        app: sys-openldap
    spec:
      containers:
      - name: sys-openldap
        image: dockerhub.daline.com.cn/openldap:1.0.1
        ports:
        - containerPort: 389
          name: "openldap"
        volumeMounts:
          - name: ldap-data
            mountPath: /var/lib/ldap
          - name: ldap-config
            mountPath: /etc/ldap/slapd.d
          - name: ldap-certs
            mountPath: /container/service/slapd/assets/certs
          - name: localtime
            mountPath: /etc/localtime
            readOnly: true
        env:
          - name: "TZ"
            value: "Asia/Shanghai"
          - name: LDAP_LOG_LEVEL
            value: "256"
          - name: LDAP_ORGANISATION
            value: "Daline Inc."
          - name: LDAP_DOMAIN
            value: "daline.com"
          - name: LDAP_ADMIN_PASSWORD
            value: "Hell0DAL"
          - name: LDAP_CONFIG_PASSWORD
            value: "Hell0DAL"
          - name: LDAP_READONLY_USER
            value: "false"
          - name: LDAP_READONLY_USER_USERNAME
            value: "readonly"
          - name: LDAP_READONLY_USER_PASSWORD
            value: "readonly"
          - name: LDAP_RFC2307BIS_SCHEMA
            value: "false"
          - name: LDAP_BACKEND
            value: "mdb"
          - name: LDAP_TLS
            value: "true"
          - name: LDAP_TLS_CRT_FILENAME
            value: "ldap.crt"
          - name: LDAP_TLS_KEY_FILENAME
            value: "ldap.key"
          - name: LDAP_TLS_DH_PARAM_FILENAME
            value: "dhparam.pem"
          - name: LDAP_TLS_CA_CRT_FILENAME
            value: "ca.crt"
          - name: LDAP_TLS_ENFORCE
            value: "false"
          - name: LDAP_TLS_CIPHER_SUITE
            value: "SECURE256:+SECURE128:-VERS-TLS-ALL:+VERS-TLS1.2:-RSA:-DHE-DSS:-CAMELLIA-128-CBC:-CAMELLIA-256-CBC"
          - name: LDAP_TLS_VERIFY_CLIENT
            value: "demand"
          - name: LDAP_REPLICATION
            value: "false"
          - name: LDAP_REPLICATION_CONFIG_SYNCPROV
            value: "binddn=\"cn=admin,cn=config\" bindmethod=simple credentials=$LDAP_CONFIG_PASSWORD searchbase=\"cn=config\" type=refreshAndPersist retry=\"60 +\" timeout=1 starttls=critical"
          - name: LDAP_REPLICATION_DB_SYNCPROV
            value: "binddn=\"cn=admin,$LDAP_BASE_DN\" bindmethod=simple credentials=$LDAP_ADMIN_PASSWORD searchbase=\"$LDAP_BASE_DN\" type=refreshAndPersist interval=00:00:00:10 retry=\"60 +\" timeout=1 starttls=critical"
          - name: LDAP_REPLICATION_HOSTS
            value: "#PYTHON2BASH:['ldap://ldap-one-service', 'ldap://ldap-two-service']"
          - name: KEEP_EXISTING_CONFIG
            value: "false"
          - name: LDAP_REMOVE_CONFIG_AFTER_SETUP
            value: "true"
          - name: LDAP_SSL_HELPER_PREFIX
            value: "ldap"
      volumes:
        - name: ldap-data
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/openldap/data/"
        - name: ldap-config
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/openldap/config/"
        - name: ldap-certs
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/openldap/certs/"
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sys-openldap
  name: sys-openldap
spec:
  ports:
    - port: 389
      targetPort: 389
      name: "openldap"
  selector:
    app: sys-openldap

---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: sys-phpldapadmin
  labels:
    app: sys-phpldapadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sys-phpldapadmin
  template:
    metadata:
      labels:
        app: sys-phpldapadmin
    spec:
      containers:
        - name: sys-phpldapadmin
          image: osixia/phpldapadmin:0.9.0
          ports:
            - containerPort: 80
              name: "http"
          volumeMounts:
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
            - name: PHPLDAPADMIN_LDAP_HOSTS
              value: "sys-openldap"
            - name: PHPLDAPADMIN_SERVER_ADMIN
              value: "alex.c@daline.com.cn"
            - name: PHPLDAPADMIN_SERVER_PATH
              value: "/phpldapadmin"
            - name: PHPLDAPADMIN_HTTPS
              value: "false"
      volumes:
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sys-phpldapadmin
  name: sys-phpldapadmin
spec:
  ports:
    - port: 80
      targetPort: 80
      name: "http"
  selector:
    app: sys-phpldapadmin

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sys-phpldapadmin
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
  - host: api-new.westfutu.com
    http:
      paths:
      - path: /westfutu/sys-phpldapadmin(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: sys-phpldapadmin
            port:
              number: 80
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: sys-mariadb
  labels:
    app: sys-mariadb
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sys-mariadb
  template:
    metadata:
      labels:
        app: sys-mariadb
    spec:
      containers:
        - name: sys-mariadb
          image: mariadb:10.3
          volumeMounts:
            - name: data
              mountPath: /var/lib/mysql
            - name: log
              mountPath: /var/log/mysql
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          ports:
            - containerPort: 3306
              name: "mariadb"
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
            - name: "MYSQL_ROOT_PASSWORD"
              value: "Hell0DAL"
      volumes:
        - name: data
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/mariadb/data"
        - name: log
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/mariadb/log"
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sys-mariadb
  name: sys-mariadb
spec:
  type: NodePort
  ports:
    - port: 3306
      targetPort: 3306
      name: "mariadb"
  selector:
    app: sys-mariadb
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: sys-redis
  labels:
    app: sys-redis
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sys-redis
  template:
    metadata:
      labels:
        app: sys-redis
    spec:
      containers:
        - name: sys-redis
          image: bitnami/redis:7.0.1
          volumeMounts:
            - name: data
              mountPath: /bitnami/redis/data
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          ports:
            - containerPort: 6379
              name: "redis"
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
            - name: "REDIS_PASSWORD"
              value: "Hell0DAL"
            - name: "REDIS_DISABLE_COMMANDS"
              value: "FLUSHDB,FLUSHALL,CONFIG"
      volumes:
        - name: data
          nfs:
            server: 369df4abd8-qmf27.cn-shanghai.nas.aliyuncs.com
            path: "/home/NFSData/dev/westfutu/redis"
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sys-redis
  name: sys-redis
spec:
  type: NodePort
  ports:
    - port: 6379
      targetPort: 6379
      name: "redis"
  selector:
    app: sys-redis
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: sys-zipkin
  labels:
    app: sys-zipkin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sys-zipkin
  template:
    metadata:
      labels:
        app: sys-zipkin
    spec:
      containers:
        - name: sys-zipkin
          image: openzipkin/zipkin:2.23
          volumeMounts:
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          ports:
            - containerPort: 9411
              name: "zipkin"
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
      volumes:
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: sys-zipkin
  name: sys-zipkin
spec:
  type: NodePort
  ports:
    - port: 9411
      targetPort: 9411
      name: "zipkin"
  selector:
    app: sys-zipkin

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: sys-zipkin
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: nginx
  rules:
  - host: zipkin-westfutu.dev.daline.com.cn
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: sys-zipkin
            port:
              number: 9411
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: pu-sys-usercenter-v1x0x1
  labels:
    app: pu-sys-usercenter-v1x0x1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pu-sys-usercenter-v1x0x1
  template:
    metadata:
      labels:
        app: pu-sys-usercenter-v1x0x1
    spec:
      hostname: pu-sys-usercenter-v1x0x1
      containers:
        - name: pu-sys-usercenter-v1x0x1
          image: dockerhub.daline.com.cn/pu_sys_usercenter:1.0.1.last
          imagePullPolicy: Always
          volumeMounts:
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          ports:
            - containerPort: 80
              name: "http"
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
            - name: "AUTHLIB_INSECURE_TRANSPORT"
              value: "1"
            - name: "SERVE"
              value: "1"
            - name: "IN_K8S"
              value: "1"
            - name: "GLB_ENV"
              value: "1"
            - name: "AUTHOR"
              value: "alex.c"
            - name: "GIT_COMMIT"
              value: "666"
            - name: "DAL_ENV"
              value: "dev"
            - name: "DAL_SPACE"
              value: "westfutu"
            # ldap config
            - name: "LDAP_URL"
              value: "ldap://sys-openldap:389"
            - name: "LDAP_BASE"
              value: "ou=user,dc=daline,dc=com"
            - name: "LDAP_BIND_DN"
              value: "cn=admin,dc=daline,dc=com"
            - name: "LDAP_BIND_PASSWORD"
              value: "Hell0DAL"
            # log config
            - name: "LOG_LEVEL"
              value: "debug"
            - name: "LOG_DIR"
              value: "/var/log/daline"
            # port config
      volumes:
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: pu-sys-usercenter-v1x0x1
  name: pu-sys-usercenter-v1x0x1
spec:
  ports:
    - port: 80
      targetPort: 80
      name: "http"
  selector:
    app: pu-sys-usercenter-v1x0x1

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: pu-sys-usercenter-v1x0x1
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
  - host: api-new.westfutu.com
    http:
      paths:
      - path: /westfutu/pu-sys-usercenter-v1x0x1(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: pu-sys-usercenter-v1x0x1
            port:
              number: 80
  - host: api-glb.daline.com.cn
    http:
      paths:
      - path: /pu-sys-usercenter-v1x0x1(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: pu-sys-usercenter-v1x0x1
            port:
              number: 80
---


apiVersion: apps/v1
kind: Deployment
metadata:
  name: pu-sys-mysqlconfig-v1x0x1
  labels:
    app: pu-sys-mysqlconfig-v1x0x1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pu-sys-mysqlconfig-v1x0x1
  template:
    metadata:
      labels:
        app: pu-sys-mysqlconfig-v1x0x1
    spec:
      hostname: pu-sys-mysqlconfig-v1x0x1
      containers:
        - name: pu-sys-mysqlconfig-v1x0x1
          image: dockerhub.daline.com.cn/pu_sys_mysqlconfig:1.0.1.last
          imagePullPolicy: Always
          volumeMounts:
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
          ports:
            - containerPort: 80
              name: "http"
          env:
            - name: "TZ"
              value: "Asia/Shanghai"
            - name: "SERVE"
              value: "1"
            - name: "IN_K8S"
              value: "1"
            - name: "AUTHOR"
              value: "alex.c"
            - name: "GIT_COMMIT"
              value: "666"
            - name: "DAL_ENV"
              value: "dev"
            - name: "DAL_SPACE"
              value: "westfutu"
            # mysql config
            - name: "MYSQL_SERVER"
              value: "sys-mariadb"
            - name: "MYSQL_PORT"
              value: "3306"
            - name: "MYSQL_ACCOUNT"
              value: "root"
            - name: "MYSQL_PASSWORD"
              value: "Hell0DAL"
            - name: "MYSQL_DB"
              value: "mysql"
            # log config
            - name: "LOG_LEVEL"
              value: "debug"
            - name: "LOG_DIR"
              value: "/var/log/daline"
            # port config
      volumes:
        - name: localtime
          hostPath:
            path: "/etc/localtime"

---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: pu-sys-mysqlconfig-v1x0x1
  name: pu-sys-mysqlconfig-v1x0x1
spec:
  ports:
    - port: 80
      targetPort: 80
      name: "http"
  selector:
    app: pu-sys-mysqlconfig-v1x0x1

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: pu-sys-mysqlconfig-v1x0x1
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: nginx
  rules:
  - host: api-new.westfutu.com
    http:
      paths:
      - path: /westfutu/pu-sys-mysqlconfig-v1x0x1(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: pu-sys-mysqlconfig-v1x0x1
            port:
              number: 80

