How do I deploy this Traefik example to Kubernetes?

8/27/2018

I am following the Getting Started guide for Traefik from here and am trying to launch the service into Kubernetes (Minikube) instead of Docker:

Edit your docker-compose.yml file and add the following at the end of your file.
# ...
  whoami:
    image: emilevauge/whoami # A container that exposes an API to show its IP address
    labels:
      - "traefik.frontend.rule=Host:whoami.docker.localhost"**

I am guessing I run it as:

kubectl run whoami-service --image=emilevauge/whoami --labels='traefik.frontend.rule=Host:whoami.docker.localhost'

however that generates an error of:

The Deployment "whoami-service" is invalid:
* metadata.labels: Invalid value: "'traefik.frontend.rule": name part must consist of alphanumeric characters, '-', '_' or '.', and....

So what am I missing here? How do I deploy the above to my Minikube Kubernetes cluster?

-- TheEdge
kubernetes
traefik

1 Answer

8/27/2018

I'm not sure if this is along the lines of what you're looking for, but Traefik has a small tutorial for getting an Ingress controller set up on Kubernetes, with a great document on configuration, as well.

If you'd just like to get that particular image working, you may be able to pass the label as an argument to the pod, possibly with kubectl run. From the output of kubectl run help:

# Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>

Or possibly manually in a manifest:

...
containers:
  - name: whoami
    image: emilevauge/whoami
    args: ["traefik.frontend.rule: "Host:whoami.docker.localhost"]

Having never worked with the image in the example before, I don't know if either the above examples will actually work.

Hope that helps a little!

-- TheKLARKEN
Source: StackOverflow