Editing Kubernetes Objects
Danger
You should be 100% sure what you are doing and should have at least a snapshot of the etcd you want to edit as things can and will possibly go wrong!
Do this at your own risk!
Requirements¶
- ETCD cluster running.
etcdctl
can reach it (you need to know which flags to provide, e.g., for tls certs and so on).
- Golang installed (
glide
installed inPATH
, e.g.,go get -u github.com/Masterminds/glide
).- PATH includes the
$GOPATH/bin
(export PATH="$GOPATH/bin/:$PATH"
)
- PATH includes the
Steps¶
Step 1 - Prepare Environment¶
1 2 3 4 5 |
|
Warning
Be sure to stop all API servers, before continuing with the next steps.
Be sure to stop all Controller Manager servers, before continuing with the next steps.
Depending on the cluster setup, you may just need move out the according manifest
from /etc/kubernetes/manifests
directory.
Step 2 - Locate object path¶
Note
The etcdctl
probably needs to be run inside the etcd container on one of the Kubernetes masters.
1 2 |
|
I recommend you to keep the session on the server for etcdctl
open and after finding the correct key to export it using export YOUR_OBJECT_PATH=__PATH__
as it will be used like this later on.
Step 3 - Get object from ETCD¶
Note
The etcdctl
probably needs to be run inside the etcd container on one of the Kubernetes masters.
Replace $YOUR_OBJECT_PATH
with the path of the object or set it as a variable.
1 2 3 4 5 6 |
|
Copy etcd-data-old.bin
to the host, e.g.:
1 |
|
Step 4 - Decode and edit the produced output as you need¶
1 2 |
|
Now edit the object.yaml
as you need.
Step 5 - Encode and save data to ETCD¶
1 2 |
|
Copy the etcd-data-new.bin
to the host, e.g.:
1 |
|
Note
The etcdctl
probably needs to be run inside the etcd container on one of the Kubernetes masters.
1 2 3 4 5 6 7 |
|
Step 6 - Verify the object is valid for Kubernetes¶
Just run kubectl get OBJECT_KIND OBJECT_NAME -o yaml
on the object you just edited to ensure it is still in working order.
If it returns the objects YAML, you are fine. In case of errors, such as illegal bytes
or so, you should restore a backup ASAP!