apiVersion: template.openshift.io/v1
kind: Template
metadata:
  name: example-app-template
labels:
  template: example-app-template
objects:


  - kind: Deployment
    apiVersion: apps/v1
    metadata:
      name: example-app
      namespace: ${NAMESPACE}
      labels:
        app: example-app
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: example-app
      template:
        metadata:
          labels:
            app: example-app
        spec:
          containers:
            - resources:
                limits:
                  cpu: 1000m
                  memory: 1024Mi
                requests:
                  cpu: 500m
                  memory: 512Mi
              terminationMessagePath: /dev/termination-log
              name: apicurio-registry-examples-debezium-openshift
              env:
                - name: MYSQL_USER
                  value: ${MYSQL_USER}
                - name: MYSQL_PASSWORD
                  value: ${MYSQL_PASSWORD}
                - name: MYSQL_JDBC_URL
                  value: jdbc:mysql://example-components-mysql.${NAMESPACE}.svc.cluster.local/${MYSQL_DATABASE}
                - name: KAFKA_BOOTSTRAP_SERVERS
                  value: example-components-kafka-kafka-bootstrap.${NAMESPACE}.svc:9092
                - name: REGISTRY_URL
                  value: http://example-components-registry-service.${NAMESPACE}.svc.cluster.local:8080/apis/registry/v2
              ports:
                - containerPort: 8080
                  protocol: TCP
              imagePullPolicy: Always
              terminationMessagePolicy: File
              image: ${APP_IMAGE_GROUP}/apicurio-registry-examples-debezium-openshift:latest
              securityContext:
                allowPrivilegeEscalation: false
                runAsNonRoot: true
                capabilities:
                  drop:
                    - ALL
                seccompProfile:
                  type: RuntimeDefault
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          dnsPolicy: ClusterFirst
          securityContext: { }
          schedulerName: default-scheduler
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxUnavailable: 25%
          maxSurge: 25%
      revisionHistoryLimit: 10
      progressDeadlineSeconds: 600


  - kind: Service
    apiVersion: v1
    metadata:
      name: example-app-service
      namespace: ${NAMESPACE}
      labels:
        app: example-app
    spec:
      selector:
        app: example-app
      ports:
        - protocol: TCP
          port: 8080
          targetPort: 8080


  - kind: Ingress
    apiVersion: networking.k8s.io/v1
    metadata:
      name: example-app
      namespace: ${NAMESPACE}
    spec:
      rules:
        - host: >-
            example-app.${NAMESPACE}.${INGRESS_ROUTER_CANONICAL_HOSTNAME}
          http:
            paths:
              - path: /
                pathType: Prefix
                backend:
                  service:
                    name: example-app-service
                    port:
                      number: 8080


parameters:
  - name: NAMESPACE
    required: true
  - name: MYSQL_DATABASE
    value: inventory
    required: true
  - name: MYSQL_USER
    value: mysqluser
    required: true
  - name: MYSQL_PASSWORD
    value: mysqlpassword
    required: true
  - name: APP_IMAGE_GROUP
    required: true
  - name: INGRESS_ROUTER_CANONICAL_HOSTNAME
    # Find out from a status block of any Ingress or Route resource, e.g.:
    # status:
    #  loadBalancer:
    #    ingress:
    #      - hostname: router-default.apps.mycluster.com
    required: true
