xxx
に置き換える方法はyyy
?
{
"spec": {
"template": {
"spec": {
"containers": [{
"args": [
"proxy",
"router",
"--domain",
"$(POD_NAMESPACE).svc.cluster.local",
"--proxyLogLevel=warning",
"--proxyComponentLogLevel=misc:error",
"--log_output_level=default:info",
"--serviceCluster",
"istio-ingressgateway"
],
"env": [{
"name": "JWT_POLICY",
"value": "third-party-jwt"
},
{
"name": "ISTIO_META_OWNER",
"value": "kubernetes://apis/apps/v1/namespaces/istio-system/deployments/xxx"
}
]
}]
}
}
}
}
ベストアンサー1
変更する.spec.template.spec.containers[].env[].value
方法は次のとおりです。ISTIO_META_OWNER使用|= sub()
交換の適用方法は次のとおりです。
jq -r '.spec.template.spec.containers[].env[] | (select(.name=="ISTIO_META_OWNER") |.value |= sub("xxx$"; "yyy"))' kubernetes_spec_example.json
結果は次のとおりです。
{
"name": "ISTIO_META_OWNER",
"value": "kubernetes://apis/apps/v1/namespaces/istio-system/deployments/yyy"
}