3.1 Display Resource

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:

Command: kubed-display-resource

Display a Kubernetes resource.

Command: kubed-display-pod
Command: kubed-display-deployment
Command: kubed-display-namespace
Command: kubed-display-foo

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:

User Option: kubed-yaml-setup-hook

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: kubed-display-resource-mode

Minor mode for buffers that display a Kubernetes resource.

This minor mode does the following:

Image: Displaying and editing YAML of Kubernetes pod with Kubed

Type C-x C-q in a resource YAML buffer to edit it, C-c C-c to apply