0

I'm trying to run .NET Core 2 Docker images in Kubernetes using Azure Container Service and Azure Container Registry.

I have successfully created a pod & is running perfectly. Later I deployed a service using command kubectl expose deployment depl-name --type=LoadBalancer --port=8086 --target-port=8086 & I checked service details using command kubectl get services but the external IP exposed by Azure is not working at all. I tried to ping that IP as well but it says request timeout. I can see, application/port everything is up & okay.

Please check snaps following:

enter image description here

enter image description here

enter image description here

enter image description here

I do not follow why the public IP exposed by Azure container service does not work even when an application is running without errors on kubernetes cluster. Please let me know if anything has gone wrong.

Thanks,

Tejas Bramhecha
  • 880
  • 5
  • 19
  • I am not sure about azure. Never used. But i think you have to enable/expose/something-like-this in your azure platform. Things are OK from k8s site – Shahriar Feb 02 '18 at 12:52

2 Answers2

0

The command you used does not match the output from "kubectl get services". You used --port=8080 which is saying to publicly expose port 8080 yet the get services call shows port 80 being exposed. They don't match, so this doesn't make sense. You also didn't tell kubectl what port on the container to map to, not sure what the default would be. Try this instead:

kubectl expose deployment depl-name --type=LoadBalancer --port=80 --target-port=80

Replacing the correct port numbers for your scenario of course. If it's still not working go into the Azure Portal and look at your cluster. You should see a new Load Balancer (the one without k8s-master in the name). Open it up and inspect the load balancing rules.

BrettRobi
  • 3,793
  • 7
  • 40
  • 64
  • Hello @BrettRobi, I tried doing what you have suggested. It says IP didn't send any data. I tried to ping extenal IP exposed by Azure, it still says, request timed out. As I'm new to it, is there any documentation available for inspecting load balancing rules in Azure? – Tejas Bramhecha Feb 05 '18 at 05:17
  • Echoing what @BrettRobi said, your expose command is not matching your pod ports. You should do something like `kubectl expose deployment depl-name --type=LoadBalancer --port=8086 --target-port=80` since your Pod appears to be listening on port 80. – sabbour Feb 05 '18 at 12:51
  • @TejasBramhecha have you verified the ports you are trying to use? I suspect this is the problem as the command is pretty straightfoward. Make sure your container is exposing the port you specify with --target-port, and of course make sure you're hitting the port specified with --port. Also do be aware that ping uses ICMP and simply exposing port 80 won't allow a ping to work. Instead test with curl or your browser if you're exposing http. – BrettRobi Feb 05 '18 at 17:10
  • @sabbour, I tried updating command & run it again but alas! it didn't work now too. I used curl command as well, it says failed to connect & so instead, I tried doing the same setup at minikube & when I try running `http://localhost:80/ui`, it says, `Error: tls: oversized record received with length 20527 Trying to reach: https://172.17.0.3:9090/` – Tejas Bramhecha Feb 12 '18 at 09:04
  • I'm confused what are you trying to do here. This link is the old link for the dashboard. What does it have to do with the expose command? – sabbour Feb 13 '18 at 11:52
  • @sabbour Okay, let's forget about minikube & localhost. Is there any other solution to make this azure exposed ip work? – Tejas Bramhecha Feb 15 '18 at 09:19
0

Can you verify what deployments you have in your cluster

kubectl get deployments --all-namespaces

You should get a list like this

NAMESPACE     NAME                      DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
default       my-deployment             1         1         1            1           28m

Then, expose the desired deployment

kubectl expose deployment my-deployment --type=LoadBalancer --port=8086 --target-port=80 --name=my-service

You should now be able to access the pod by browsing to 13.65.243.33:8086. If it's not working, check if your container is actually reacting on incoming requests on port 80.

Christian Vorhemus
  • 2,396
  • 1
  • 17
  • 29