云容器引擎 CCE-使用密钥:使用密钥配置Pod的数据卷

时间:2023-11-01 16:25:54

使用密钥配置Pod的数据卷

密钥可以在Pod中作为文件使用。如下面的Pod示例所示,mysecret密钥的username和password以文件方式保存在/etc/foo目录下。
apiVersion: v1kind: Podmetadata:  name: mypodspec:  containers:  - name: mypod    image: redis    volumeMounts:    - name: foo      mountPath: "/etc/foo"      readOnly: true  volumes:  - name: foo    secret:      secretName: mysecret
另外,还可以指定密钥的目录路径和权限,username存放在容器中的/etc/foo/my-group/my-username目录下。
apiVersion: v1kind: Podmetadata:  name: mypodspec:  containers:  - name: mypod    image: redis    volumeMounts:    - name: foo      mountPath: "/etc/foo"  volumes:  - name: foo    secret:      secretName: mysecret      items:      - key: username        path: my-group/my-username        mode: 511

挂载Secret到数据卷还可以在界面上进行操作,在创建工作负载时,设置容器的高级设置,选择数据存储,添加本地磁盘,选择Secret即可配置。具体请参见密钥(Secret)挂载

support.huaweicloud.com/usermanual-cce/cce_01_0016.html