Host your First Helm chart

Host your First Helm chart

Introduction:

Helm is a package manager for Kubernetes that simplifies the deployment and management of applications. With Helm, you can define, install, and upgrade complex Kubernetes applications with ease. In this guide, we’ll walk through hosting your first Helm chart, complete with real-world examples and scenarios.

Hosting your first Helm Chart on GitHub not only promotes collaboration but also provides version control and easy accessibility for others. This article will walk you through a real-time scenario of creating, packaging, and hosting a Helm Chart on GitHub.

What is a Helm Chart?

A Helm chart is a collection of YAML files and templates that describe a Kubernetes application, making it easy to deploy and manage. It’s like a recipe for your application, specifying its components, configurations, and dependencies.

Create your Helm Chart:

helm create mustafa

Now you will get mustafa folder.

Go to the folder:

cd mustafa

Now customize our helm charts by making the changes changes on Chart.yaml & values .yaml:

Chart.yaml

apiVersion: v2
name: mustafa
description: A Helm chart for Kubernetes
type: application
version: 0.1.0
appVersion: "latest"

values.yaml


replicaCount: 1
image:
  repository: shaikmustafa/dm
  # This sets the pull policy for images.
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: ""

# This is for the secretes for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
imagePullSecrets: []
# This is to override the chart name.
nameOverride: ""
fullnameOverride: ""
serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Automatically mount a ServiceAccount's API credentials?
  automount: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: ""

podAnnotations: {}
# This is for setting Kubernetes Labels to a Pod.
# For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
podLabels: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000# This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/
service:
  # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
  type: NodePort
  # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports
  port: 80

# This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/
ingress:
  enabled: false
  className: ""
  annotations: {}
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
  hosts:
    - host: chart-example.local
      paths:
        - path: /
          pathType: ImplementationSpecific
  tls: []
  #  - secretName: chart-example-tls
  #    hosts:
  #      - chart-example.local
resources: {}
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
livenessProbe:
  httpGet:
    path: /
    port: http
readinessProbe:
  httpGet:
    path: /
    port: http

#This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/
autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80

# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
#   secret:
#     secretName: mysecret
#     optional: false

volumeMounts: []
# - name: foo
#   mountPath: "/etc/foo"
#   readOnly: true

nodeSelector: {}

tolerations: []

affinity: {}

Now go back to folder:

cd ../

Test your chart:

helm lint mustafa && helm template mustafa

Pack your helm chart:

helm package mustafa

Then you will get mustafa-0.1.0.tgz file

Now generate index.yaml file:

helm repo index .

It will generate index.yaml file

Install git in your system:

yum install git -y

Now Create a Repo on GitHub and clone it

Clone the Repo:

git clone https://github.com/usubbu/helm-repo.git

move this index.yaml & mustafa-0.1.0.tgz files to helm-repo folder

mv index.yaml mustafa-0.1.0.tgz helm-repo

Now push the code to github:

cd helm-repo
git add .
git commit -m "my helm is ready"
git push -u origin main

Now open repository settings » select pages option

Select the branch as main and path as /root and click on save

Wait for 2 minutes untill links gets enabled. After some time you will get repo link as usubbu.github.io/helm-repo

Now your helm is live copy the url and paste it on browser.

That’s it! we hosted our first helm. Now anyone can download the helm using

helm repo add devops https://usubbu.github.io/helm-repo/

Conclusion

Hosting your Helm Chart on GitHub is an excellent practice for collaboration and CI/CD integration. By following this guide, you have packaged, tested, and hosted a Helm Chart for a real-time application.