<p>After double-checking that the labels is not really there using <code>helm template ...</code>, you maybe try using <code>helm upgrade --force ...</code> so it will replace the resource and use the new labels.</p>

CC BY-SA 4.0
2023-10-17T14:56:02.360Z
2023-10-17T14:56:02.360Z
Ahmed AbouZaid
<p>I have an existing deployment that has the label <code>importance: normal</code> in spec/template/metadata/labels (all the pods spawned from this deployment have that label in them).</p>
<p>The current deployment yaml does NOT have that <code>importance: normal</code> label in it. It was in an older version of the deployment yaml.</p>
<p>So everything that was deployed with the original deployment yaml has this importance label in it. After we perform a <code>helm upgrade --install</code> and use the latest deployment yaml(which does not have this label) and when we look at the deployment in the cluster is still has this label in it. The deployment does have the changes we made but it does not delete this old label.</p>
<p>I want to be able to remove that label when a helm upgrade is performed.</p>
<p>I tried the following trying to use the --set flag but have had no luck.</p>
<p>Command I tried - which did nothing:</p>
<p><code>helm upgrade --install echo service-standard/service-standard --namespace qa --set-string spec.template.metadata.labels.importance=&quot;&quot; -f ./helm-chart/values.shared.yaml --wait --timeout 600s</code></p>
<p>I also tried using <code>--reset-values</code> and that also had no effect.</p>
<p>Here is the snippet of the deployment that I am trying to remove the label from - The label is in the first spec block (not the second) right before <code>app: echo-selector</code> :</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: &quot;8&quot;
  creationTimestamp: &quot;2022-12-14T15:24:04Z&quot;
  generation: 9
  labels:
    app.kubernetes.io/managed-by: Helm
  name: echo-deployment
spec:
  replicas: 2
  revisionHistoryLimit: 5
  template:
    metadata:
      annotations:
        linkerd.io/inject: enabled
      creationTimestamp: null
      labels:
        app: echo-selector
        importance: normal
        version: current
    spec:
      containers:
      - env:
        - name: TEST
</code></pre>
<p>We do not want to have to delete the deployment and re install it (which would remove the label).
Any help or advice is greatly appreciated!!!!</p>

CC BY-SA 4.0
2023-02-11T15:15:27.870Z
Did you try helm template command and made sure the output didn't have the label?
taleodor
<containers><helm><kubernetes-helm>
How to delete an existing label in a deployment with helm upgrade
ErnieAndBert
# How to delete an existing label in a deployment with helm upgrade

(Asked by: username_0 on 2023-02-09)

I have an existing deployment that has the label importance: normal in spec/template/metadata/labels (all the pods spawned from this deployment have that label in them).
The current deployment yaml does NOT have that importance: normal label in it. It was in an older version of the deployment yaml.
So everything that was deployed with the original deployment yaml has this importance label in it. After we perform a helm upgrade --install and use the latest deployment yaml(which does not have this label) and when we look at the deployment in the cluster is still has this label in it. The deployment does have the changes we made but it does not delete this old label.
I want to be able to remove that label when a helm upgrade is performed.
I tried the following trying to use the --set flag but have had no luck.
Command I tried - which did nothing:
helm upgrade --install echo service-standard/service-standard --namespace qa --set-string spec.template.metadata.labels.importance="" -f ./helm-chart/values.shared.yaml --wait --timeout 600s
I also tried using --reset-values and that also had no effect.
Here is the snippet of the deployment that I am trying to remove the label from - The label is in the first spec block (not the second) right before app: echo-selector :
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "8"
  creationTimestamp: "2022-12-14T15:24:04Z"
  generation: 9
  labels:
    app.kubernetes.io/managed-by: Helm
  name: echo-deployment
spec:
  replicas: 2
  revisionHistoryLimit: 5
  template:
    metadata:
      annotations:
        linkerd.io/inject: enabled
      creationTimestamp: null
      labels:
        app: echo-selector
        importance: normal
        version: current
    spec:
      containers:
      - env:
        - name: TEST

We do not want to have to delete the deployment and re install it (which would remove the label).
Any help or advice is greatly appreciated!!!!

**Tags:** containers, helm, kubernetes-helm

> **Comments:**
> **username_1**: Did you try helm template command and made sure the output didn't have the label?  

---

## 1 answers

### Answer by username_2 on 2023-10-17. Score: 1

After double-checking that the labels is not really there using `helm template ...`, you maybe try using `helm upgrade --force ...` so it will replace the resource and use the new labels.


---

