---
kind: Namespace
apiVersion: v1
metadata:
  name: traefik

---
kind: ServiceAccount
apiVersion: v1
metadata:
  name: traefik
  namespace: traefik

---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: traefik
  namespace: traefik
  labels:
    app: traefik
spec:
  replicas: 1
  selector:
    matchLabels:
      app: traefik
  template:
    metadata:
      labels:
        app: traefik
    spec:
      serviceAccountName: traefik
      containers:
        - name: traefik
          image: traefik/traefik:latest
          imagePullPolicy: Never
          args:
            - --api.insecure
            - --log.level=debug
            - --entrypoints.pweb.address=:80
            - --entrypoints.pwebsecure.address=:443
            - --entrypoints.privweb.address=:8080
            - --entrypoints.privwebsecure.address=:4443
            - --entrypoints.traefik.address=:9000
            - --experimental.knative
            - --providers.knative.publicEntrypoints=pweb,pwebsecure
            - --providers.knative.publicService.namespace=traefik
            - --providers.knative.publicService.name=traefik
            - --providers.knative.privateEntrypoints=privweb,privwebsecure
            - --providers.knative.privateService.namespace=traefik
            - --providers.knative.privateService.name=privtraefik
            - --providers.knative.throttleduration=2s

          ports:
            - name: pweb
              containerPort: 80
            - name: pwebsecure
              containerPort: 443
            - name: privweb
              containerPort: 8080
            - name: privwebsecure
              containerPort: 4443
            - name: traefik
              containerPort: 9000

---
apiVersion: v1
kind: Service
metadata:
  name: traefik
  namespace: traefik
spec:
  type: LoadBalancer
  selector:
    app: traefik
  ports:
    - port: 80
      name: web
      targetPort: pweb
    - port: 443
      name: websecure
      targetPort: pwebsecure
    - port: 9000
      name: traefik
      targetPort: traefik

---
apiVersion: v1
kind: Service
metadata:
  name: privtraefik
  namespace: traefik
spec:
  selector:
    app: traefik
  ports:
    - port: 80
      name: web
      targetPort: privweb
    - port: 443
      name: websecure
      targetPort: privwebsecure
