You can view the YAML description of any resource in your Kubernetes cluster. In Kubed, this is referred to as displaying the given resource. The following commands display a Kubernetes resource:
Display a Kubernetes resource.
Display Kubernetes resource of a given type.
Command kubed-display-resource
can display any Kubernetes
resource. It prompts you to select a resource type and a resource
name, and displays that resource in a dedicated buffer. By default,
this command assumes you want to display a resource that is in the
current namespace, but if you invoke kubed-display-resource
with a prefix argument (C-u) and choose a namespaced resource
type, then it also lets you select the namespace of the resource.
With a double prefix argument, it lets you select which
kubectl
context to use too. See Context and Namespace.
If you have kubed-prefix-map
bound to C-c k, you can
invoke kubed-display-resource
with C-c k RET. This
command is also available from the menu-bar “Kubernetes” menu
(see Definition of kubed-menu-bar-mode), and from the transient
“Kubernetes Display” menu (see Transient Menus).
You can also display the resource at point in resources list buffers by simply typing RET. See Browse Resources.
Kubed also provides a dedicated kubed-display-foo
command
for each supported resource type foo. These commands are just
like kubed-display-resource
, except that they do not prompt you
for a type, since they are type-specific. For example,
kubed-display-pod
only prompts you for a pod name, and then
displays it like kubed-display-resource
does.
You can invoke these commands by adding a type-specific key before
RET in C-c k RET: C-c k p RET
invokes kubed-display-pod
, C-c k d RET invokes
kubed-display-deployment
, and so on.
When Kubed prepares a buffer for displaying a resource, it runs the
hook kubed-yaml-setup-hook
right after populating the buffer
with the YAML description of the resource:
List of functions to call, in order, to prepare YAML buffers. The
first function on this hook is normally the major mode you want to use
for YAML buffers that display Kubernetes resources. By default, this
is the list (yaml-ts-mode view-mode)
.
In addition, Kubed enables a bespoke minor mode
kubed-display-resource-mode
in buffers that display Kubernetes
resources:
Minor mode for buffers that display a Kubernetes resource.
This minor mode does the following:
kubed-display-resource-jump-to-list
, which pops up the
resources list buffer for the type of the displayed resource, and
takes you to the line corresponding to it.
kubed-display-resource-replace
, which lets you apply any
changes that you make in the YAML buffer back to the resource. When
you hit C-c C-c, Kubed asks you for confirmation before
proceeding; you can reply with d (‘diff’) to show a diff
between the current state of the resource and the current buffer
contents. You can also display this diff anytime with C-c C-=.
Note that by default Kubed displays resources in read-only buffers, so
you may need to hit C-x C-q (read-only-mode
) before
making changes in the buffer.
revert-buffer-quick
) and
M-x revert-buffer. This is also useful if you edit the
resource and want to restart from a clean slate.