【问题标题】:How to access Azure Key Vault with Network Security Policy enables?如何使用网络安全策略访问 Azure Key Vault?
【发布时间】:2021-05-12 23:35:40
【问题描述】:

我有 2 个部署如下:

  1. 定向数据库部署。
  2. Web 服务部署。

最初,为了访问 Orient DB,Web 服务获取存储在 Azure Key Vault 中的 Orient DB 用户名和密码。

为了提供额外的安全性,我创建了一个网络安全策略,它只允许具有 namespaceSelector "application: production"podSelector "application: production" 的 pod。 应用的网络安全策略如下:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: nmsp
  namespace: production
spec:
  podSelector:
    matchLabels:
      application: production
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          application: production
      podSelector:
        matchLabels:
          application: production
  egress:
  - to:
    - namespaceSelector:
        matchLabels:
          application: production
      podSelector:
        matchLabels:
          application: production

但是,应用网络安全策略后,Web 服务无法与 Orient DB 连接,因为 Web 服务无法从 Azure 密钥库 获取用户名和密码。 它给出了错误,

Unhandled Rejection at: FetchError: request to https://in-keyvault-kv.vault.azure.net/secrets?api-version=7.1 failed, reason: getaddrinfo EAI_AGAIN in-aks-keyvault-kv.vault.azure.net
at ClientRequest. (/usr/src/app/node_modules/node-fetch/lib/index.js:1461:11)
at ClientRequest.emit (events.js:314:20)
at TLSSocket.socketErrorListener (_http_client.js:428:9)
at TLSSocket.emit (events.js:314:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
type: 'system',
errno: 'EAI_AGAIN',
code: 'EAI_AGAIN'
}

那么如何在启用网络安全策略的情况下访问此密钥库以获取用户名和密码?并连接 orient DB 服务?

如果有人知道,请帮助我。 谢谢。

【问题讨论】:

    标签: azure kubernetes azure-aks


    【解决方案1】:

    您可以添加启用端口 443 的出口规则(如果您想限制流量,还可以添加 Key Vault 服务的 IP 范围)或使用类似 Azure Key Vault provider for Secret Store CSI driver 的方式获取存储在 Azure Key Vault 实例中的机密内容并使用 Secret Store CSI 驱动程序接口将它们挂载到 Kubernetes pod 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-23
      • 2020-09-25
      • 2020-08-08
      • 1970-01-01
      • 1970-01-01
      • 2019-06-09
      • 2017-07-11
      相关资源
      最近更新 更多