query {
comp(func: eq(dgraph.type,"ServiceTemplate")) {
topologytemplate{
nodetemplates {
name
namespace @filter (eq(url,"a_url")){
url
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用上面的查询,我想过滤节点模板对象具有我们在查询中传递的匹配 URL 的数据,我们得到所有节点模板的列表,但我得到的结果如下:
{
"data": {
"comp": [
{
"topologytemplate": {
"nodetemplates": [
{
"name": "a",
"namespace": {
"url": "a_url"
}
},
{
"name": "b"
},
{
"name": "c"
},
{
"name": "d"
},
{
"name": "e"
},
{
"name": "f",
"namespace": {
"url": "b_url"
}
},
{
"name": "g"
}
]
}
}
]
},
}
Run Code Online (Sandbox Code Playgroud)
但我只想要那些具有我们将使用 graphQL 过滤的 URL 的节点模板。知道如何过滤它。
kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data "tls.crt"}}' | base64 -d > ca.pem
Run Code Online (Sandbox Code Playgroud)
如何在 ansible playbook 中运行上述命令?
我尝试按如下方式使用它:
- name: Apply secret istio-ca
shell: kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data "tls.crt"}}' | base64 -d > ca.pem
register: sout
Run Code Online (Sandbox Code Playgroud)
但这给了我一个错误,如下所示:
fatal: [172.31.20.135]: FAILED! => {"msg": "template error while templating string: expected token 'end of print statement', got 'string'. String: kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data \"tls.crt\"}}' | base64 -d > ca.pem"}
Run Code Online (Sandbox Code Playgroud)