<p>I'm playing around with GitOps and ArgoCD in Redhat Openshift. My goal is to switch a worker node to an infra node.</p>

<p>I want to do this with descriptive YAML Files, and NOT manually by using the command line (that's easy with kubectl label node ...)</p>

<p>In order to do make the node an infra node, I want to add a label "infra" and take the label "worker" from it. Before, the object looks like this (irrelevant labels omitted): </p>

<pre><code>apiVersion: v1
kind: Node
metadata:
  labels:
    node-role.kubernetes.io/infra: ""
  name: node6.example.com
spec: {}
</code></pre>

<p>After applying a YAML File, it's supposed to look like that: </p>

<pre><code>apiVersion: v1
kind: Node
metadata:
  labels:
    node-role.kubernetes.io/worker: ""
  name: node6.example.com
spec: {}
</code></pre>

<p>If I put the latter config in a file, and do "kubectl apply -f ", the node has both infra and worker labels. So adding a label or changing the value of a label is easy, but is there a way to remove a label in an objects metadata by applying a YAML file ?</p>

<p>you can delete the label with</p>

<pre><code>kubectl label node node6.example.com node-role.kubernetes.io/infra-
</code></pre>

<p>than you can run the <code>kubectl apply</code> again with the new label.
You will be up and running.</p>
