简体   繁体   English

如何在 aws EKS 中定义环境变量

[英]How to define Environment variables in aws EKS

I'm new to k8s and I was looking for a way to define environment variables in my Aws EKS deployment.我是 k8s 的新手,我一直在寻找一种在我的 Aws EKS 部署中定义环境变量的方法。

You need to pass environment variable to Pod's container not deployment.您需要将环境变量传递给 Pod 的容器而不是部署。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        env:
        - name: MY_VAT
          value: MY_VALUE
        ports:
        - containerPort: 80

See: https://kube.netes.io/docs/tasks/inject-data-application/define-environment-variable-container/参见: https://kube.netes.io/docs/tasks/inject-data-application/define-environment-variable-container/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM