Traefik as a reverse proxy on Kubernetes

Maciej
1 min readJul 15, 2020

--

I will present an example of the configuration, using traefik as a reverse proxy in Kubernetes instead of in Kubernetes mode.

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

--

--

Maciej
Maciej

Written by Maciej

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

No responses yet