apiVersion: apps/v1
kind: Deployment
metadata:
  name: virtengine-provider
spec:
  selector:
    matchLabels:
      app: virtengine-provider
  template:
    metadata:
      labels:
        app: virtengine-provider
    spec:
      containers:
        - name: virtengine-provider
          image: ghcr.io/virtengine/virtengine:stable
          imagePullPolicy: IfNotPresent
          command: [ "/bin/sh", "/boot/run.sh" ]
          env:

            ##
            # boot config
            ##

            # location of key export. must contain two files:
            #
            # key.txt:      exported wallet key
            # key-pass.txt: password used to encrypt exported key
            - name: VIRTENGINE_BOOT_KEYS
              value: /boot-keys

            ##
            # cosmos-sdk client config
            ##

            # --home
            - name: VIRTENGINE_HOME
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: home

            # --from
            - name: VIRTENGINE_FROM
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: from

            # --node
            - name: VIRTENGINE_NODE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: node

            # --chain-id
            - name: VIRTENGINE_CHAIN_ID
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: chain-id

            # --keyring-backend
            - name: VIRTENGINE_KEYRING_BACKEND
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: keyring-backend

            # --trust-node
            - name: VIRTENGINE_TRUST_NODE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-client-config
                  key: trust-node

            ##
            # virtengine-provider config
            ##

            - name: VIRTENGINE_AUTH_PEM
              valueFrom:
                secretKeyRef:
                  name: virtengine-provider-keys
                  key: provider-cert.pem

            # include unique hostnames for apps
            - name: VIRTENGINE_DEPLOYMENT_INGRESS_STATIC_HOSTS
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: ingress-static-hosts
                  optional: true

            # domain to host unique app hostnames on
            # (required if VIRTENGINE_DEPLOYMENT_INGRESS_STATIC_HOSTS is "true")
            - name: VIRTENGINE_DEPLOYMENT_INGRESS_DOMAIN
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: ingress-domain
                  optional: true

            # return load balancer host in lease status command
            - name: VIRTENGINE_DEPLOYMENT_INGRESS_EXPOSE_LB_HOSTS
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: ingress-expose-lb-hosts
                  optional: true

            # return load balancer host in lease status command
            - name: VIRTENGINE_DEPLOYMENT_NETWORK_POLICIES_ENABLED
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: network-policies-enabled
                  optional: true

            - name: VIRTENGINE_MAX_UNIT_CPU
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-unit-cpu
                  optional: true

            - name: VIRTENGINE_MAX_UNIT_MEMORY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-unit-memory
                  optional: true

            - name: VIRTENGINE_MAX_UNIT_STORAGE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-unit-storage
                  optional: true

            - name: VIRTENGINE_MAX_UNIT_COUNT
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-unit-count
                  optional: true

            - name: VIRTENGINE_MAX_UNIT_PRICE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-unit-price
                  optional: true

            - name: VIRTENGINE_MIN_UNIT_CPU
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: min-unit-cpu
                  optional: true

            - name: VIRTENGINE_MIN_UNIT_MEMORY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: min-unit-memory
                  optional: true

            - name: VIRTENGINE_MIN_UNIT_STORAGE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: min-unit-storage
                  optional: true

            - name: VIRTENGINE_MIN_UNIT_COUNT
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: min-unit-count
                  optional: true

            - name: VIRTENGINE_MIN_UNIT_PRICE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: min-unit-price
                  optional: true

            - name: VIRTENGINE_MAX_GROUP_COUNT
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-group-count
                  optional: true

            - name: VIRTENGINE_MAX_GROUP_UNITS
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-group-units
                  optional: true

            - name: VIRTENGINE_MAX_GROUP_CPU
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-group-cpu
                  optional: true

            - name: VIRTENGINE_MAX_GROUP_MEMORY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-group-memory
                  optional: true

            - name: VIRTENGINE_MAX_GROUP_STORAGE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: max-group-storage
                  optional: true

            - name: VIRTENGINE_MEM_PRICE_MIN
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: mem-price-min
                  optional: true

            - name: VIRTENGINE_CLUSTER_PUBLIC_HOSTNAME
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: cluster-public-hostname
                  optional: true

            - name: VIRTENGINE_CLUSTER_NODE_PORT_QUANTITY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: cluster-node-port-quantity
                  optional: true

            - name: VIRTENGINE_CLUSTER_WAIT_READY_DURATION
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: cluster_wait-ready-duration
                  optional: true

            - name: VIRTENGINE_INVENTORY_RESOURCE_POLL_PERIOD
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: inventory-resource-poll-period
                  optional: true

            - name: VIRTENGINE_INVENTORY_RESOURCE_DEBUG_FREQUENCY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: inventory-resource-debug-freq
                  optional: true

            - name: VIRTENGINE_BID_PRICE_STRATEGY
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-price-strategy
                  optional: true

            - name: VIRTENGINE_BID_PRICE_CPU_SCALE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-cpu-scale
                  optional: true

            - name: VIRTENGINE_BID_PRICE_MEMORY_SCALE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-memory-scale
                  optional: true

            - name: VIRTENGINE_BID_PRICE_STORAGE_SCALE
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-storage-scale
                  optional: true

            - name: VIRTENGINE_BID_PRICE_SCRIPT_PATH
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-script-path
                  optional: true

            - name: VIRTENGINE_BID_PRICE_SCRIPT_PROCESS_LIMIT
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-script-process-limit
                  optional: true

            - name: VIRTENGINE_BID_PRICE_SCRIPT_PROCESS_TIMEOUT
              valueFrom:
                configMapKeyRef:
                  name: virtengine-provider-config
                  key: bid-script-process-timeout
                  optional: true
          ports:
            - name: gateway
              containerPort: 8443
          volumeMounts:
            - name: boot
              mountPath: /boot
              readOnly: true
            - name: keys
              mountPath: /boot-keys
              readOnly: true
      volumes:
        - name: boot
          configMap:
            name: virtengine-provider-boot
        - name: keys
          secret:
            secretName: virtengine-provider-keys
