1

I have the following situation. I am using an ASP.Net Core API and I need to get the name of the machine executing calls.

I am using the following code:

var machine = System.Environment.MachineName;

If I run the API solution locally in my machine I get the name of this:

"L10PCXXXXXXX"

But if I run the API as a pod over Kubernetes I get the name of the pod:

"api-test-75575d9d8b-ckjkp"

My question is, how I can get the full name considering the execution over Kubernetes?

Thanks!

Fernhunt
  • 11
  • 1
  • 1
    This is the expected behaviour. System.Environment.MachineName is correctly showing the name of the Pod as the Pod is "the name of the machine executing calls". What "machine" do you want? The Pod, the Node, the cluster? What environment are you running your K8s cluster? Why do you need the System.Environment.MachineName? – Robin Webb Feb 25 '22 at 08:40
  • @RobinWebb probably is the expected behaviour of the API running under K8S. But I would like to have the name of machine of the user that makes the call. It will be possible ? Thanks – Fernhunt Mar 01 '22 at 15:44
  • Could you try Dns.GetHostEntry(HttpContext.Connection.RemoteIpAddress).HostName; https://stackoverflow.com/questions/50742479/how-to-get-a-clients-computer-name-in-asp-net-core – Robin Webb Mar 01 '22 at 16:30

0 Answers0