5

Created a deployment on Google Kubernetes using jaegertracing/all-in-one public image from Docker Hub

Then, exposed the deployment with Service type as LoadBalancer.

Now, launched the Jagger UI and it is working, but it do not show any service except jagger-query.

I have deployed my .net web api application for testing on kubernetes.

My application has only one single web API which is successfully running on Google Kubernetes engine and exposed via load balancer service type. The API has all the data hard-coded and do not call any other service or database.

Used following nuget packages in the project:

Jaeger -Version 0.2.2
OpenTracing.Contrib.NetCore -Version 0.5.0

I have added following code in Startup.cs file of my API:

    services.AddSingleton<ITracer>(serviceProvider =>
    {
        //string serviceName = Assembly.GetEntryAssembly().GetName().Name;
        string serviceName = serviceProvider.GetRequiredService<IHostingEnvironment>().ApplicationName;

        ILoggerFactory loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();

        ISampler sampler = new ConstSampler(sample: true);

        string jaegerHost = Environment.GetEnvironmentVariable("jaeger_host");

        var reporter = new RemoteReporter.Builder()
            .WithLoggerFactory(loggerFactory)
            .WithSender(new UdpSender(jaegerHost, 6831, 0)) // todo: 
            .Build();

        ITracer tracer = new Tracer.Builder(serviceName)
            .WithLoggerFactory(loggerFactory)
            .WithSampler(sampler)
            .WithReporter(reporter)
            .Build();

        GlobalTracer.Register(tracer);

        return tracer;
    });

    services.AddOpenTracing();

jaegerHost environment variable is assigned the IP of the jaeger service created.

The question is how and where to make changes so that my application service gets available in the Jaeger UI, so that I can see it's traces.

I am stuck here, can anyone please help how to proceed ahead?

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
CodeZila
  • 919
  • 2
  • 14
  • 31
  • Does your application consists of separately deployed frontend and backend parts ? As far as I understand you your frontend Pods do their job and you were able to successfully exposed them via LoadBalancer service. Are they communicating with some backend Pods ? Have you defined any additional services to expose backend Pods to frontend ones ? – mario Jun 05 '20 at 18:36
  • @mario My application has only one single web API which is successfully running on Google Kubernetes engine and exposed via load balancer service type. The API has all the data hard-coded and do not call any other service or database. But, the service is not visible on Jagger UI. – CodeZila Jun 06 '20 at 01:24
  • @mario plz check my update in the question – CodeZila Jun 06 '20 at 20:23
  • _"jaegerHost environment variable is assigned the IP of the jaeger service created."_ - do you mean kubernetes `Service` in this context ? Could you also say a bit more on how you've deployed it on kubernetes ? Is it managed by a `Deployment` or maybe a `StatefulSet`? I'm not sure if you don't have to set `jaegerHost` via `jaeger_host` env var rather to `Pod`'s FQDN... I guess it needs to be able to bind to host address. Maybe even localhost will be the correct value ? And one more detail... have you set "jaeger_host" env var or `jaegerHost` as you wrote in your question ? – mario Jun 10 '20 at 16:39

1 Answers1

2

The jaeger-agent service should look like

apiVersion: v1
kind: Service
metadata:
  name: jaeger-agent
  namespace: jaeger
  labels:
    app: jaeger
    app.kubernetes.io/name: jaeger
    app.kubernetes.io/component: agent
spec:
  type: LoadBalancer
  ports:
  - name: agent-compact
    port: 6831
    protocol: UDP
    targetPort: 6831
  - name: agent-binary
    port: 6832
    protocol: UDP
    targetPort: 6832
  - name: agent-configs
    port: 5778
    protocol: TCP
    targetPort: 5778
  selector:
    app.kubernetes.io/name: jaeger
    app.kubernetes.io/component: all-in-one

Don't use IP, use FQDN. First, try to hardcode value for jaegerHost

string jaegerHost = "jaeger-agent.jaeger";

where jaeger-agent - service name, jaeger - namespace of service

Also, you should create jaeger-collector service

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116