Kubernetes
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
功能
显示当前激活的 Kubernetes 上下文名称及命名空间名称。
示例配置
- json
- yaml
- toml
{
"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"
}
}
}
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
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"
[options.cluster_aliases]
"arn:aws:eks:eu-west-1:1234567890:cluster/posh" = "posh-cluster"
选项
| Name | Type | Default | Description |
|---|---|---|---|
display_error | boolean | false | show the error context when failing to retrieve the kubectl information |
parse_kubeconfig | boolean | true | parse kubeconfig files instead of calling out to kubectl to improve performance |
context_aliases | object | custom context namespace | |
cluster_aliases | object | custom cluster name |
模板 (信息)
默认模板
{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }}
属性
| Name | Type | Description |
|---|---|---|
.Context | string | the current kubectl context |
.Namespace | string | the current kubectl context namespace |
.User | string | the current kubectl context user |
.Cluster | string | the current kubectl context cluster |
技巧
当未指定命名空间时,Kubernetes 通常会使用 "default" 命名空间。若希望提示符在显示空命名空间时展示 "default" 字样,可采用如下模板配置:
{{.Context}} :: {{if .Namespace}}{{.Namespace}}{{else}}default{{end}}