发布时间: 2023-6-28 文章作者: myluzh 分类名称: Kubernetes 朗读文章
apiVersion: v1 kind: Pod metadata: name: my-app-pod spec: containers: - name: my-app image: my-app-image env: # 使用 ConfigMap 中的 DB_HOST 和 DB_PORT 配置 - name: DB_HOST valueFrom: configMapKeyRef: name: my-config-map key: DB_HOST - name: DB_PORT valueFrom: configMapKeyRef: name: my-config-map key: DB_PORT --- apiVersion: v1 kind: ConfigMap metadata: name: my-config-map data: # 定义一个 key/value 对 DB_HOST: "localhost" DB_PORT: "5432"
apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: my-container image: my-image env: - name: DB_USERNAME valueFrom: secretKeyRef: name: db-credentials key: username - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-credentials key: password --- apiVersion: v1 kind: Secret metadata: name: db-credentials type: Opaque data: # 将用户名的内容编码为 base64 字符串 username: dXNlcm5hbWU= # 将密码的内容编码为 base64 字符串 password: cGFzc3dvcmQ=
标签: k8s kubernetes configmap secret
发表评论