Edit Kubernetes resource status subresources with your local editor.
edit-status is a kubectl plugin for targeted status edits during development,
testing, and operator troubleshooting. It resolves resources dynamically, so it
works with built-in Kubernetes resources and CRDs that expose a /status
subresource.
- Edit only the
statusfield, never the full object. - Patch the Kubernetes
/statussubresource. - Support built-in resources, CRDs, resource short names, and
resource.groupnames. - Complete resource types and object names through kubectl shell completion.
- Preview generated patches with
--dry-run. - Use YAML or JSON in the editor.
Build the plugin:
make binInstall it somewhere in PATH using the kubectl plugin name expected by kubectl:
install -m 0755 bin/edit-status "$(go env GOPATH)/bin/kubectl-edit_status"For kubectl-managed plugin argument completion, also install the completion delegate executable:
ln -sf "$(go env GOPATH)/bin/kubectl-edit_status" "$(go env GOPATH)/bin/kubectl_complete-edit_status"Verify installation:
kubectl plugin list | grep edit_status
kubectl edit-status --helpLoad kubectl's own completion in your shell. For zsh:
source <(kubectl completion zsh)Kubectl will discover kubectl_complete-edit_status and delegate completion for
plugin arguments. This enables:
kubectl edit-status <TAB>
kubectl edit-status est <TAB>
kubectl edit-status --dry-run -o yaml est <TAB>The plugin also provides standalone completion scripts:
kubectl edit-status completion bash
kubectl edit-status completion zsh
kubectl edit-status completion fish
kubectl edit-status completion powershellThose scripts are useful only when running the plugin as a standalone command;
for kubectl edit-status ..., prefer kubectl completion zsh.
kubectl edit-status RESOURCE NAME [flags]Examples:
kubectl edit-status pod nginx -n default
kubectl edit-status deployment web -n prod
kubectl edit-status widgets.example.com demo -n default
kubectl edit-status est demo -n defaultThe plugin opens a document containing only the resource status:
status:
conditions: []After you save and close the editor, the plugin sends a JSON merge patch to the
resource's /status subresource. If you remove fields in the editor, the patch
marks those fields as null so they are removed from status. If nothing
changed, it exits without sending a request.
--field-manager string field manager name used for the status patch (default "edit-status")
--dry-run print the status patch without sending it to the API server
-o, --output string format used in the editor: yaml or json (default "yaml")
All standard kubectl config flags are also available, including --context,
--kubeconfig, and --namespace.
The editor is selected in this order:
KUBE_EDITOR
EDITOR
VISUAL
vi
Use this CRD and custom resource to test edit-status without creating Pods or
consuming CPU and memory workloads:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: editstatustests.status.example.com
spec:
group: status.example.com
scope: Namespaced
names:
plural: editstatustests
singular: editstatustest
kind: EditStatusTest
shortNames:
- est
versions:
- name: v1
served: true
storage: true
subresources:
status: {}
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
x-kubernetes-preserve-unknown-fields: true
status:
type: object
x-kubernetes-preserve-unknown-fields: true
---
apiVersion: status.example.com/v1
kind: EditStatusTest
metadata:
name: demo
namespace: default
spec: {}Apply it and edit status:
kubectl apply -f edit-status-test.yaml
kubectl edit-status est demo -n defaultSet a status like this:
status:
phase: Ready
message: edit-status worksVerify and clean up:
kubectl get est demo -n default -o yaml
kubectl delete -f edit-status-test.yamlUsers need permission to get the object and patch its status subresource. For example:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: edit-deployment-status
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
verbs: ["get"]
- apiGroups: ["apps"]
resources: ["deployments/status"]
verbs: ["patch"]Resources that do not enable a status subresource cannot be updated by this plugin.