2020-10-15 10:48:41 -07:00
|
|
|
---
|
|
|
|
id: kubectl
|
|
|
|
title: Kubectl Context
|
|
|
|
sidebar_label: Kubectl
|
|
|
|
---
|
|
|
|
|
|
|
|
## What
|
|
|
|
|
2021-02-10 18:23:00 -08:00
|
|
|
Display the currently active Kubernetes context name and namespace name.
|
2020-10-15 10:48:41 -07:00
|
|
|
|
|
|
|
## Sample Configuration
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"type": "kubectl",
|
|
|
|
"style": "powerline",
|
2020-10-16 11:07:38 -07:00
|
|
|
"powerline_symbol": "\uE0B0",
|
2020-10-15 10:48:41 -07:00
|
|
|
"foreground": "#000000",
|
|
|
|
"background": "#ebcc34",
|
2022-03-27 01:12:47 -07:00
|
|
|
"template": " \uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} "
|
2020-10-15 10:48:41 -07:00
|
|
|
}
|
|
|
|
```
|
2021-02-10 18:23:00 -08:00
|
|
|
|
|
|
|
## Properties
|
|
|
|
|
2021-02-12 12:39:20 -08:00
|
|
|
- display_error: `boolean` - show the error context when failing to retrieve the kubectl information - defaults to `false`
|
2021-11-21 07:02:51 -08:00
|
|
|
- parse_kubeconfig: `boolean` - parse kubeconfig files instead of calling out to kubectl to improve
|
|
|
|
performance - defaults to `false`
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2022-02-01 03:10:46 -08:00
|
|
|
## Template ([info][templates])
|
|
|
|
|
|
|
|
:::note default template
|
|
|
|
|
|
|
|
``` template
|
|
|
|
{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }}
|
|
|
|
```
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Properties
|
2021-02-10 18:23:00 -08:00
|
|
|
|
|
|
|
- `.Context`: `string` - the current kubectl context
|
2021-11-21 07:02:51 -08:00
|
|
|
- `.Namespace`: `string` - the current kubectl context namespace
|
2022-01-17 04:16:04 -08:00
|
|
|
- `.User`: `string` - the current kubectl context user
|
2021-11-21 07:02:51 -08:00
|
|
|
- `.Cluster`: `string` - the current kubectl context cluster
|
2021-02-10 18:23:00 -08:00
|
|
|
|
|
|
|
## Tips
|
|
|
|
|
|
|
|
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}}`
|
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[templates]: /docs/configuration/templates
|