apiVersion: apps/v1
kind: Deployment
metadata:
  name: chainlink
spec:
  selector:
    matchLabels:
      app: chainlink
      role: ethereum
  replicas: 1
  template:
    metadata:
      labels:
        app: chainlink
        role: ethereum
        environment: production        
    spec:
      containers:
        - name: chainlink
          # image: smartcontract/chainlink:1.1.1          
          image: dextrac/chainlink-olympics:latest
          args: ["local", "n", "-p",  "/chainlink/.password", "-a", "/chainlink/.api"]
          env:
            - name: ROOT
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: root-folder
            - name: LOG_LEVEL
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: log-level
            - name: LOG_TO_DISK
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: log-to-disk
            - name: ETH_CHAIN_ID
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: eth-chain-id
            - name: CHAINLINK_TLS_PORT
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: chainlink-tls-port
            - name: SECURE_COOKIES
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: secure-cookies
            - name: ALLOW_ORIGINS
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: allow-origins
            - name: ETH_URL
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: eth-url
            - name: ETH_SECONDARY_URLS
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: eth-secondary-urls
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: chainlink-secrets
                  key: database-url
            - name: JSON_CONSOLE
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: json-console
            - name: DATABASE_LOCKING_MODE
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: database-locking-mode
            - name: LEASE_LOCK_REFRESH_INTERVAL                  
              valueFrom:
                configMapKeyRef:
                  name: chainlink-configmap
                  key: database-lease-lock-refresh-interval            

          ports:
            - containerPort: 6688
            - containerPort: 11972
            - containerPort: 11973
          volumeMounts:
            - name: api-volume
              mountPath: /chainlink/.api
              subPath: .api
            - name: password-volume
              mountPath: /chainlink/.password
              subPath: .password

          readinessProbe:
            httpGet:
              path: /metrics
              port: 6688
            initialDelaySeconds: 10
            periodSeconds: 1

          resources:
            requests:
              cpu: 3000m
              memory: 3000Mi
      volumes:
        - name: api-volume
          secret:
            secretName: api-env
        - name: password-volume
          secret:
            secretName: password-env
