Migrate your manifest yaml files into Helm Chart

Abhay Pore
3 min readMar 27, 2023

--

In this blog post we will learn to convert our existing manifest yaml files into Helm Charts.

Manifest Files

Kubernetes manifest files are YAML files that describe the desired state of K8s objects, such as pods , services , deployments , and so on. These files are used to create, update, or delete resources in a kubernetes cluster.

Helm Charts

Helm Charts are template based packaging solution for kubernetes. Helm is the kubernetes equivalent of yum/apt. It is a collection of all your versioned, pre-configured application resources which can be deployed as one unit. You can then deploy another version of the chart with a different set of configuration.

Migration Part

As part of this blog we are going to convert our following existing manifest file into Helm chart using Helmify tool:

Existing Manifest file saved as mainfest.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: nginxdeploy
name: nginxdeploy
spec:
replicas: 1
selector:
matchLabels:
app: nginxdeploy
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: nginxdeploy
spec:
containers:
- image: nginx:latest
name: nginx
resources: {}
status: {}

Helmify

Helmify is a command line tool that converts Kubernetes YAML files to Helm charts. It is designed for operator charts but can also be used for other purposes. Hemify tool reference link: https://github.com/arttor/helmify

Installation:

Installation can be done either using brew or can be downloaded from this link: https://github.com/arttor/helmify/releases/tag/v0.3.33

Once download is finised, run following command:

cat manifest.yaml|helmify nginx

The output of the above command will be a helm chart:

Output

Helm chart will be created with the name nginx, which will contain Chart.yaml templates directory & values.yaml

root@nginxdeploy-546d8dc7fd-s542t:/nginx# ls -lrt
total 12
-rw------- 1 root root 128 Mar 27 12:32 values.yaml
drwxr-x--- 2 root root 4096 Mar 27 12:32 templates
-rw-r----- 1 root root 1137 Mar 27 12:32 Chart.yaml

root@nginxdeploy-546d8dc7fd-s542t:/nginx# cd templates/
root@nginxdeploy-546d8dc7fd-s542t:/nginx/templates# ls -lrt
total 8
-rw------- 1 root root 790 Mar 27 12:32 deployment.yaml
-rw-r----- 1 root root 1762 Mar 27 12:32 _helpers.tpl

root@nginxdeploy-546d8dc7fd-s542t:/nginx/templates# cat deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nginx.fullname" . }}-nginxdeploy
labels:
app: nginxdeploy
{{- include "nginx.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.nginxdeploy.replicas }}
selector:
matchLabels:
app: nginxdeploy
{{- include "nginx.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app: nginxdeploy
{{- include "nginx.selectorLabels" . | nindent 8 }}
spec:
containers:
- env:
- name: KUBERNETES_CLUSTER_DOMAIN
value: {{ quote .Values.kubernetesClusterDomain }}
image: {{ .Values.nginxdeploy.nginx.image.repository }}:{{ .Values.nginxdeploy.nginx.image.tag
| default .Chart.AppVersion }}
name: nginx
resources: {}

root@nginxdeploy-546d8dc7fd-s542t:/nginx# cat values.yaml
kubernetesClusterDomain: cluster.local
nginxdeploy:
nginx:
image:
repository: nginx
tag: latest
replicas: 1

root@nginxdeploy-546d8dc7fd-s542t:/nginx# cat Chart.yaml
apiVersion: v2
name: nginx
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"

Conclusion

You can migrate your all the existing manifest files into Helm Charts using hemify tool, I have personally migrated 30 odd applications using this method.

--

--