apiVersion: v1
kind: Service
metadata:
  name: <<appenv>>render-engine
  namespace: <<appenv>>tdb-render-engine
  labels:
    app: <<appenv>>render-engine
    service: <<appenv>>render-engine
spec:
  ports:
    - port: 80
      name: http-<<appenv>>render-engine
  selector:
    app: <<appenv>>builder-be
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: <<appenv>>render-engine-sync-role-bd
  namespace: <<appenv>>tdb-render-engine
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: <<appenv>>render-engine-sync-role
subjects:
  - kind: ServiceAccount
    name: default
---

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: ovh-vars
  namespace: <<appenv>>tdb-render-engine
data:
  OVH_OBJECT_STORAGE: '<<appenv>>OvhObjectStorageS3:<<appenv>>builder-static'
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: <<appenv>>rclone-config
  namespace: <<appenv>>tdb-render-engine
data:
  rclone.conf: |
    [<<appenv>>OvhObjectStorageS3]
    type = s3
    provider = Other
    env_auth = false
    access_key_id = e3b65854d79f4f3ba910f5dcadd124be
    secret_access_key = c2d9ff38c2104310a91f1adbcdc29307
    acl = private
    region = sbg
    location_constraint = sbg
    endpoint = https://s3.sbg.io.cloud.ovh.net
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: <<appenv>>tdb-render-engine
  namespace: <<appenv>>tdb-render-engine
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: <<appenv>>render-engine
      version: v1
  template:
    metadata:
      name: <<appenv>>render-engine
      labels:
        app: <<appenv>>render-engine
        version: v1
    spec:
      containers:
        - name: render-engine
          image: docker.adaoncloud.com/ada/<<appenv>>render-engine:<<imagetag>>
          env:
            - name: ADA_APP_ENV
              value: <<appenv>>
            - name: ADA_POD_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
            - name: ELASTIC_HOST
              value: 'https://ada-elastic-es-http.sta-ada-elastic.svc.cluster.local:9200'
            - name: ELASTIC_REJECTUNAUTHORIZED
              value: 'true'
            - name: ELASTIC_USERNAME
              valueFrom:
                secretKeyRef:
                  name: tdb-logs-es-user-rw
                  key: username
                  optional: false
            - name: ELASTIC_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: tdb-logs-es-user-rw
                  key: password
                  optional: false
            - name: KAFKA_SERVER
              value: 'ada-cluster-kafka-bootstrap.sta-ada-kafka-cluster.svc.cluster.local:9093'
            - name: KAFKA_USERNAME
              valueFrom:
                secretKeyRef:
                  name: kafka-render-engine-user
                  key: username
                  optional: false
            - name: KAFKA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: kafka-render-engine-user
                  key: password
                  optional: false
            - name: KAFKA_CLIENTID
              valueFrom:
                secretKeyRef:
                  name: kafka-render-engine-user
                  key: clientid
                  optional: false
            - name: KAFKA_TOPIC
              valueFrom:
                secretKeyRef:
                  name: kafka-render-engine-user
                  key: topic
                  optional: false
            - name: KAFKA_GROUPID
              valueFrom:
                secretKeyRef:
                  name: kafka-render-engine-user
                  key: groupid
                  optional: false
            - name: FSTLOGLEVEL
              value: info
            - name: NODE_ENV
              value: sta
            - name: OVH_OBJECT_ENABLE
              value: '1'
            - name: OVH_OBJECT_STORAGE
              valueFrom:
                configMapKeyRef:
                  name: ovh-vars
                  key: OVH_OBJECT_STORAGE
            - name: ADA_BUILDER_STATIC_URL
              value: https://builder-static.staging.adaoncloud.com
            - name: ADA_BUILDER_BE_URL
              value: http://sta-builder-be.sta-builder-be.svc.cluster.local
            - name: ADA_GALLERY_BE_URL
              value: http://sta-gallery-be.sta-gallery-be.svc.cluster.local
            - name: TDB_OAUTH_URL
              value: https://tdb-oauth.staging.adaoncloud.com
            - name: TDB_OAUTH_DISABLE
              value: '0'
          ports:
            - containerPort: 80
          volumeMounts:
            - name: config
              mountPath: 'root/.config/rclone'
              readOnly: true
          imagePullPolicy: Always
      restartPolicy: Always
      imagePullSecrets:
        - name: ada-registry
      volumes:
        - name: config
          configMap:
            name: <<appenv>>rclone-config
