kubernetes为容器定义环境变量

示例Pod 的配置文件

envars.yaml Copy envars.yaml to clipboard
apiVersion: v1
kind: Pod
metadata:
  name: envar-demo
  labels:
    purpose: demonstrate-envars
spec:
  containers:
  - name: envar-demo-container
    image: busybox
    env:
    - name: DEMO_GREETING
      value: "Hello from the environment"
    - name: DEMO_FAREWELL
      value: "Such a sweet sorrow"

在 shell 中,运行 printenv 命令列出环境环境变量

posted @ 2021-05-18 10:03  哈喽哈喽111111  阅读(441)  评论(0编辑  收藏  举报