til/content/posts/kubectl-replace.md

18 lines
185 KiB
Markdown
Raw Normal View History

2020-09-25 08:54:54 +00:00
---
title: "kubectl replace"
date: 2020-09-25
2020-09-25 08:54:54 +00:00
draft: false
tags:
- kubernetes
- kubectl
images:
2021-05-11 18:40:15 +00:00
- https://opengraph.cluster.fun/opengraph/?siteTitle=Today%20I%20learnt...&title=kubectl%20replace&tags=kubernetes%2Ckubectl&image=https%3A%2F%2Fmarcusnoble.co.uk%2Fimages%2Fmarcus.jpg&twitter=Marcus_Noble_&github=AverageMarcus&website=www.MarcusNoble.co.uk
2020-09-25 08:54:54 +00:00
---
After working with Kubernetes for a few years now I've only just today learnt about `kubectl replace` which, you guessed it, completely replaces a resource.
I've always used `kubectl apply` to update existing resources (or create new ones) which does a merge between the existing and the supplied manifest.
Hat tip to [@vdemeest](https://twitter.com/vdemeest) for this:
[![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABJYAAAIQCAYAAADTruSMAAAAAXNSR0IArs4c6QAAQABJREFUeAHsnQd4XOWZ/c/0PqM66nKTXCQZg22aDYltSMCb3QDJhpJiyAZMEgJsNsvukpAEErJslt0kEMgSSANCaPkHU4Ix4ELAptnYxg0jW5bV62hmNL3+z3dl2aNiTLHAwHvZse7c+93vfvc3ozyPzp73vLosN8gmBISAEBACQkAICAEhIASEgBAQAkJACAgBISAE3iEB/TscL8OFgBAQAkJACAgBISAEhIAQEAJCQAgIASEgBISARkCEJfkiCAEhIASEgBAQAkJACAgBISAEhIAQEAJCQAi8KwIiLL0rbHKREBACQkAICAEhIASEgBAQAkJACAgBISAEhIAIS/IdEAJCQAgIASEgBISAEBACQkAICAEhIASEgBB4VwREWHpX2OQiISAEhIAQEAJCQAgIASEgBISAEBACQkAICAERluQ7IASEgBAQAkJACAgBISAEhIAQEAJCQAgIASHwrgiIsPSusMlFQkAICAEhIASEgBAQAkJACAgBISAEhIAQEAIiLMl3QAgIASEgBISAEBACQkAICAEhIASEgBAQAkLgXREQYeldYZOLhIAQEAJ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