Reputation: 733
I seem to have an issue with my C# applications that I containerize and put into pod, cant seem to reach services withing the cluster?
I made a simple code example
using System;
using System.Net.NetworkInformation;
namespace pingMe
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
Ping ping = new Ping();
PingReply pingresult = ping.Send("example-service.default.svc");
if (pingresult.Status.ToString() == "Success")
{
Console.WriteLine("I can reach");
}
}
}
}
which should be able to ping this within the cluster
PS C:\Helm> kubectl apply -f https://k8s.io/examples/service/access/hello-application.yaml
deployment.apps/hello-world created
PS C:\Helm> kubectl expose deployment hello-world --type=ClusterIP --name=example-service
service/example-service exposed
PS C:\Helm> kubectl get service/example-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
example-service ClusterIP 10.97.171.216 <none> 8080/TCP 14s
PS C:\Helm> kubectl get deployment.apps/hello-world
NAME READY UP-TO-DATE AVAILABLE AGE
hello-world 2/2 2 2 61s
but In the cluster I get this:
Hello World!
Unhandled exception. System.Net.NetworkInformation.PingException: An exception occurred during a Ping request.
---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000005, 0xFFFDFFFF): Name or service not known
at System.Net.Dns.InternalGetHostByName(String hostName)
at System.Net.Dns.GetHostAddresses(String hostNameOrAddress)
at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
--- End of inner exception stack trace ---
at System.Net.NetworkInformation.Ping.GetAddressAndSend(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress, Int32 timeout, Byte[] buffer, PingOptions options)
at System.Net.NetworkInformation.Ping.Send(String hostNameOrAddress)
at pingMe.Program.Main(String[] args) in /src/pingMe/Program.cs:line 12
How come... Adding the port number does not help..
Upvotes: 2
Views: 934
Reputation: 81
On the surface it all looks OK. I would start debugging by eliminating possibilities. From the "worker" pod can you ping the ClusterIP and not the service name? Can you successfully do a DNS lookup on any service or pod? If you can access the Cluster IP, but pinging or resolving the service name continues to fail then DNS seems more suspect.
Upvotes: 1