gpt4 book ai didi

库伯内斯 : Invalid value: "**** ": error converting fieldPath: field label not supported

转载 作者:行者123 更新时间:2023-12-02 12:00:56 26 4
gpt4 key购买 nike

我正在尝试应用下面的部署,但我遇到下面的错误

部署“示例”无效:spec.template.spec.containers[0].env[0].valueFrom.fieldRef.fieldPath:无效值:“spec.template.metadata.annotations.configHash”:转换错误fieldPath:不支持字段标签:spec.template.metadata.annotations.configHash

我尝试了不同的访问 fieldPath 的方式,例如:

spec.template.metadata.annotations['configHash']
spec.template.metadata.['annotations'].['configHash']
spec.template.metadata.['annotations'['configHash']]

似乎没有任何效果。任何帮助将不胜感激。

Kubernetes - 1.16.8-gke.15

apiVersion: apps/v1
kind: Deployment
metadata:
name: ecc-web
labels:
app: ecc
spec:
replicas: 1
selector:
matchLabels:
app: ecc
template:
metadata:
labels:
app: ecc
annotations:
configHash: b6651e50d35182bd8fc2f75a5af4aca79387079860fb953896399a1ad16e317d
spec:
volumes:
- name: opt-ecc-logs
emptyDir: {}
securityContext:
fsGroup: 1000
containers:
- name: ecc-web
image: gcr.io/gke-nonprod/ecc:release-11
envFrom:
- configMapRef:
name: env-config
env:
- name: CONFIG_HASH
valueFrom:
fieldRef:
fieldPath: spec.template.metadata.annotations.configHash
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: ecc-secret
key: mysql_svcacct_ecc_dev_password
ports:
- containerPort: 80
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- name: opt-ecc-logs
mountPath: /opt/ecc/logs
- name: application-log
image: busybox
command: ["/bin/sh","-c"]
args: ["touch /opt/ecc/logs/application.log;chown -R wsapp:wsapp /opt/ecc/logs/;tail -n+1 -f /opt/ecc/logs/application.log"]
securityContext:
runAsUser: 1000
runAsGroup: 1000
volumeMounts:
- name: opt-ecc-logs
mountPath: /opt/ecc/logs

最佳答案

只需使用:

env:
- name: CONFIG_HASH
valueFrom:
fieldRef:
fieldPath: metadata.annotations['configHash']

代替 spec.template.metadata.annotations.configHash

关于库伯内斯 : Invalid value: "**** ": error converting fieldPath: field label not supported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62402280/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com