Avi*_*Avi 4 kubernetes kubernetes-deployment
我试图将一些容器信息公开为环境变量,从 pod 的 spec.template.spec.containers[0].name 读取值,这似乎不起作用。用于引用部署模板中的容器字段的 apiSpec 是什么。部署模板如下:
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
replicas: 2
selector:
matchLabels:
run: nginx
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
run: nginx
spec:
containers:
- image: nginx
name: nginx
ports:
- containerPort: 8000
resources: {}
env:
- name: MY_CONTAINER_NAME
valueFrom:
fieldRef:
fieldPath: spec.template.spec.containers[0].name
Run Code Online (Sandbox Code Playgroud)
Downward API 使您能够将 pod 自己的元数据公开给在该 pod 内运行的进程。
目前,它允许您将以下信息传递给您的容器:
就是这样。如您所见,容器端口不在此列表中。
通常,通过 Downward API 可用的元数据相当有限。如果您需要更多,则需要直接从 Kubernetes API 服务器获取它,您可以通过使用客户端库或使用大使容器来实现。
归档时间: |
|
查看次数: |
1012 次 |
最近记录: |