Skip to content

Instantly share code, notes, and snippets.

@carlosgrillet
Last active June 13, 2025 17:54
Show Gist options
  • Select an option

  • Save carlosgrillet/4875672cf457de98b4e0682bf908e022 to your computer and use it in GitHub Desktop.

Select an option

Save carlosgrillet/4875672cf457de98b4e0682bf908e022 to your computer and use it in GitHub Desktop.
How to deploy Traefik in Kubernetes

How to deploy Traefik in kubernetes

Warning

At this point you should already have access to your kubernetes cluster in the cloud.

Tip

This example was tested on Linode (Akamai Cloud)

To install traefik on kubernetes, we are going to use helm. Follow the link see how to install it on your system, once done, we can now proceed.

Add Traefik Labs chart repository to Helm:

helm repo add traefik https://traefik.github.io/charts

You can update the chart repository by running:

helm repo update

Create the values to configure traefik installation

touch traefik-values.yml

add this content to the file

ports:
  web:
    redirections:
      to: websecure
      schema: https
  websecure:
    tls:
      enabled: true
      certResolver: letsencrypt

certificatesResolvers:
  letsencrypt:
    acme:
      email: <your-email@mail.com>
      storage: /data/acme.json
      tlsChallenge: true

You can take a look at all the possible values here traefik-helm-chart values. Also here you have some more examples of configuration traefik-helm-chart examples

Install traefik with the values

Now let's install traefik in a namespace called traefik

Note

This will create a load balancer in you cloud service.

helm install traefik traefik/traefik --create-namespace --namespace traefik --values traefik-values.yml

to check that everithing is correct run this command

kubectl get pods -n traefik

and then

kubectl logs -n traefik <pod-name>

Deploy a service

let's deploy a simple nginx service

  1. create a deployment manifest
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
kubectl apply -f nginx-deployment.yml
  1. create a service manifest
apiVersion: v1
kind: Service
metadata:
  name: nginx-service
  labels:
    app: nginx
spec:
  selector:
    app: nginx
  ports:
    - name: http
      port: 80
      targetPort: 80
  type: ClusterIP
kubectl apply -f nginx-service.yml
  1. create a traefik ingressRoute manifest
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
  name: nginx-ingressroute
  labels:
    app: nginx
spec:
  entryPoints:
    - websecure
  routes:
  - match: Host(`<your-domain-here.com>`)
    kind: Rule
    services:
    - name: nginx-service
      port: 80
  tls:
    certResolver: letsencrypt
kubectl apply -f nginx-ingressroute.yml

Note

Don't forget to create the dns record that points the requested URL to your load balancer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment