Traefik as a reverse proxy on Kubernetes

Deployment settings

spec:
containers:
- image: traefik:v2.2.5
name: traefik-proxy
resources:
limits:
cpu: 0.1
memory: 128Mi
command:
- "sh"
- "-c"
- "traefik"

Traefik settings

Example of toml which is using for running traefik as a reverse proxy:

apiVersion: v1
kind: ConfigMap
metadata:
name: traefik-proxy-config
data:
traefik.toml: |
defaultEntryPoints = ["http","https"]
logLevel = "INFO"

[file]
[entryPoints]
[entryPoints.http]
address = ":80"

[entryPoints.https]
address = ":443"


[frontends]
[frontends.some_front_end]
entrypoints = ["http"]
backend = "some_back_end"

[backends]
[backends.some_backend]
[backends.some_backend.servers.some_service]
passHostHeader = true
weight = 1
url = "http://some-service:80"

[accessLog]
format = "json"
filePath = "/mnt/log/access.log"

Explanations of settings

  • [file]Is required when setting forntend/backend in file
  • passHostHeader = trueIf not set, the Host header will be cut off, so depending on the configuration it will be addicted
  • some_front_end, some_back_end, some_servicecan be replaced with any name
  • If you do not describe the load-balancing method, the default load-balancing wrr. Therefore, weight=Nsetting of mandatorywrrthis is Weighted Round-robin

 by the author.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maciej

Maciej

DevOps Consultant. I’m strongly focused on automation, security, and reliability.