国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 操作系統 > 正文

Kubernetes 1.5 實踐 如何給pod中的容器設置環境變量

2024-06-28 16:00:46
字體:
來源:轉載
供稿:網友

Kubernetes 1.5 給POD設置變量

When you create a Pod, you can set environment variables for the containers that run in the Pod. To set environment variables, include the env field in the configuration file. 在創建pod時,你可以為運行在pod中的容器設置環境變量。當我們需要設置變量時,我們只需要在配置文件中(yaml)中加入env選項。

In this exercise, you create a Pod that runs one container. The configuration file for the Pod defines an environment variable with name DEMO_GREETING and value “Hello from the environment”. Here is the configuration file for the Pod: 在這個練習中,你將創建一個運行了一個容器的pod。在配置文件中為pod定義的的一個環境變量名為 DEMO_GREETING,值為 “Hello from the environment”。這個pod的配置文件envars.yaml如下:

apiVersion: v1kind: Podmetadata: name: envar-demo labels: purpose: demonstrate-envarsspec: containers: - name: envar-demo-container image: gcr.io/google-samples/node-hello:1.0 env: - name: DEMO_GREETING value: "Hello from the environment"

Create a Pod based on the YAML configuration file: 通過YAML配置文件創建Pod:

kubectl create -f http://k8s.io/docs/tasks/configure-pod-container/envars.yaml

List the running Pods: 查看正在運行的Pods

kubectl get pods -l purpose=demonstrate-envars

The output is similar to this: 輸出內容如下:

NAME READY STATUS RESTARTS AGE envar-demo 1/1 Running 0 9s

Get a shell to the container running in your Pod: 連接到Pod中的容器:

kubectl exec -it envar-demo -- /bin/bash

In your shell, run the PRintenv command to list the environment variables. 在這個shell中,執行命令printenv命令查看環境變量。

root@envar-demo:/# printenv

The output is similar to this: 輸出內容如下:

NODE_VERSION=4.4.2 EXAMPLE_SERVICE_PORT_8080_TCP_ADDR=10.3.245.237 HOSTNAME=envar-demo ... DEMO_GREETING=Hello from the environment

To exit the shell, enter exit. 執行命令exit退出。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 介休市| 柳林县| 濮阳县| 汉沽区| 商河县| 四会市| 深州市| 德格县| 宜城市| 五常市| 进贤县| 晋中市| 重庆市| 图木舒克市| 休宁县| 敦煌市| 玉溪市| 舞钢市| 商都县| 资阳市| 望都县| 郓城县| 通州区| 万安县| 东明县| 老河口市| 繁昌县| 保定市| 天气| 通化县| 常山县| 孟州市| 沙洋县| 丹巴县| 赤水市| 兰溪市| 罗田县| 南丹县| 师宗县| 邓州市| 沂源县|