简体   繁体   English

Azure Kubernetes容器环境变量

[英]Azure Kubernetes Container Env Variables

so in Docker, I can do a Docker run -e to pass in environment variables. 因此在Docker中,我可以执行Docker run -e来传递环境变量。

But how does one do that for Azure Kubernetes Pods? 但是,如何对Azure Kubernetes Pod做到这一点呢? They aren't username/password kinds of variables but more so URLs segments we would want to use during startup. 它们不是用户名/密码类型的变量,而是更多,因此我们希望在启动期间使用的URL段。

http://webapi/august where august is what we would want to pass in, then in September, we would want to pass in september . http://webapi/august其中august是我们想要传递的内容,然后在9月,我们希望在september传递。

This aren't the best examples, but it shows what I'm looking for. 这不是最好的例子,但是它显示了我在寻找什么。

Thanks. 谢谢。

There is a clear example on kubernetes documentation for this - https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/ 另外,对这个kubernetes文档一个明显的例子- https://kubernetes.io/docs/tasks/inject-data-application/define-environment-variable-container/

Short example from there: 那里的简短示例:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
        env:
        - name: DEMO_GREETING
          value: "Hello from the environment"
        - name: DEMO_FAREWELL
          value: "Such a sweet sorrow"

Take a note of env 以一记env

later if you want to change the variable on the fly - you can use kubectl set env -h command 稍后,如果您想即时更改变量-您可以使用kubectl set env -h命令

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

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