當涉及到陣列和配置時,我對何時使用空格以及何時不使用感到困惑。
我認為對于單值陣列,您需要使用空格:
IE:
values:
- "hello"
- "bye"
- "yes"
然而這是錯誤的:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
當值是地圖時,當我添加空格時,掌舵解釋器會抱怨:
error: error parsing deploy.yaml: error converting YAML to JSON: yaml: line 12: did not find expected '-' indicator
當我不這樣做時不會:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
我似乎找不到任何關于此的規則。
uj5u.com熱心網友回復:
YAML 中的物件陣列可以以空格開頭,也可以不以空格開頭。兩者都在 YAML 語法中有效。
values:
- "hello"
- "bye"
- "yes"
values:
- "hello"
- "bye"
- "yes"
確保同一塊的鍵必須在同一列中。
樣本:
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata: # "metadata" and "type" in the same column
direction: in
或者
spec:
scaleTargetRef:
name: sb-testing
minReplicaCount: 3
triggers:
- type: azure-servicebus
metadata:
direction: in
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/484385.html
標籤:Kubernetes yaml
上一篇:Statefulsetpod使用的存盤空間超過了volumeClaimTemplates中定義的存盤空間
下一篇:證書機密上沒有tls.crt
