---
kind: Deployment
apiVersion: apps/v1
metadata:
  name: gopy
  labels:
    app: gopy
spec:
  replicas: 3
  selector:
    matchLabels:
      app: gopy
  template:
    metadata:
      labels:
        app: gopy
    spec:
      containers:
      - name: gopy
        image: docker.dezendorf.net/gopy:bb7d1a0
        ports:
        - name: web
          containerPort: 5000

---
apiVersion: v1
kind: Service
metadata:
  name: gopy
spec:
  type: ClusterIP
  ports:
    - name: web
      port: 5000
  selector:
    app: gopy
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: gopy-ingress-route
  namespace: default
spec:
  entryPoints:
    - web
  routes:
  - match: ((Host(`go`)||Host(`go.dezendorf.net`))) && Path(`/list`)
    kind: Rule
    priority: 5
    middlewares:
      - name: gopyhttpsgofqdn
    services:
    - name: gopy
      port: 5000
  - match: ((Host(`go`)||Host(`go.dezendorf.net`))) && Path(`/{url:.*}/edit`)
    kind: Rule
    priority: 4
    middlewares:
      - name: gopyhttpsgofqdn
    services:
    - name: gopy
      port: 5000
  - match: ((Host(`go`)||Host(`go.dezendorf.net`))) && Path(`/{url:.*}/add`)
    kind: Rule
    priority: 3
    middlewares:
      - name: gopyhttpsgofqdn
    services:
    - name: gopy
      port: 5000
  - match: ((Host(`go`)||Host(`go.dezendorf.net`))) && Path(`/{url:.*}/delete`)
    kind: Rule
    priority: 2
    middlewares:
      - name: gopyhttpsgofqdn
    services:
    - name: gopy
      port: 5000
  - match: ((Host(`go`)||Host(`go.dezendorf.net`)))
    kind: Rule
    priority: 1
    services:
    - name: gopy
      port: 5000
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
  name: gopy-websecure-route
  namespace: default
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`go.dezendorf.net`)
    kind: Rule
    middlewares:
    - name: authelia
    services:
    - name: gopy
      port: 5000
  tls:
    certResolver: myresolver
---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: gopyhttpsgofqdn
spec:
  redirectRegex:
    regex: "^http(s)?://(go(.dezendorf.net)?)/(.+)?$"
    replacement: "https://go.dezendorf.net/${4}"
