Skip to main content

Command Palette

Search for a command to run...

Running Node app using Helm Charts inside Kubernetes Cluster

Published
โ€ข6 min readโ€ขView as Markdown
S
I'm energetic, ambitious person who has developed a mature and responsible approach to any task that I undertake, or situation that I am presented with. I am excellent at working with others to achieve a certain objective on time and with excellence. Customer Engineer| Al/ ML |AI Infrastructure | Cloud Migration |Technical Solution| Vertex AI| Cloud Database |Cloud Networking |DevOps Engineer| Technical Blogger| Generative AI| Google Cloud Ready Facilitator ๐ŸŒLinux Linux Professional Institute Certificate Technical Writer \ Cloud Networking Cloud Computing \ Cloud Infrastructure Cloud Consultant \ Customer Engineer ๐ŸŒVirtualization - VMware, vSphere, vCenter Server ๐ŸŒProgramming Skill Technical Skills Proficiency in languages like Java, Python, Scala, or JavaScript. System Administration: Experience with Linux/Unix systems, Windows Server. Networking: Understanding of network protocols, routing, VPC, Subnets, Firewalls, VPNs, Load Balancers, switching, and firewall configurations. Cloud Platforms: Experience with AWS, Azure, or Google Cloud Platform. Databases: Knowledge of SQL and NoSQL databases like MySQL, PostgreSQL, MongoDB. Scripting: Ability to write scripts for automation using Bash, PowerShell, or similar. Monitoring and Logging: Familiarity with tools like Nagios, Prometheus, Grafana, ELK Stack. Configuration Management: Experience with tools like Ansible, Puppet, Chef. DevOps: Knowledge of CI/CD pipelines, Jenkins, Docker, Kubernetes. Security: Understanding of security best practices and tools, Cloud security best practices, IAM, Security Groups, Compliance. Infrastructure as Code: Terraform, CloudFormation, Ansible Compute Services: EC2, GCE, Azure VMs. Storage Solutions: S3, GCS Customer Service Skills:- Communication: Strong verbal and written communication skills. Problem-Solving: Ability to diagnose and resolve technical issues efficiently. Interpersonal Skills: Building and maintaining relationships with clients. Training and Education: Ability to conduct training sessions for clients. Project Management: Managing customer projects and ensuring timely delivery. Knowledge/experience in configuring and supporting devices such as Cisco, Juniper, Checkpoint, etc. Knowledge Cloud Migration, Presale, Data Center relocation, Go-to-Market Strategy. Certifications: AWS Certified Solutions Architect Microsoft Certified: Azure Solutions Architect Expert Google Professional Cloud Architect Certified Kubernetes Administrator (CKA)

TABLE OF CONTENTS

  • ๐Ÿ“ Introduction:

  • Why Helm? ๐Ÿค”

  • ๐Ÿ“‹ Prerequisites:

    • Before we begin, make sure you have the following prerequisites in place:

    • ๐Ÿ“ Step 1: Create a Helm Chart

    • ๐Ÿ“ Step 2: Edit values.yaml

    • ๐Ÿš€ Step 3: Deploy the Helm Chart

  • ๐Ÿ“Conclusion:

๐Ÿ“ Introduction:

In this blog post, we will walk you through the process of deploying a Docker image from Docker Hub using Helm. Helm is a powerful package manager for Kubernetes that allows you to define, install, and upgrade even the most complex Kubernetes applications.

Why Helm? ๐Ÿค”

Helm solves several challenges in the Kubernetes deployment process:

  1. Package Management: Helm allows you to package your application, including all its dependencies and configurations, into a single unit called a "chart." This simplifies the distribution and installation of complex applications.

  2. Version Control: Helm charts can be versioned and stored in a chart repository, making it easy to manage different versions of your application and rollback to previous versions if needed.

  3. Templating: Helm uses Go templates to generate Kubernetes manifest files dynamically, enabling you to customize deployments for different environments (e.g., development, production) without duplicating code.

  4. Upgrade and Rollback: Helm simplifies the process of upgrading and rolling back applications, ensuring smooth updates and minimizing downtime.

  5. Collaboration: Teams can collaborate more effectively by sharing and reusing Helm charts, reducing the risk of configuration errors.

