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:
CODEhelm version
kubectl get nodes
2. Create a New Helm Chart
Use Helm to scaffold a new chart for your application:
CODEhelm create myapp
This creates a directory named
myappwith a predefined folder structure (templates,values.yaml, etc.).
3. Customize values.yaml
- The
values.yamlfile 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.,
repositoryandtag). - Define service ports, replicas, and other configurations.
- Set the Docker image details (e.g.,
Example:
CODEimage:
repository: your-docker-repo/your-app
tag: "latest"
service:
type: ClusterIP
port: 80
4. Edit Kubernetes Manifests in templates Directory
- The
templatesdirectory contains YAML templates for various Kubernetes resources. - Edit these files to fit your application requirements:
deployment.yamlfor deployment configurations.
service.yamlfor exposing your application.- Add additional YAML files if you need specific resources like ConfigMaps, Ingress, or Secrets.
- For example, customize
deployment.yamlwith 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:
CODEhelm package myapp
Install the Helm chart in your Kubernetes cluster:
CODEhelm 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:
CODEkubectl get pods
kubectl get svc
To debug any issues, use:
CODEkubectl 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.yamlandingress.yamlfiles accordingly in yourtemplatesdirectory.
8. Update the Application
For any changes to the chart or configuration, use the
helm upgradecommand:
CODEhelm upgrade myapp ./myapp
9. Uninstall the Application (Cleanup)
To remove the application when it’s no longer needed:
CODEhelm 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.
SOCIAL SHARE CARD GENERATOR