apiVersion: v1
kind: Secret
metadata:
 name: secret-test
type: kubernetes.io/basic-auth
#type: Opaque  #也可以用Opaque类型
data:
 #username: admin
 username: YWRtaW4=
 #password: password
 password: cGFzc3dvcmQ=
 
#说明：
#type类型指定为 Opaque 或者 kubernetes.io/basic-auth,username和password是加密的信息
#资源定义文件时，与命令行创建secret的--from-literal=username=admin 效果是一样的,但命令行的变量无需加密
---
#调用secret的清单文件
apiVersion: v1
kind: Pod
metadata:
  name: pod-secret-volume
spec:
  volumes:
  - name: secret
    secret:
     secretName: secret-test       #指定secret的名称
  containers:
    - name: secret-test-container
      image: registry.cn-beijing.aliyuncs.com/wangxiaochun/nginx:1.20.0
      volumeMounts:                #卷引用secret
       - name: secret
         mountPath: /secret/
         readOnly: true
