繁体   English   中英

如何在 Kubernetes 中使用 a.pfx 证书?

[英]How to use a .pfx certificate in Kubernetes?

我有一个 Java 容器需要使用的 .pfx 文件。

我使用命令创建了一个 tls 机密

kubectl create secret tls secret-pfx-key --dry-run=client --cert tls.crt --key tls.key -o yaml

apiVersion: v1
kind: Secret
type: kubernetes.io/tls
metadata:
  name     : secret-pfx-key
  namespace: default
data:
  #cat tls.crt | base64
  tls.crt: base64-gibberish....
  #cat tls.key | base64
  tls.key: base64-gibberish....

但是,现在我无法理解如何使用它。 当我将秘密作为卷添加到 pod 中时,我可以看到创建的两个文件。 但我需要将两者结合在一个.pfx 文件中。

我错过了什么吗? 谢谢。

注意:我已阅读相关的 stackoverflow 问题,但无法理解如何使用它。

您可以先转换为 pfx,然后kubectl create secret generic mypfx --from-file=pfx-cert=<converted pfx file>

将 secret 作为卷挂载到您的 pod 中:

apiVersion: v1
kind: Pod
metadata:
  name: test-mypfx
spec:
  restartPolicy: OnFailure
  volumes:
  - name: pfx-volume
    secret:
      secretName: mypfx
  containers:
  - name: busybox
    image: busybox
    command: ["ash","-c","cat /path/in/the/container/pfx-cert; sleep 5"]
    volumeMounts:
    - name: pfx-volume
      mountPath: /path/in/the/container

上面的示例转储证书,等待 5 秒并退出。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM