Skip to main content

Kubernetes

Whatโ€‹

Display the currently active Kubernetes context name and namespace name.

Sample Configurationโ€‹

{
"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"
}
}
}

Optionsโ€‹

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

Template (info)โ€‹

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

Propertiesโ€‹

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

It is common for the Kubernetes "default" namespace to be used when no namespace is provided. If you want your prompt to render an empty current namespace using the word "default", you can use something like this for the template:

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