---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: $DEPLOYMENT_NAME
  name: $DEPLOYMENT_NAME
  namespace: blackdice
spec:
  replicas: 1
  selector:
    matchLabels:
      app: $DEPLOYMENT_NAME
  template:
    metadata:
      labels:
        app: $DEPLOYMENT_NAME
    spec:
      containers:
      - env:
        - name: NODE_ENV
          valueFrom:
            secretKeyRef:
              key: NODE_ENV
              name: serviceplatform-env
        - name: MYSQL_URL
          valueFrom:
            secretKeyRef:
              key: MYSQL_URL
              name: serviceplatform-env
        - name: MYSQL_PASSWORD
          valueFrom:
            secretKeyRef:
              key: MYSQL_PASSWORD
              name: serviceplatform-env
        - name: MYSQL_PORT
          valueFrom:
            secretKeyRef:
              key: MYSQL_PORT
              name: serviceplatform-env
        - name: MYSQL_DATABASE
          valueFrom:
            secretKeyRef:
              key: MYSQL_DATABASE
              name: serviceplatform-env
        - name: MYSQL_USER
          valueFrom:
            secretKeyRef:
              key: MYSQL_USER
              name: serviceplatform-env
        - name: DB_DIALECT
          valueFrom:
            secretKeyRef:
              key: DB_DIALECT
              name: serviceplatform-env
        - name: REDIS_URL
          valueFrom:
            secretKeyRef:
              key: REDIS_URL
              name: serviceplatform-env
        - name: REDIS_PASSWORD
          valueFrom:
            secretKeyRef:
              key: REDIS_PASSWORD
              name: serviceplatform-env
        - name: REDIS_PORT
          valueFrom:
            secretKeyRef:
              key: REDIS_PORT
              name: serviceplatform-env
        - name: COMMUNICATOR_ADDRESS
          valueFrom:
            secretKeyRef:
              key: COMMUNICATOR_ADDRESS
              name: serviceplatform-env
        - name: SIGNING_KEY
          valueFrom:
            secretKeyRef:
              key: SIGNING_KEY
              name: serviceplatform-env
        - name: MQTT_HOST
          valueFrom:
            secretKeyRef:
              key: MQTT_HOST
              name: serviceplatform-env
        - name: MQTT_USERNAME
          valueFrom:
            secretKeyRef:
              key: MQTT_USERNAME
              name: serviceplatform-env
        - name: MQTT_PASSWORD
          valueFrom:
            secretKeyRef:
              key: MQTT_PASSWORD
              name: serviceplatform-env
        - name: FIREBASE_ENV
          valueFrom:
            secretKeyRef:
              key: FIREBASE_ENV
              name: serviceplatform-env
        - name: APNS_TOPIC
          valueFrom:
            secretKeyRef:
              key: APNS_TOPIC
              name: serviceplatform-env
        - name: MDM_API_TOKEN
          valueFrom:
            secretKeyRef:
              key: MDM_API_TOKEN
              name: serviceplatform-env
        - name: MDM_AUTH
          valueFrom:
            secretKeyRef:
              key: MDM_AUTH
              name: serviceplatform-env
        - name: MDM_SERVICE_URL
          valueFrom:
            secretKeyRef:
              key: MDM_SERVICE_URL
              name: serviceplatform-env
        - name: DNS_URL
          valueFrom:
            secretKeyRef:
              key: DNS_URL
              name: serviceplatform-env
        - name: MYSQL_DATABASE_THREAT
          valueFrom:
            secretKeyRef:
              key: MYSQL_DATABASE_THREAT
              name: serviceplatform-env
        - name: MONGO_COLLECTION
          valueFrom:
            secretKeyRef:
              key: MONGO_COLLECTION
              name: serviceplatform-env
        - name: MONGO_URI
          valueFrom:
            secretKeyRef:
              key: MONGO_URI
              name: serviceplatform-env
        - name: MONGO_DATABASE
          valueFrom:
            secretKeyRef:
              key: MONGO_DATABASE
              name: serviceplatform-env
        - name: RETINA_EMAIL_REDIRECT
          valueFrom:
            secretKeyRef:
              key: RETINA_EMAIL_REDIRECT
              name: serviceplatform-env
        - name: CORS_ORIGINS
          valueFrom:
            secretKeyRef:
              key: CORS_ORIGINS
              name: serviceplatform-env
        - name: AMA_OAUTH_SCOPE
          valueFrom:
            secretKeyRef:
              key: AMA_OAUTH_SCOPE
              name: serviceplatform-env
        - name: AMA_PROJECT_ID
          valueFrom:
            secretKeyRef:
              key: AMA_PROJECT_ID
              name: serviceplatform-env
        - name: AMA_PRIVATE_KEY
          valueFrom:
            secretKeyRef:
              key: AMA_PRIVATE_KEY
              name: serviceplatform-env
        - name: AMA_SERVICE_EMAIL
          valueFrom:
            secretKeyRef:
              key: AMA_SERVICE_EMAIL
              name: serviceplatform-env
        - name: AMA_SUBSCRIPTION_NAME
          valueFrom:
            secretKeyRef:
              key: AMA_SUBSCRIPTION_NAME
              name: serviceplatform-env
        - name: AMA_PS_SERVICE_EMAIL
          valueFrom:
            secretKeyRef:
              key: AMA_PS_SERVICE_EMAIL
              name: serviceplatform-env
        - name: AMA_PS_PRIVATE_KEY
          valueFrom:
            secretKeyRef:
              key: AMA_PS_PRIVATE_KEY
              name: serviceplatform-env
        - name: AGENT_STORAGE
          valueFrom:
            secretKeyRef:
              key: AGENT_STORAGE
              name: serviceplatform-env
        - name: AGENT_STORAGE_KEY
          valueFrom:
            secretKeyRef:
              key: AGENT_STORAGE_KEY
              name: serviceplatform-env
        image: $IMAGE_NAME
        imagePullPolicy: Always
        name: $DEPLOYMENT_NAME
        ports:
        - containerPort: 3000
          protocol: TCP
      restartPolicy: Always


---
apiVersion: v1
kind: Service
metadata:
  name: $DEPLOYMENT_NAME
  namespace: blackdice
spec:
  ports:
  - name: $DEPLOYMENT_NAME
    port: 3000
    protocol: TCP
    targetPort: 3000
  selector:
    app: $DEPLOYMENT_NAME
  type: ClusterIP
