how to convert docker-compose.yaml to kubernetes.yaml of traefik

8/3/2021

I wanna using traefik auto discovery kubernetes service. The docker-compose.yaml is like this:

version: "3.3"

services:

  traefik:
    image: "traefik:v2.5"
   version: "3.3"

services:

  whoami:
    image: "traefik/whoami"
    container_name: "simple-service"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.com`)"
      - "traefik.http.routers.whoami.entrypoints=web"

And run docker-compose up -d is working,the whoami.com discoveried.

But when I convert this to kubernetes yaml,I got error with labels, How can I write the labels on kubernetes yaml.

labels:
  - "traefik.enable=true"
  - "traefik.http.routers.whoami.rule=Host(`whoami.com`)" 
  -  "traefik.http.routers.whoami.entrypoints=web"
-- Michael
kubernetes
traefik

1 Answer

8/3/2021

Check out Kompose.

It will help generate some stuff for you. But specifically with Traefik you'll have to move to either the Ingress system or Traefik's custom IngressRoute system. See this doc for the former and the latter is linked in the sidebar there.

-- coderanger
Source: StackOverflow