如何从Kubernetes引擎访问Google KMS?

如何从Kubernetes引擎访问Google KMS?,kubernetes,.net-core,google-cloud-platform,google-kubernetes-engine,google-cloud-kms,Kubernetes,.net Core,Google Cloud Platform,Google Kubernetes Engine,Google Cloud Kms,我不得不将我的.Net核心应用程序从谷歌应用程序引擎转移到谷歌Kubernetes引擎,因为我需要静态IP,遗憾的是谷歌应用程序引擎没有这个选项 我已经制作了一个集群和一些pod,但在日志中我看到: 未处理的异常。Grpc.Core.RpcException:Status(StatusCode=PermissionDenied,Detail=“请求的身份验证范围不足。”) 在Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg) 在Grpc.

我不得不将我的.Net核心应用程序从谷歌应用程序引擎转移到谷歌Kubernetes引擎,因为我需要静态IP,遗憾的是谷歌应用程序引擎没有这个选项

我已经制作了一个集群和一些pod,但在日志中我看到:

未处理的异常。Grpc.Core.RpcException:Status(StatusCode=PermissionDenied,Detail=“请求的身份验证范围不足。”)
在Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
在Grpc.Core.Calls.BlockingUnaryCall[TRequest,TreResponse](CallInvocationDetails`2调用,TRequest请求)
在Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TreResponse](方法'2,方法,字符串宿主,调用选项,TRequest请求)
在Grpc.Core.Interceptors.InterceptingCallInvoker.b_uu3_0[TRequest,TreResponse](TRequest请求,客户端InterceptorContext`2 ctx)
在Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,treresponse](TRequest请求,ClientInterceptorContext`2 context,BlockingUnaryCallContinuation`2 continuation)
在Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TreResponse](方法'2,字符串宿主,调用选项选项,TRequest请求)
在Google.Cloud.Kms.V1.KeyManagementService.KeyManagementServiceClient.Decrypt(DecryptRequest请求,CallOptions选项)
在Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest请求,CallSettings CallSettings)
在Google.Api.Gax.Grpc.ApiCallRetryExtensions.c_uudisplayClass1_0`2.b_u0(TRequest请求,调用设置调用设置)
在Google.Api.Gax.Grpc.ApiCall`2.c_uuudisplayClass10_0.b_uu1(TRequest-req,CallSettings-cs)
在Google.Api.Gax.Grpc.ApiCall`2.Sync(TRequest请求,CallSettings percallsettings)
在Google.Cloud.Kms.V1.KeyManagementServiceClientImpl.Decrypt(DecryptRequest请求,CallSettings CallSettings)
在Google.Cloud.Kms.V1.KeyManagementServiceClient.Decrypt(CryptoKeyName名称、ByteString密文、CallSettings CallSettings)
在/app/Services/Kms/EncryptedFileInfo.cs中的Neo.Services.Kms.EncryptedFileInfo.CreateReadStream()处:第81行
在Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(布尔重载)中
在Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()中
位于Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1提供程序)
在Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()中
在/app/Services/Config/ConfigurationProvider.cs中的Neo.Services.Config.ConfigurationProvider.get_AppConfig():第27行
在/app/Startup.cs中的Neo.Startup.LogAppChecks()处:第197行
在/app/Startup.cs中的Neo.Startup.Run()处:第24行
在/app/Program.cs中的Neo.Program.Main()处:第5行
我设法发现这个问题的存在是因为我无法在Kubernetes中解密我的
appsettings.json
文件。它在谷歌应用程序引擎中工作

我猜这是因为GAE已经默认设置了GOOGLE_APPLICATION_CREDENTIALS环境变量

我找到了这篇文章,但它看起来描述了一些不同的东西

如何从Kubernetes引擎访问Google KMS

@更新

节点池的输出描述:

config:
  diskSizeGb: 100
  diskType: pd-standard
  imageType: COS
  machineType: n1-standard-1
  metadata:
    disable-legacy-endpoints: 'true'
  oauthScopes:
  - https://www.googleapis.com/auth/devstorage.read_only
  - https://www.googleapis.com/auth/logging.write
  - https://www.googleapis.com/auth/monitoring
  - https://www.googleapis.com/auth/service.management.readonly
  - https://www.googleapis.com/auth/servicecontrol
  - https://www.googleapis.com/auth/trace.append
  serviceAccount: default
我已使用此命令将作用域添加到我的新节点池

gcloud容器节点池创建您的池名——zone europe-west1-b——集群
您的集群名称--num nodes 1--作用域默认值、bigquery、云平台、计算rw、数据存储、存储已满、taskqueue、userinfo电子邮件、sql管理员
现在我得到:

未处理的异常。Grpc.Core.RpcException:Status(StatusCode=PermissionDenied,Detail=“Permission”cloudkms.cryptoKeyVersions.useToDecrypt“资源”项目/项目名称/位置/全局/密钥环/webapp/加密密钥/appsecrets上被拒绝”(或者它可能不存在)
在Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
在Grpc.Core.Calls.BlockingUnaryCall[TRequest,TreResponse](CallInvocationDetails`2调用,TRequest请求)
在Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TreResponse](方法'2,方法,字符串宿主,调用选项,TRequest请求)
在Grpc.Core.Interceptors.InterceptingCallInvoker.b_uu3_0[TRequest,TreResponse](TRequest请求,客户端InterceptorContext`2 ctx)
在Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,treresponse](TRequest请求,ClientInterceptorContext`2 context,BlockingUnaryCallContinuation`2 continuation)
在Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TreResponse](方法'2,字符串宿主,调用选项选项,TRequest请求)
在Google.Cloud.Kms.V1.KeyManagementService.KeyManagementServiceClient.Decrypt(DecryptRequest请求,CallOptions选项)
在Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest请求,CallSettings CallSettings)
在Google.Api.Gax.Grpc.ApiCallRetryExtensions.c_uudisplayClass1_0`2.b_u0(TRequest请求,调用设置调用设置)
在Google.Api.Gax.Grpc.ApiCall`2.c_uuudisplayClass10_0.b_uu1(TRequest-req,CallSettings-cs)
在Google.Api.Gax.Grpc.ApiCall`2.Sync(TRequest请求,CallSettings percallsettings)
在Google.Cloud.Kms.V1.KeyManagementServiceClientImpl.Decrypt(DecryptRequest请求,CallSettings CallSettings)
在Google.Cloud.Kms.V1.KeyManagementServiceClient.Decrypt(CryptoKeyName名称、ByteString密文、CallSettings CallSettings)
在/app/Services/Kms/EncryptedFileInfo.cs中的Neo.Services.Kms.EncryptedFileInfo.CreateReadStream()处:第81行
在Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(布尔重载)中
在Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()中
位于Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1提供程序)
在Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()中
在/app/Services/Config/ConfigurationProvider.cs中的Neo.Services.Config.ConfigurationProvider.get_AppConfig():第27行
在尼奥街