apiVersion: v1
kind: ServiceAccount
metadata:
  name: sta-tdb-tinyurl
  namespace: sta-tdb-tinyurl
---
apiVersion: v1
kind: Service
metadata:
  name: sta-tdb-tinyurl
  namespace: sta-tdb-tinyurl
  labels:
    app: sta-tdb-tinyurl
    service: sta-tdb-tinyurl
spec:
  ports:
    - port: 8080
      name: http-sta-tdb-tinyurl
  selector:
    app: sta-tdb-tinyurl
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sta-tdb-tinyurl
  namespace: sta-tdb-tinyurl
spec:
  replicas: 1
  revisionHistoryLimit: 3
  selector:
    matchLabels:
      app: sta-tdb-tinyurl
  template:
    metadata:
      name: sta-tdb-tinyurl
      labels:
        app: sta-tdb-tinyurl
    spec:
      serviceAccountName: sta-tdb-tinyurl
      containers:
        - name: tdb-tinyurl
          image: docker.adaoncloud.com/tdb/sta-tdb-tinyurl:<<imagetag>>
          ports:
            - containerPort: 8080
          imagePullPolicy: Always
          env:
            - name: CASSANDRA_DC
              value: sta-ada-dc1
            - name: CASSANDRA_KS
              value: tdb_tinyurl
            - name: CASSANDRA_HOST_URL
              value: cassandradb4.sta-ada-cassandradb.svc.cluster.local
            - name: CASSANDRA_HOST_PORT
              value: "9042"
            - name: CASSANDRA_USERNAME
              valueFrom:
                secretKeyRef:
                  name: cassandra-adaclient
                  key: username
                  optional: false
            - name: CASSANDRA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: cassandra-adaclient
                  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-tinyurl-user
                  key: username
                  optional: false
            - name: KAFKA_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: kafka-tinyurl-user
                  key: password
                  optional: false
            - name: KAFKA_CLIENTID
              valueFrom:
                secretKeyRef:
                  name: kafka-tinyurl-user
                  key: clientid
                  optional: false
            - name: KAFKA_TOPIC
              valueFrom:
                secretKeyRef:
                  name: kafka-tinyurl-user
                  key: topic
                  optional: false
            - name: KAFKA_GROUPID
              valueFrom:
                secretKeyRef:
                  name: kafka-tinyurl-user
                  key: groupid
                  optional: false
            - name: DEFAULT_DOMAIN
              value: staging.adaon.eu
            - name: FSTLOGLEVEL
              value: info
      restartPolicy: Always
      imagePullSecrets:
        - name: ada-registry
