You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- 3. Check the logs forthe container runningin your Pod: -->
69
+
<!--
70
+
3. Check the logs for the container running in your Pod:
71
+
-->
66
72
3. 检查 Pod 中运行容器的日志:
67
73
68
-
```shell
69
-
kubectl logs pod/dependent-envars-demo
70
-
```
71
-
```
74
+
```shell
75
+
kubectl logs pod/dependent-envars-demo
76
+
```
77
+
```
72
78
73
-
UNCHANGED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
74
-
SERVICE_ADDRESS=https://172.17.0.1:80
75
-
ESCAPED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
76
-
```
79
+
UNCHANGED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
80
+
SERVICE_ADDRESS=https://172.17.0.1:80
81
+
ESCAPED_REFERENCE=$(PROTOCOL)://172.17.0.1:80
82
+
```
77
83
78
84
<!--
79
85
As shown above, you have defined the correct dependency reference of `SERVICE_ADDRESS`, bad dependency reference of `UNCHANGED_REFERENCE` and skip dependent references of `ESCAPED_REFERENCE`.
@@ -88,6 +94,15 @@ the reference can be correctly resolved, such as in the `SERVICE_ADDRESS` case.
88
94
如果环境变量被引用时已事先定义,则引用可以正确解析,
89
95
比如 `SERVICE_ADDRESS` 的例子。
90
96
97
+
<!--
98
+
Note that order matters in the `env` list. An environment variable is not considered
99
+
"defined" if it is specified further down the list. That is why `UNCHANGED_REFERENCE`
100
+
fails to resolve `$(PROTOCOL)` in the example above.
When the environment variable is undefined or only includes some variables, the undefined environment variable is treated as a normal string, such as `UNCHANGED_REFERENCE`. Note that incorrectly parsed environment variables, in general, will not block the container from starting.
93
108
@@ -99,17 +114,16 @@ is defined or not. This can be seen from the `ESCAPED_REFERENCE` case above.
99
114
比如 `UNCHANGED_REFERENCE` 的例子。
100
115
注意,解析不正确的环境变量通常不会阻止容器启动。
101
116
102
-
`$(VAR_NAME)` 这样的语法可以用两个 `$` 转义,既:`$$(VAR_NAME)`。
117
+
`$(VAR_NAME)` 这样的语法可以用两个 `$` 转义,即:`$$(VAR_NAME)`。
103
118
无论引用的变量是否定义,转义的引用永远不会展开。
104
119
这一点可以从上面 `ESCAPED_REFERENCE` 的例子得到印证。
105
120
106
121
## {{% heading "whatsnext" %}}
107
122
108
-
109
123
<!--
110
124
* Learn more about [environment variables](/docs/tasks/inject-data-application/environment-variable-expose-pod-information/).
111
125
* See [EnvVarSource](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#envvarsource-v1-core).
0 commit comments