akhil mittal
Posted on November 6, 2024
To deploy your custom application in a Kubernetes cluster using Helm, follow these steps to create a Helm chart and configure it to deploy the application:
Step-by-Step Guide
1. Set Up Your Environment
- Make sure Helm is installed on your local machine and configured to interact with your Kubernetes cluster.
-
Verify the Helm version and check connectivity to the cluster:
helm version kubectl get nodes
2. Create a New Helm Chart
-
Use Helm to scaffold a new chart for your application:
helm create myapp
This creates a directory named
myapp
with a predefined folder structure (templates
,values.yaml
, etc.).
3. Customize values.yaml
- The
values.yaml
file holds the default configuration values for your chart. Modify it to reflect the settings for your application. For example:- Set the Docker image details (e.g.,
repository
andtag
). - Define service ports, replicas, and other configurations.
- Set the Docker image details (e.g.,
-
Example:
image: repository: your-docker-repo/your-app tag: "latest" service: type: ClusterIP port: 80
4. Edit Kubernetes Manifests in templates
Directory
- The
templates
directory contains YAML templates for various Kubernetes resources. - Edit these files to fit your application requirements:
-
deployment.yaml
for deployment configurations. -
service.yaml
for exposing your application. - Add additional YAML files if you need specific resources like ConfigMaps, Ingress, or Secrets.
-
- For example, customize
deployment.yaml
with your application's container image and other specifications.
5. Package and Install the Helm Chart
-
Before deploying, package the chart to confirm that everything is structured correctly:
helm package myapp
-
Install the Helm chart in your Kubernetes cluster:
helm install myapp ./myapp
This command deploys your application using the configurations defined in your chart.
6. Verify the Deployment
-
Check that the application pods and services are running:
kubectl get pods kubectl get svc
-
To debug any issues, use:
kubectl describe pod <pod-name> kubectl logs <pod-name>
7. Expose the Application (Optional)
- If you want external access to your application, configure an Ingress resource or use a LoadBalancer service type. Update the
service.yaml
andingress.yaml
files accordingly in yourtemplates
directory.
8. Update the Application
-
For any changes to the chart or configuration, use the
helm upgrade
command:
helm upgrade myapp ./myapp
9. Uninstall the Application (Cleanup)
-
To remove the application when it’s no longer needed:
helm uninstall myapp
Summary of Key Components in Helm Chart
-
values.yaml
: Default values for your chart. -
templates/
: Directory containing Kubernetes manifests for deployment, service, and other resources. -
Chart.yaml
: Metadata about the chart (name, version, etc.).
This process gives you flexibility to manage and version control your deployments, making it easier to maintain and scale the application in Kubernetes.
Posted on November 6, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.