Real-World Example: Imagine you are managing a microservices-based application with multiple services that need to be deployed and scaled independently. Helm allows you to create charts for each service, define their dependencies, and manage their deployments as a cohesive application. When you need to update a service or roll back to a previous version due to issues, Helm simplifies the process, making your DevOps tasks more efficient and error-free.

Helm is a valuable tool in the DevOps toolbox, streamlining Kubernetes deployments and making it easier to manage complex applications in a containerized environment. ๐Ÿšข๐Ÿ“ฆ๐ŸŽ›๏ธ

๐Ÿ“‹ Prerequisites:

Before we begin, make sure you have the following prerequisites in place:

  • Kubernetes cluster: You should have a Kubernetes cluster up and running.

  • Helm: Helm should be installed on your local machine.

  •       curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | sudo tee /usr/share/keyrings/helm.gpg > /dev/null
          sudo apt-get install apt-transport-https --yes
          echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
          sudo apt-get update
          sudo apt-get install helm
    
  • Docker: You need Docker installed on your local machine for building and pushing Docker images.

๐Ÿ“ Step 1: Create a Helm Chart

First, we need to create a Helm chart to define the deployment of our application. Open your terminal and run the following command to create a Helm chart named "node-app":

helm create note-app

This command generates a directory structure for your Helm chart with default templates and values.

๐Ÿ“ Step 2: Edit values.yaml

Navigate to the "node-app" directory and open the values.yaml file in your preferred text editor. Update the file to match the specifications you provided in your question:

replicaCount: 2

image:
  repository: trainwithshubham/node-app-test-new
  pullPolicy: Always 
  # Overrides the image tag whose default is the chart appVersion.
  tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
  # Specifies whether a service account should be created
  create: 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: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

service:
  type: NodePort
  port: 8000
  targetPort: 8000
  nodePort: 30012

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

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 4
  targetCPUUtilizationPercentage: 50
  # targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}

This configuration specifies the number of replicas, Docker image details, and service specifications for your application.

๐Ÿš€ Step 3: Deploy the Helm Chart

Now that our Helm chart is configured, we can deploy our application to the Kubernetes cluster. Use the following command:

helm install note-app ./note-app

This command deploys the "node-app" Helm chart to your Kubernetes cluster. Helm will create all the necessary Kubernetes resources based on the configuration in your chart.

๐Ÿ” Step 4: Verify the Deployment To verify that your application has been deployed successfully, you can run the following command to list all the deployments in your cluster:

kubectl get deployments
or
kubectl get all

You should see the "node-app" deployment listed with the desired number of replicas.

๐ŸŒ Step 5: Access Your Application To access your application, you can use the NodePort service you defined in the values.yaml file. Find the NodePort assigned to your service:

kubectl get svc

Locate the "node-app" service and note the port under "PORT(S)". You can now access your application using your Kubernetes cluster's IP address and the NodePort.

๐ŸŽ‰ Congratulations! You have successfully deployed a Docker image from Docker Hub using Helm. Helm makes it easy to define and manage complex Kubernetes deployments, making it an essential tool for DevOps engineers working with Kubernetes.

๐Ÿ“Conclusion:

In this guide, we've taken you through the step-by-step process of deploying a Docker image from Docker Hub using Helm. Helm, with its powerful package management capabilities, simplifies the deployment and management of applications in Kubernetes. Here's a recap of what we've covered:

  1. Prerequisites: We ensured you have a Kubernetes cluster, Helm installed, and Docker set up on your local machine.

  2. Creating a Helm Chart: We started by creating a Helm chart named "node-app." Helm charts are essential for defining and packaging Kubernetes applications.

  3. Editing values.yaml: We customized the configuration in the values.yaml file to specify details about the application, including the Docker image, replica count, and service settings.

  4. Deploying the Helm Chart: With the Helm chart configured, we deployed the application to the Kubernetes cluster using the helm install command.

  5. Verification: We confirmed the successful deployment by checking the status of the Kubernetes deployment and services.

  6. Accessing Your Application: We explained how to access your application using the NodePort service defined in the chart.

Helm simplifies complex Kubernetes deployments by offering package management, version control, templating, and easy upgrade and rollback capabilities. It streamlines collaboration among teams, making it a valuable tool for DevOps engineers managing containerized applications.

3 views

More from this blog

C

CloudGrad

96 posts