Chr*_*ski 2 kubernetes kubectl
我想查看以下命令显示的“ config”详细信息:
kubectl config view
Run Code Online (Sandbox Code Playgroud)
但是,这显示了所有上下文的整个配置详细信息,如何过滤(或有另一个命令)以查看CURRENT上下文的配置详细信息?
P E*_*ram 11
使用以下命令获取包括证书的完整配置
kubectl config view --minify --flatten
Run Code Online (Sandbox Code Playgroud)
执行此操作的云原生方法是使用命令的 JSON 输出,然后使用以下命令对其进行过滤jq:
kubectl config view -o json | jq '. as $o
| ."current-context" as $current_context_name
| $o.contexts[] | select(.name == $current_context_name) as $context
| $o.clusters[] | select(.name == $context.context.cluster) as $cluster
| $o.users[] | select(.name == $context.context.user) as $user
| {"current-context-name": $current_context_name, context: $context, cluster: $cluster, user: $user}'
{
"current-context-name": "docker-for-desktop",
"context": {
"name": "docker-for-desktop",
"context": {
"cluster": "docker-for-desktop-cluster",
"user": "docker-for-desktop"
}
},
"cluster": {
"name": "docker-for-desktop-cluster",
"cluster": {
"server": "https://localhost:6443",
"insecure-skip-tls-verify": true
}
},
"user": {
"name": "docker-for-desktop",
"user": {
"client-certificate-data": "REDACTED",
"client-key-data": "REDACTED"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这个答案帮助我弄清楚了一些 jq 位。
| 归档时间: |
|
| 查看次数: |
1480 次 |
| 最近记录: |