Updating running Kubernetes resources from the kubectl commandline using the patch command

Lucas Jellema
0 0
Read Time:44 Second

All too often I found myself editing Kubernetes resource definitions in the Kubernetes Dashboard. Modifying for example the type of a service. Typically I would git clone yaml files, run  them in a single statement and then manually change a few details.

image

After just the tiniest of search efforts, I ran into the kubectl patch command, that is created for just this purpose.

kubectl patch svc eventbuspublisherservice -p ‘{“spec”: {“type”: “NodePort”}}’ –namespace my_space

This will change the type of the eventbuspublisherservice  to  NodePort.

An alternative approach with patch is to create a YAML file with the desired new or updated content for the resource definition. Use a statement like this to apply the contents of the YAML file:

kubectl patch deployment my-deployment –patch “$(cat my-patch.yaml)” –namespace my_space

image

Documentation: https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next Post

ADF Performance Monitor: Error Diagnostics

Application errors are often hard to retrieve, or take a lot of time to resolve. When you are suffering from errors, and have a lack of clarity when errors happen, you would like to have useful error diagnostics for analysis. The ADF Performance Monitor automatically captures detailed diagnostics for each […]
%d bloggers like this: