kubecost / cost-analyzer-helm-chart

Kubecost helm chart
http://kubecost.com/install
Apache License 2.0
478 stars 416 forks source link

[Bug] cost-analyzer deployment seems to have some duplicated labels #3502

Closed defenestration closed 2 months ago

defenestration commented 3 months ago

Kubecost Helm Chart Version

2.3.0

Kubernetes Version

1.29.0

Kubernetes Platform

AKS

Description

The cost-analyzer deployment seems to have some duplicated labels in spec.template.metadata.labels. This is causing us issues when upgrading from 2.2.5. Using this chart as a Fluxcd.io helmrelease crd,this prevents us from upgrading to 2.3.0.

Error we get is about duplicate keys.

  Warning  UpgradeFailed  45m  helm-controller  Helm upgrade failed for release kubecost/kubecost with chart cost-analyzer@2.3.0: error while running post render on files: map[string]interface {}(nil): yaml: unmarshal errors:
  line 34: mapping key "app.kubernetes.io/name" already defined at line 30
  line 36: mapping key "app.kubernetes.io/instance" already defined at line 31
  line 38: mapping key "app" already defined at line 32

This is parsed output from helm template -n default kubecost-test kubecost/cost-analyzer --version 2.3.0

I noted version 2.2.5 of the chart did not have these duplicate labels as well.

kind: Deployment
metadata:
  name: kubecost-test-cost-analyzer
  namespace: default
  labels:
    app.kubernetes.io/name: cost-analyzer
    helm.sh/chart: cost-analyzer-2.3.0
    app.kubernetes.io/instance: kubecost-test
    app.kubernetes.io/managed-by: Helm
    app: cost-analyzer
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: cost-analyzer
      app.kubernetes.io/instance: kubecost-test
      app: cost-analyzer
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: cost-analyzer
        app.kubernetes.io/instance: kubecost-test
        app: cost-analyzer
        helm-rollout-restarter: "ZY72b"
        app.kubernetes.io/name: cost-analyzer
        helm.sh/chart: cost-analyzer-2.3.0
        app.kubernetes.io/instance: kubecost-test
        app.kubernetes.io/managed-by: Helm
        app: cost-analyzer
...

Steps to reproduce

  1. helm template -n default kubecost-test kubecost/cost-analyzer --version 2.3.0
  2. observe duplicate labels in spec.template.metadata.labels, mainly app.kubernetes.io/name and other app.kubernetes.io ones as well.

Expected behavior

Functional upgrade

Impact

Staying on 2.2.5 for now.

Screenshots

No response

Logs

Warning  UpgradeFailed  45m  helm-controller  Helm upgrade failed for release kubecost/kubecost with chart cost-analyzer@2.3.0: error while running post render on files: map[string]interface {}(nil): yaml: unmarshal errors:
  line 34: mapping key "app.kubernetes.io/name" already defined at line 30
  line 36: mapping key "app.kubernetes.io/instance" already defined at line 31
  line 38: mapping key "app" already defined at line 32


### Slack discussion

_No response_

### Troubleshooting

- [X] I have read and followed the [issue guidelines](https://github.com/kubecost/cost-analyzer-helm-chart/blob/develop/ISSUE_GUIDELINES.md) and this is a bug impacting only the Helm chart.
- [X] I have searched other issues in this repository and mine is not recorded.
AjayTripathy commented 3 months ago

Hey @defenestration this shouldn't break the default helm install but I agree they should be removed as they are duplicates. cc @jessegoodier do you know if the plan is to remove this in 2.3.1?

jessegoodier commented 3 months ago

3500

it will be fixed in 2.3.1

jessegoodier commented 3 months ago

for anyone that wants the fix before Monday, RC.1 is out and will most likely be 2.3.1

helm upgrade kubecost --repo https://kubecost.github.io/cost-analyzer cost-analyzer --namespace kubecost --version 2.3.1-rc.2
AjayTripathy commented 2 months ago

This is fixed in latest.