Helm change name of deployments artiefacts

8/12/2019

I’ve created helm chart which is working as expected, however I want to change the names of the deployed application currently for each deployment I got different (random) name and I want it to be a fixed name, how can I do that?

This is the helper

{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "unleash.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some K8S name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "unleash.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

This is the outcome of the name after deployment

crabby-ibex-postgresql-0              0/1    Pending            0         1s
crabby-ibex-unleash-86775cdffd-xt575  0/1    ContainerCreating  0         1s

This is the names from the values yaml

replicaCount: 1
namespace: unleash
restartPolicy: Never
name: a-unleash
nameOverride: unleash

e.g. I want it instead of

crabby-ibex-unleash-86775cdffd-xt575

to be like

unleash-service
uleash-postgressql 

update

I've added the following to the _helper.tpl

{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 26 | trimSuffix "-" -}}
{{- end -}}

and put the following in the values.yml fullnameOverride: apps

i expect that the artifacts will start with apps and it doesnt work

-- Jenny M
kubernetes
kubernetes-helm

2 Answers

8/12/2019

I don't know, why nobody posted it yet. You can pass the name of the Helm release to the helm install command:

helm install <your_Chart.yaml_directory> -n <release_name>

-- Marcin Ginszt
Source: StackOverflow

8/12/2019

Based of name crabby-ibex-unleash-86775cdffd-xt575 I guess you are using kind: Deployment for this application, if you change kind to StatefulSet in you yaml you will end up with pod named uleash-postgressql-0, but because of helm you have additional prefix, you could use --name=you_relese_name which will create pod you_relese_name-uleash-postgressql-0.

If you really want to get rid of helm chart prefix you have to set fullnameOverride for every chart you are deploying.

EDIT: To make use of fullnameOverride you have to define it in your _helpers.tpl file.

{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "unleash.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some K8S name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "unleash.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 26 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
-- FL3SH
Source: StackOverflow