多云容器平台 MCP-设置环境变量:YAML样例

时间:2023-11-01 16:15:51

YAML样例

apiVersion: apps/v1kind: Deploymentmetadata:  name: env-example  namespace: defaultspec:  replicas: 1  selector:    matchLabels:      app: env-example  template:    metadata:      labels:        app: env-example    spec:      containers:        - name: container-1          image: nginx:alpine          imagePullPolicy: Always          resources:            requests:              cpu: 250m              memory: 512Mi            limits:              cpu: 250m              memory: 512Mi          env:            - name: key                     # 自定义              value: value            - name: key1                    # 配置项键值导入              valueFrom:                configMapKeyRef:                  name: configmap-example                  key: key1            - name: key2                    # 密钥键值导入              valueFrom:                secretKeyRef:                  name: secret-example                  key: key2            - name: key3                    # 变量引用,用Pod定义的字段作为环境变量的值              valueFrom:                fieldRef:                  apiVersion: v1                  fieldPath: metadata.name            - name: key4                    # 资源引用,用Container定义的字段作为环境变量的值              valueFrom:                resourceFieldRef:                  containerName: container1                  resource: limits.cpu                  divisor: 1          envFrom:            - configMapRef:                 # 配置项导入                name: configmap-example            - secretRef:                    # 密钥导入                name: secret-example      imagePullSecrets:        - name: default-secret
support.huaweicloud.com/usermanual-mcp/mcp_01_0079.html