Errors discovered in K8s service
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I don't know if I'm using it wrong. When I used Aspire 13 service, I found that calling it locally was fine, but there were problems when I used K8s in the cluster. The approximate stack error is as follows:
-------------------------------------------------------------------------------------------------------------
info: System.Net.Http.HttpClient.Refit.Implementation.Generated+ZhongDeAspirePlatformServiceDefaultsRefitInterfaceCollectionsIApiService1, ZhongDeAspirePlatform.ServiceDefaults, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.LogicalHandler[100] Start processing HTTP request GET https+http://apiservice1/api/v1/WeatherForecast/Get info: System.Net.Http.HttpClient.Refit.Implementation.Generated+ZhongDeAspirePlatformServiceDefaultsRefitInterfaceCollectionsIApiService1, ZhongDeAspirePlatform.ServiceDefaults, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.ClientHandler[100] Sending HTTP request GET https://apiservice1/api/v1/WeatherForecast/Get info: System.Net.Http.HttpClient.Refit.Implementation.Generated+ZhongDeAspirePlatformServiceDefaultsRefitInterfaceCollectionsIApiService1, ZhongDeAspirePlatform.ServiceDefaults, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.ClientHandler[104] HTTP request failed after 47.6685ms System.Net.Http.HttpRequestException: Name or service not known (apiservice1:443) ---> System.Net.Sockets.SocketException (0xFFFDFFFF): Name or service not known
Explain a few things from the errors in the pod above:
1. BaseAddress = new Uri("https+ http://apiservice1 It has taken effect (the original https+http://can still be seen in the LogicalHandler).
Aspire's ServiceDiscovery has intervened and parsed it into a real request target https://apiservice1/... .
3. However, in the K8s container, the final solution is to use DNS resolution apiservice1->not have this name ->report Name or service not known (apiservice1:443).
That is to say, Aspire is already parsing the service name URI, but the parsing result is still host=apiservice1, which has not been mapped to the real K8s service name apiservice1-service.
----------------------------------------------------------------------------------------------------------------
config.yaml
apiVersion: "v1" kind: "ConfigMap" metadata: name: "apiservice1-config" labels: app.kubernetes.io/name: "zhongdeaspireplatform-apphost" app.kubernetes.io/component: "apiservice1" app.kubernetes.io/instance: "{{.Release.Name}}" data: OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES: "{{ .Values.config.apiservice1.OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EXCEPTION_LOG_ATTRIBUTES }}" OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES: "{{ .Values.config.apiservice1.OTEL_DOTNET_EXPERIMENTAL_OTLP_EMIT_EVENT_LOG_ATTRIBUTES }}" OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY: "{{ .Values.config.apiservice1.OTEL_DOTNET_EXPERIMENTAL_OTLP_RETRY }}" ASPNETCORE_FORWARDEDHEADERS_ENABLED: "{{ .Values.config.apiservice1.ASPNETCORE_FORWARDEDHEADERS_ENABLED }}" HTTP_PORTS: "{{ .Values.config.apiservice1.HTTP_PORTS }}" APISERVICE_HTTP: "{{ .Values.config.apiservice1.APISERVICE_HTTP }}" services__apiservice__http__0: "{{ .Values.config.apiservice1.services__apiservice__http__0 }}" APISERVICE_HTTPS: "{{ .Values.config.apiservice1.APISERVICE_HTTPS }}" services__apiservice__https__0: "{{ .Values.config.apiservice1.services__apiservice__https__0 }}"
--
----------------------------
If this error is caused by me not configuring the relevant code myself, please reply. If it is a bug, please let me know. I have already used the current project in the production environment and urgently need to solve it. Thank you
### Expected Behavior
_No response_
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version info
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.