识别 C#-client 中 kubernetes 部署规范中的错误字段

LM1*_*M10 1 .net kubernetes

我正在尝试使用 Kubernetes 的 C# 客户端定义部署规范。我的规范字段的值是由其他一些应用程序生成的。因此,部署有时会失败,并且出现Unprocessable entity(Microsoft.Rest.HttpOperationException) 错误。然而,很难确定哪个字段导致了无法处理的实体错误。

有人可以告诉我如何识别错误的字段吗?

这是跟踪:

Microsoft.Rest.HttpOperationException: Operation returned an invalid status code 'UnprocessableEntity'
   at k8s.Kubernetes.CreateNamespacedDeploymentWithHttpMessagesAsync(V1Deployment body, String namespaceParameter, String dryRun, String fieldManager, String pretty, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at k8s.KubernetesExtensions.CreateNamespacedDeploymentAsync(IKubernetes operations, V1Deployment body, String namespaceParameter, String dryRun, String fieldManager, String pretty, CancellationToken cancellationToken)
   at k8s.KubernetesExtensions.CreateNamespacedDeployment(IKubernetes operations, V1Deployment body, String namespaceParameter, String dryRun, String fieldManager, String pretty)
Run Code Online (Sandbox Code Playgroud)

LM1*_*M10 5

通过打印 Microsoft.Rest.HttpOperationException 的 Response.Content 字段,我能够获得更详细的错误。

try
{
    // Code for deployment
}
catch(Microsoft.Rest.HttpOperationException e)
{
    Console.WriteLine(e.Response.Content);
}
Run Code Online (Sandbox Code Playgroud)