将 Nginx Ingress 证书挂载在 Ingress Controller Pods 中作为内存而不是 K8s Secrets

问题描述

作为合规工作的一部分,我们似乎需要使用直接安装在内存中的入口证书,使用 emptyDir 和 medium:Memory ,但我无法在 Nginx Ingress Controller repo 或其他方面找到任何示例这样做。 如果之前有人这样做过,请提供一些见解。

解决方法

我从来没有这样做过。刚刚尝试过,一切正常。不过,我不得不手动放置证书。我的意思是,我创建了一个 debian pod 并手动安装了所有东西。我不知道你打算怎么做那部分,所以它会很优雅。

无论如何,这是对我有用的 yaml,带有 www.example.com 的自签名证书。

apiVersion: v1
kind: Pod
metadata:
  name: nginx-https
  labels:
    app: nginx
spec:
  containers:
  - image: debian
    name: nginx
    volumeMounts:
    - mountPath: /etc/nginx/certs
      name: certs
    tty: true
  volumes:
  - name: certs
    emptyDir:
      medium: "Memory"

和请求

curl -vvv https://service -k
...
* TLSv1.2 (IN),TLS handshake,Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN,server accepted to use http/1.1
* Server certificate:
*  subject: CN=www.example.com; O=example organization
*  start date: Jan 18 15:48:22 2021 GMT
*  expire date: Jan 18 15:48:22 2022 GMT
*  issuer: O=domain Inc.; CN=example.com
*  SSL certificate verify result: unable to get local issuer certificate (20),continuing anyway.
> GET / HTTP/1.1
> Host: 192.168.31.62
> User-Agent: curl/7.59.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: nginx/1.14.2
< Date: Mon,18 Jan 2021 15:52:41 GMT
< Content-Type: text/html
< Content-Length: 612
...

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...