将自定义 CA 证书通过 ConfigMap 添加到集群后,集群网络操作符会将用户提供的 CA 证书和系统 CA 证书合并到一个捆绑包中,并将合并的捆绑包注入请求信任捆绑包注入的操作符。
|
在向配置映射添加config.openshift.io/inject-trusted-cabundle="true" 标签后,其中的现有数据将被删除。集群网络操作符拥有配置映射,并且仅接受ca-bundle 作为数据。必须使用单独的配置映射来存储service-ca.crt ,方法是使用service.beta.openshift.io/inject-cabundle=true 注释或类似的配置。在同一个配置映射上添加config.openshift.io/inject-trusted-cabundle="true" 标签和service.beta.openshift.io/inject-cabundle=true 注释可能会导致问题。
|
操作符通过创建具有以下标签的空 ConfigMap 来请求此注入
config.openshift.io/inject-trusted-cabundle="true"
apiVersion: v1
data: {}
kind: ConfigMap
metadata:
labels:
config.openshift.io/inject-trusted-cabundle: "true"
name: ca-inject (1)
namespace: apache
操作符将此 ConfigMap 挂载到容器的本地信任存储中。
|
仅当证书未包含在 Red Hat Enterprise Linux CoreOS (RHCOS) 信任捆绑包中时,才需要添加受信任的 CA 证书。
|
证书注入不仅限于操作符。当创建带有config.openshift.io/inject-trusted-cabundle=true
标签的空 ConfigMap 时,集群网络操作符会在任何命名空间中注入证书。
ConfigMap 可以驻留在任何命名空间中,但是 ConfigMap 必须作为卷挂载到需要自定义 CA 的 Pod 中的每个容器中。例如
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-example-custom-ca-deployment
namespace: my-example-custom-ca-ns
spec:
...
spec:
...
containers:
- name: my-container-that-needs-custom-ca
volumeMounts:
- name: trusted-ca
mountPath: /etc/pki/ca-trust/extracted/pem
readOnly: true
volumes:
- name: trusted-ca
configMap:
name: trusted-ca
items:
- key: ca-bundle.crt (1)
path: tls-ca-bundle.pem (2)
1 |
ca-bundle.crt 作为 ConfigMap 密钥是必需的。 |
2 |
tls-ca-bundle.pem 作为 ConfigMap 路径是必需的。 |