我有一个 kubernetes 集群,每个节点上有 16Gb RAM
以及一个典型的 dotnet core webapi 应用程序
我尝试像这样配置限制:
apiVersion: v1
kind: LimitRange
metadata:
name: mem-limit-range
spec:
limits:
- default:
memory: 512Mi
defaultRequest:
memory: 256Mi
type: Container
Run Code Online (Sandbox Code Playgroud)
但我的应用程序相信可以使用 16Gb
因为cat /proc/meminfo | head -n 1
返回MemTotal: 16635172 kB
(或者可能来自 cgroups,我不确定)
所以..可能是限制不起作用?
不!K8s 在达到内存限制时成功杀死了我的 pod
.net core 有有趣的 GC 模式,更多细节在这里。这是一个很好的模式,但看起来它对 k8s 不起作用,因为应用程序获取了错误的内存信息。无限的 Pod 可以获得所有主机内存。但有限制——他们会死。
现在我看到两种方法:
如何在 Kubernetes 的 pod 中限制 .net core 应用程序的内存大小?
如何在 …
我们使用 swagger 来探索 api,有一次我们关闭了 razor。
这导致了招摇的问题
原始错误:
An unhandled exception occurred while processing the request.
DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'
on type 'Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator' can be invoked with the available services and parameters:
Cannot resolve parameter 'Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider apiDescriptionsProvider'
of constructor 'Void .ctor(Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider, Swashbuckle.AspNetCore.SwaggerGen.ISchemaRegistryFactory, Microsoft.Extensions.Options.IOptions`1[Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions])'.
Cannot resolve parameter 'Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider apiDescriptionsProvider'
of constructor 'Void .ctor(Microsoft.AspNetCore.Mvc.ApiExplorer.IApiDescriptionGroupCollectionProvider, Swashbuckle.AspNetCore.SwaggerGen.ISchemaRegistryFactory, Swashbuckle.AspNetCore.SwaggerGen.SwaggerGeneratorOptions)'.
Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable<Parameter> parameters)
Run Code Online (Sandbox Code Playgroud)