apiVersion: v1
kind: Secret
metadata:
  name: secret-mysql
type: kubernetes.io/basic-auth
#type: Opaque  #也可以用Opaque类型
data:
  username: cm9vdAo=             #key名称:username：root
  password: MTIzNDU2             #key名称:password: 123456
---
apiVersion: v1
kind: Pod
metadata:
  name: pod-secret-mysql-init
spec:
  containers:
  - name: mysql
    image: registry.cn-beijing.aliyuncs.com/wangxiaochun/mysql:8.0.29-oracle
    env:
    - name: MYSQL_ROOT_PASSWORD
      valueFrom:
        secretKeyRef:            
          name: secret-mysql      #引用指定的secret
          key: password           #引用指定的secret中对应的key
          optional: false         #必须存在

