我正在尝试配置 AKS,并且我有以下设置
我想在 Nginx Kubernetes Ingress Controller 和 Asp.Net Core 6.0 WebAPI POD 之间启用 HTTPS,例如
我该如何设置?我在哪里存储 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/