K8s namer to map a service to set of pods

I have the following setup on my k8s env,

hello-world app
I have three applications, hello-world01, hello-world02, hello-world03 (each with single replica) deployed as pod in default namespace in my k8s environment

response and behavior of hello-world app
All the three apps responds similarly with different success rates

  • hello-world01 - 100% success
  • hello-world02 - 100% success
  • hello-world03 - 0% success (returns 500 internal server error)

I deployed linkerd on the same env as daemonset in default namespace

below is my dtab configuration, I need service1 to map to the 3 pods (hello-world01, hello-world02, hello-world03)

  dtab: |
    /srv        => /#/io.l5d.k8s/default/http;
    /host       => /srv;
    /svc        => /host;
    /host/world => /srv/service1;

what should be my namer configuration in order to map the service1 -> hello-world01, hello-world02, hello-world03?

Hey @zshaik – you would want to handle this by way of a Kubernetes Service object. If you create a service called service1 in the default namespaces with a port called http, then the dtab that you pasted should successfully route traffic to all pods backed by your service.

Your service will end up looking something like this:

apiVersion: v1
kind: Service
  name: service1
    app: service1
  clusterIP: None
  - name: http
    port: 7777

You’ll need to apply a different selector though to select over pods started by different replication controllers. Checkout the Kubernetes docs on working with Label & Selectors.

1 Like

@klingerf Awesome! exactly what I was looking for, the LABELS!! I finally got the setup I was looking for,
A picture is better than thousand words, Thank you.

1 Like