kubernetes - Azure Kubernetes 服务 (AKS) : How to enable HTTPS between Nginx Kubernetes Ingress Controller & Asp.Net Core 6.0 WebAPI POD?

标签 kubernetes .net-core asp.net-core-webapi azure-aks

我正在尝试配置 AKS,并且我有以下设置

enter image description here

我想在 Nginx Kubernetes Ingress Controller 和 Asp.Net Core 6.0 WebAPI POD 之间启用 HTTPS,例如

enter image description here

我该如何设置?我在哪里存储 WebAPI SSL 证书?

最佳答案

引用documentation for annotation将入口后端设置为 HTTPS:

nginx.ingress.kubernetes.io/backend-protocol: HTTPS

遵循指导here为您的 WebAPI Pod 设置 SSL 证书。

证书可以存储在 kubernetes 通用 secret 中,并可以作为 安装到 pod 上。在生产中,AKS secret 存储可能是 backed by Azure KeyVault ,因此证书将真正存储在 KeyVault 中。

对于您的测试环境,以下是创建 key 的方法:

kubectl create secret generic webapi-cert-secret 
  --from-file=cert=yourcert.pfx
  --from-literal=pass='yourcertpasswd'

然后挂载到您的 Pod/部署定义中(为简洁起见,进行了截断):

      env:
      - name: Kestrel__Certificates__Default__Path
        value: /certs/aspnet-cert.pfx
      - name: Kestrel__Certificates__Default__Password
        valueFrom:
          secretKeyRef:
            name: webapi-cert-secret
            key: pass
      volumeMounts:
      - name: certsvolume
        mountPath: /certs/aspnet-cert.pfx
        subPath: aspnet-cert.pfx
        readOnly: true
  volumes:
  - name: certsvolume
    secret:
      secretName: webapi-cert-secret
      items:
      - key: cert
        path: aspnet-cert.pfx

关于kubernetes - Azure Kubernetes 服务 (AKS) : How to enable HTTPS between Nginx Kubernetes Ingress Controller & Asp.Net Core 6.0 WebAPI POD?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73406354/

相关文章:

kubernetes - 如何在docker命令中切换用户(su)

javascript - Cookie 不随 CORS Web 请求一起发送

c# - 如何返回带有我自己的错误的完整 BadRequest 响应正文

angular - 使用 Angular 2 和服务器 ASP.NET 核心获取错误 "JSONP injected script did not invoke callback."

kubernetes - 广告连播未能安排。通过kubernates安装openstack

azure - 在 kubernetes 中部署 azure 函数时如何检索函数键

kubernetes - 在 kind 集群中编辑 extraPortMappings

c# - 使用 ImageSharp 调整色阶和颜色

c# - 如何从 Controller 返回一个特定的状态码并且没有内容?

asp.net-core - 在 .NET Core 2 中注册基于作用域的 HttpClient