Problem
You want to use Traefik to expose your app. You also want to use custom certificate, path routing, redirect to HTTPs, and compress traffic.
Solution
The following example uses IngressRoute
and two Middleware
s to achieve the goal:
apiVersion: traefik.containo.us/v1alpha1 kind: IngressRoute metadata: name: my-app-secure namespace: my-app spec: entryPoints: - websecure routes: - kind: Rule match: Host(`example.com`) && PathPrefix(`/app`) priority: 10 middlewares: - name: redirect-https namespace: my-app - name: compress namespace: my-app services: - kind: Service name: my-app namespace: my-app passHostHeader: true port: 8080 scheme: http strategy: RoundRobin weight: 10 tls: secretName: supersecret --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: name: redirect-https namespace: my-app spec: redirectScheme: scheme: https permanent: true --- apiVersion: traefik.containo.us/v1alpha1 kind: Middleware metadata: name: compress namespace: my-app spec: compress: {}
These are Traefik-specific custom resources. Please, find more information here: https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/.