跳转到主内容

Kubernetes

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

功能

显示当前激活的 Kubernetes 上下文名称及命名空间名称。

示例配置

{
"type": "kubectl",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#000000",
"background": "#ebcc34",
"template": " 󱃾 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} ",
"options": {
"context_aliases": {
"arn:aws:eks:eu-west-1:1234567890:cluster/posh": "posh"
},
"cluster_aliases": {
"arn:aws:eks:eu-west-1:1234567890:cluster/posh": "posh-cluster"
}
}
}

选项

NameTypeDefaultDescription
display_errorbooleanfalseshow the error context when failing to retrieve the kubectl information
parse_kubeconfigbooleantrueparse kubeconfig files instead of calling out to kubectl to improve performance
context_aliasesobjectcustom context namespace
cluster_aliasesobjectcustom cluster name

模板 (信息)

默认模板
{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }}

属性

NameTypeDescription
.Contextstringthe current kubectl context
.Namespacestringthe current kubectl context namespace
.Userstringthe current kubectl context user
.Clusterstringthe current kubectl context cluster
技巧

当未指定命名空间时,Kubernetes 通常会使用 "default" 命名空间。若希望提示符在显示空命名空间时展示 "default" 字样,可采用如下模板配置:

{{.Context}} :: {{if .Namespace}}{{.Namespace}}{{else}}default{{end}}