How can I use "System.Environment.MachineName" in a ASP Net Core Application running over Kubernetes?

2/24/2022

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
asp.net-core
kubernetes

0 Answers