---
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
  name: timer-source
spec:
  definition:
    description: Send message in frequency specified by period
    properties:
      message:
        default: '{"msg": "hello"}'
        example: hello world
        title: Message
        type: string
      period:
        default: "5000"
        title: Period
        type: integer
    required:
    - message
    title: Custom timer source
  flow:
    from:
      parameters:
        period: '#property:period'
      steps:
      - set-body:
          constant: '{{message}}'
      - to: kamelet:sink
      uri: timer:tick
  types:
    out:
      mediaType: text/plain
---
apiVersion: messaging.knative.dev/v1
kind: InMemoryChannel
metadata:
  name: mychannel
spec: {}
---
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: timer-to-inmem
spec:
  sink:
    ref:
      apiVersion: messaging.knative.dev/v1
      kind: InMemoryChannel
      name: mychannel
  source:
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: timer-source
---
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: inmem-to-mariadb-sink
spec:
  sink:
    properties:
      databaseName: testdb
      password: supersecret
      query: INSERT INTO test (msg) VALUES (:#msg)
      serverName: mariadb-tnb
      username: testuser
    ref:
      apiVersion: camel.apache.org/v1alpha1
      kind: Kamelet
      name: mariadb-sink
  source:
    ref:
      apiVersion: messaging.knative.dev/v1
      kind: InMemoryChannel
      name: mychannel
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: mariadb-tnb
  name: mariadb-tnb
spec:
  progressDeadlineSeconds: 600
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: mariadb-tnb
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mariadb-tnb
    spec:
      containers:
      - env:
        - name: MYSQL_USER
          value: testuser
        - name: MYSQL_DATABASE
          value: testdb
        - name: MYSQL_PASSWORD
          value: supersecret
        image: registry.redhat.io/rhel8/mariadb-103:latest
        imagePullPolicy: IfNotPresent
        name: mariadb-tnb
        ports:
        - containerPort: 3306
          name: mariadb-tnb
          protocol: TCP
        readinessProbe:
          failureThreshold: 6
          initialDelaySeconds: 5
          periodSeconds: 10
          successThreshold: 1
          tcpSocket:
            port: mariadb-tnb
          timeoutSeconds: 5
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: mariadb-tnb
  name: mariadb-tnb
spec:
  ports:
  - name: mariadb-tnb
    port: 3306
    protocol: TCP
    targetPort: 3306
  selector:
    app: mariadb-tnb
  type: ClusterIP
---
