'Unable to access kubernetes pods using External IP
I am using imperative way (yaml files not used) to deploy the pod into cluster and expose it using LoadBalancer service to access it.. But unfortunately I am getting connection timeout issue.
My Docker file looks like:
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS base
WORKDIR /app
EXPOSE 80
ADD publish .
ENTRYPOINT ["dotnet", "DemoApi.dll"]
Note : Publish folder has all the libraries to run the exe..
Then I pushed that into docker hub.
I tried to run the image using the following two commands..
First created the pod in cluster as below.
kubectl run demo-api-pod --image ***/demoapi:2.0.0.2
Then tried to expose this pod using the service.
kubectl expose pod demo-api-pod --type=Loadbalancer --port=80 --name=demo-api-service
On running the "kuebctl get svc", I got the external IP. enter image description here
When I tried ot access http://20.195.35.174/weatherforecast, I received connection timeout issue.
I even tried setting the environment variable "ASPNETCORE_URLS" while running the pod.
kubectl run demo-api-pod --image ***/demoapi:2.0.0.2 --env="ASPNETCORE_URLS=80"
Even exposing the pod that was created as above was not accessible.
what is that I am missing here.. kindly help.
Solution 1:[1]
Thanks Oguzhan.. I was able to fix the issue by these two ways.
change the docker file base file from
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS base
to
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
The reason is, the first sdk doesnt have the "aspnetcore_urls" environment varibale set.
if we still wnat to proceed with the SDK image, then we need to add the environent variable manually in hte docker file or we can set it while running the image as below.
kubectl run demo-api-pod --image ***/demoapi:1.0.0.0 --env="ASPNETCORE_URLS=http://+:80"
Thanks..
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user14267126 |
