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
|
|
|
|
|
2023-07-14 04:51:25 -07:00
|
|
|
import Config from "@site/src/components/Config.js";
|
|
|
|
|
|
|
|
<Config
|
|
|
|
data={{
|
|
|
|
type: "kubectl",
|
|
|
|
style: "powerline",
|
|
|
|
powerline_symbol: "\uE0B0",
|
|
|
|
foreground: "#000000",
|
|
|
|
background: "#ebcc34",
|
|
|
|
template: " \uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} ",
|
|
|
|
properties: {
|
|
|
|
context_aliases: {
|
|
|
|
"arn:aws:eks:eu-west-1:1234567890:cluster/posh": "posh",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
2021-02-10 18:23:00 -08:00
|
|
|
|
|
|
|
## Properties
|
|
|
|
|
2024-04-04 14:20:48 -07:00
|
|
|
| Name | Type | Default | Description |
|
|
|
|
| ------------------ | :-------: | :-----: | ------------------------------------------------------------------------------- |
|
|
|
|
| `display_error` | `boolean` | `false` | show the error context when failing to retrieve the kubectl information |
|
|
|
|
| `parse_kubeconfig` | `boolean` | `false` | parse kubeconfig files instead of calling out to kubectl to improve performance |
|
|
|
|
| `context_aliases` | `object` | | custom context namespace |
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2022-02-01 03:10:46 -08:00
|
|
|
## Template ([info][templates])
|
|
|
|
|
|
|
|
:::note default template
|
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
```template
|
2022-02-01 03:10:46 -08:00
|
|
|
{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }}
|
|
|
|
```
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Properties
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2022-09-16 07:32:48 -07:00
|
|
|
| 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 |
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2023-07-14 04:51:25 -07:00
|
|
|
:::tip
|
2021-02-10 18:23:00 -08:00
|
|
|
|
|
|
|
It is common for the Kubernetes "default" namespace to be used when no namespace is provided. If you want your prompt to
|
2022-09-16 07:32:48 -07:00
|
|
|
render an empty current namespace using the word "default", you can use something like this for the template:
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2023-07-14 04:51:25 -07:00
|
|
|
```
|
|
|
|
{{.Context}} :: {{if .Namespace}}{{.Namespace}}{{else}}default{{end}}
|
|
|
|
```
|
|
|
|
:::
|
2021-02-10 18:23:00 -08:00
|
|
|
|
2022-04-20 09:43:59 -07:00
|
|
|
[templates]: /docs/configuration/templates
|