##################################################################################################
# reader-provider; 此服务是通过nacos; 因此; 无需创建service
##################################################################################################
apiVersion: v1
kind: ServiceAccount
metadata:
  name: reader-provider-account
  namespace: bcx-opm
  labels:
    account: reader-account
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: reader-deployment
  namespace: bcx-opm
  labels:
    app: reader-provider
spec:
  replicas: 2
  selector:
    matchLabels:
      app: reader-provider
  template:
    metadata:
      labels:
        app: reader-provider
    spec:
      serviceAccountName: reader-provider-account
      containers:
        - name: reader-provider
          image: docker.io/library/tenant-open-dubbo-reader-provider:1.0.0
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
          imagePullPolicy: IfNotPresent
          command: ["/bin/bash", "-c", "apt-get update && apt-get install -y telnet && java -jar app.jar "]
          ports:
            - containerPort: 18802
          env:
            - name: "dubbo.registry.address"
              value: "nacos://nacos-service.bcx-opm.svc.cluster.local:8848"
            - name: "nacos.address"
              value: "nacos-service.bcx-opm.svc.cluster.local"
            - name: "dubbo.protocol.port"
              value: "18802"
---
##################################################################################################
# Writer-provider
##################################################################################################
apiVersion: v1
kind: ServiceAccount
metadata:
  name: writer-provider-account
  namespace: bcx-opm
  labels:
    account: writer-account
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: writer-deployment
  namespace: bcx-opm
  labels:
    app: writer-provider
spec:
  replicas: 3
  selector:
    matchLabels:
      app: writer-provider
  template:
    metadata:
      labels:
        app: writer-provider
    spec:
      serviceAccountName: writer-provider-account
      containers:
        - name: writer-provider
          image: docker.io/library/tenant-open-dubbo-writer-provider:1.0.0
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
          imagePullPolicy: IfNotPresent
          command: ["/bin/bash", "-c", "apt-get update && apt-get install -y telnet && java -jar app.jar "]
          ports:
            - containerPort: 18803
          env:
            - name: "dubbo.registry.address"
              value: "nacos://nacos-service.bcx-opm.svc.cluster.local:8848"
            - name: "nacos.address"
              value: "nacos-service.bcx-opm.svc.cluster.local"
            - name: "dubbo.protocol.port"
              value: "18803"
---
##################################################################################################
# rest-api
##################################################################################################
apiVersion: v1
kind: Service
metadata:
  name: rest-api-service
  namespace: bcx-opm
  labels:
    app: rest-api
spec:
  type: NodePort
  ports:
    - port: 8082
      targetPort: 8082
      nodePort: 30001
      name: http-port
  selector:
    app: rest-api
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: rest-api-account
  namespace: bcx-opm
  labels:
    account: rest-api-account
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: rest-api-deployment
  namespace: bcx-opm
  labels:
    app: rest-api
spec:
  replicas: 2
  selector:
    matchLabels:
      app: rest-api
  template:
    metadata:
      labels:
        app: rest-api
    spec:
      serviceAccountName: rest-api-account
      containers:
        - name: rest-api
          image: docker.io/library/tenant-open-rest-api:1.0.0
          securityContext:
            capabilities:
              add: ["NET_ADMIN"]
          imagePullPolicy: IfNotPresent
          command: ["/bin/bash", "-c", "apt-get update && apt-get install -y telnet && java -jar app.jar --server.port=8082"]
          ports:
            - containerPort: 18805
            - containerPort: 8082
          env:
            - name: "dubbo.registry.address"
              value: "nacos://nacos-service.bcx-opm.svc.cluster.local:8848"
            - name: "dubbo.protocol.port"
              value: "18805"