我的值中有一个json编码的字符串.yaml文件->;
values.yaml个
network:
cidrs : "[\"123.123.123.123/32\",\"123.124.125.125/32\"]"
现在,我想在我的网络策略出口ipblock中使用此值作为字符串列表.但我无法将其转换为列表.
目前,我正在遵循这一点来实现要求,但它失败了-
将YAML转换为JSON时出错:YAML:第xx行:未找到所需的键
netpol.yaml个
spec:
podSelector:
matchLabels:
name: log-forwarder
policyTypes:
- Egress
egress:
{{- $json := .Values.network.cidrs | fromJson -}}
{{- range $json }}
- to:
- ipBlock:
cidr: {{- . }}
{{- end }}
ports:
- protocol: TCP
port: 443
您知道如何将编码后的字符串转换为字符串列表并在我的网络策略中使用吗?