# Copyright BigchainDB GmbH and BigchainDB contributors
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
# Code is Apache-2.0 and docs are CC-BY-4.0

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: openresty-instance-0-dep
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: openresty-instance-0-dep
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx-openresty
        image: bigchaindb/nginx_3scale:2.0.0-alpha
        imagePullPolicy: IfNotPresent
        env:
        - name: DNS_SERVER
          valueFrom:
            configMapKeyRef:
              name: vars
              key: node-dns-server-ip
        - name: OPENRESTY_FRONTEND_PORT
          valueFrom:
            configMapKeyRef:
              name: vars
              key: openresty-backend-port
        - name: BIGCHAINDB_BACKEND_HOST
          valueFrom:
            configMapKeyRef:
              name: vars
              key: ngx-bdb-instance-name
        - name: BIGCHAINDB_API_PORT
          valueFrom:
            configMapKeyRef:
              name: vars
              key: bigchaindb-api-port
        ports:
        - containerPort: "<openresty-backend-port from ConfigMap>"
          protocol: TCP
          name: openresty-port
        volumeMounts:
        - name: threescale-credentials
          mountPath: /usr/local/openresty/nginx/conf/threescale
          readOnly: true
        livenessProbe:
          httpGet:
            path: /
            port: openresty-port
          initialDelaySeconds: 15
          periodSeconds: 15
          successThreshold: 1
          failureThreshold: 3
          timeoutSeconds: 10
        resources:
          limits:
            cpu: 200m
            memory: 768Mi
      restartPolicy: Always
      volumes:
      - name: threescale-credentials
        secret:
          secretName: threescale-credentials
          defaultMode: 0400
