Search code examples
chartskubernetesdependenciesrenamekubernetes-helm

How can i rename a helm chart once created?


I have created a helm chart named "abc" with the command helm create abc Now when I install this chart, all the kuberenets resources created will have a name containing "abc".

Now I have to rename the chart "abc" to "xyz". If i use helm install --name xyz ./abc only the chart name is changed to xyz. The resources inside it remain with "abc".

I need to rename the entire chart (with its resources) to be renamed. Do I have any option for it?


Solution

  • You can access xyz with {{ .Release.Name }} and need to update the resource names with {{ .Release.Name }} so that the names are picked up dynamically every time:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: {{ .Release.Name }}
      labels:
        app.kubernetes.io/name: {{ .Values.app.dbName }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      replicas: 1
      selector:
        matchLabels:
          app.kubernetes.io/name: {{ .Values.app.dbName }}
          app.kubernetes.io/instance: {{ .Release.Name }}
      template:
        metadata:
          labels:
            app.kubernetes.io/name: {{ .Values.app.dbName }}
            app.kubernetes.io/instance: {{ .Release.Name }}
        spec:
          containers:
            - image: mysql:5.6
              name: "{{ .Release.Name }}-mysql" // or just {{ .Release.Name }}