将整个卷安装为 kubernetes 中的秘密

Mounting entire volumes as secrets in kubernetes

我在本地运行一个容器如下:

docker run --rm \
  --name=my-container \
  --net=host \
  -v $(pwd)/producer.properties:/etc/replicator/producer.properties \
  -v $(pwd)/consumer.properties:/etc/replicator/consumer.properties \
  -v $(pwd)/service-keystore.jks:/etc/replicator/destination.keystore.jks \
  -v $(pwd)/service-truststore.jks:/etc/replicator/destination.truststore.jks \
  repo/image

问题是作为卷装载的所有文件都包含敏感数据。

我正在尝试将以上内容移植到 kubernetes

如何挂载文件,同时将它们视为机密?

创建一个名为 secretnamesecret resource from the files(示例)并直接将 secret 挂载到容器中,如下所示

spec:
  volumes:
  - name: secret-volume
    secret:
      secretName: secretname
  containers:
  - name: containername
    image: imagename
    volumeMounts:
    - name: secret-volume
      readOnly: true
      mountPath: "/etc/secret-volume"