apiVersion: v1
kind: Service
metadata:
  name: kafka-service
  labels:
    app: kafka
spec:
  ports:
  - port: 9092
  selector:
    app: kafka
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka
  template:
    metadata:
      labels:
        app: kafka
    spec:
      containers:
      - name: kafka
        image: ubuntu/kafka:edge
        env:
          - name: ZOOKEEPER_HOST
            value: zookeeper-service
        args: ["/etc/kafka/server.properties", "--override", "advertised.listeners=PLAINTEXT://kafka-service:9092"]
        ports:
        - containerPort: 9092
          name: kafka
          protocol: TCP
        volumeMounts:
        - mountPath: /var/lib/kafka/data
          name: kafka-data
          subPath: kafka/data
      volumes:
      - name: kafka-data
        persistentVolumeClaim:
          claimName: kafka-pvc
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-ui
  labels:
    app: kafka-ui
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kafka-ui
  template:
    metadata:
      labels:
        app: kafka-ui
    spec:
      containers:
      - name: kafka-ui
        image: provectuslabs/kafka-ui
        ports:
        - containerPort: 8080
        env:
        - name: KAFKA_CLUSTERS_0_NAME
          value: "kafka-service"
        - name: KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS
          value: "kafka-service:9092"
---
apiVersion: v1
kind: Service
metadata:
  name: kafka-ui
  labels:
    name: kafka-ui
spec:
  type: NodePort
  ports:
    - port: 8080
      nodePort: 31890
      name: http
  selector:
    app: kafka-ui
---
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: kafka-ui-tls-allarddcs
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`kafka-prod.allarddcs.nl`)
    kind: Rule
    services:
    - name: kafka-ui
      port: 8080
  tls:
    certResolver: letsencrypt
