apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: default
  name: micro-router
  labels:
    micro: runtime
    name: micro-router
  annotations:
    name: "router"
    version: "latest"
    source: "github.com/micro/micro"
    owner: "micro"
    group: "micro"
spec:
  replicas: 1
  selector:
    matchLabels:
      name: micro-router
      micro: runtime
  template:
    metadata:
      labels:
        name: micro-router
        micro: runtime
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/path: /metrics
        prometheus.io/port: "9000"
    spec:
      containers:
        - name: micro
          env:
            - name: MICRO_PROFILE
              value: platform
            - name: MICRO_SERVICE_NAME
              value: router
            - name: MICRO_PROXY
              value: "micro-network.default.svc.cluster.local:8443"
            - name: MICRO_AUTH_PUBLIC_KEY
              valueFrom:
                secretKeyRef:
                  name: micro-secrets
                  key: auth_public_key
            - name: MICRO_AUTH_PRIVATE_KEY
              valueFrom:
                secretKeyRef:
                  name: micro-secrets
                  key: auth_private_key
            - name: MICRO_LOG_LEVEL
              value: "debug"
            - name: MICRO_BROKER_TLS_CA
              value: "/certs/broker/ca.crt"
            - name: MICRO_BROKER_TLS_CERT
              value: "/certs/broker/cert.pem"
            - name: MICRO_BROKER_TLS_KEY
              value: "/certs/broker/key.pem"
            - name: MICRO_EVENTS_TLS_CA
              value: "/certs/events/ca.crt"
            - name: MICRO_EVENTS_TLS_CERT
              value: "/certs/events/cert.pem"
            - name: MICRO_EVENTS_TLS_KEY
              value: "/certs/events/key.pem"
            - name: MICRO_REGISTRY_TLS_CA
              value: "/certs/registry/ca.crt"
            - name: MICRO_REGISTRY_TLS_CERT
              value: "/certs/registry/cert.pem"
            - name: MICRO_REGISTRY_TLS_KEY
              value: "/certs/registry/key.pem"
            - name: MICRO_ENABLE_ACME
              value: "false"
            - name: MICRO_STORE_ADDRESS
              value: "postgresql://root@cockroachdb-cluster-public:26257?ssl=true&sslmode=require&sslrootcert=certs/store/ca.crt&sslkey=certs/store/key.pem&sslcert=certs/store/cert.pem"
          args:
            - service
            - router
          image: micro/micro
          imagePullPolicy: Always
          ports:
            - containerPort: 8084
              name: router-port
          readinessProbe:
            tcpSocket:
              port: router-port
            initialDelaySeconds: 5
            periodSeconds: 10
          volumeMounts:
            - name: etcd-client-certs
              mountPath: "/certs/registry"
              readOnly: true
            - name: nats-client-certs
              mountPath: "/certs/broker"
              readOnly: true
            - name: nats-client-certs
              mountPath: "/certs/events"
              readOnly: true
            - name: cockroachdb-client-certs
              mountPath: "/certs/store"
              readOnly: true
      volumes:
        - name: etcd-client-certs
          secret:
            secretName: etcd-client-certs
        - name: nats-client-certs
          secret:
            secretName: nats-client-certs
        - name: cockroachdb-client-certs
          secret:
            secretName: cockroachdb-client-certs
            defaultMode: 0600
