Create and deploy a Helm chart with a nginx application, including deployment, service, and configmap configurations. Learn how to customize values using --set and values files.
Prerequisites
Kubernetes cluster running (minikube, kind, or cloud cluster)
helm v3+ installed
kubectl configured to access the cluster
Part 1: Create the Helm Chart
Step 1: Generate the base chart
helm create demo-app
This command creates a basic Helm chart structure with:
This is a security-enhanced nginx image that runs as non-root
Step 4: Add ConfigMap for custom content
A ConfigMap has been added to provide custom HTML content for nginx.
Part 3: Deploy the Application
Step 5: Install the chart with default values
# Deploy with default configurationhelm install my-demo-app ./demo-app
# Verify deploymentkubectl get pods,svc,configmap
Step 6: Check the application
# Port forward to access the applicationkubectl port-forward service/my-demo-app 8080:80
# In another terminal, test the applicationcurl http://localhost:8080
You should see the custom HTML content from the ConfigMap.
Part 4: Customization with –set
Step 7: Override values using –set
# Change replica counthelm upgrade my-demo-app ./demo-app --set replicaCount=3# Change the custom HTML contenthelm upgrade my-demo-app ./demo-app \
--set 'configmap.data.index\.html=<h1>Updated via --set</h1><p>This content was changed using --set flag</p>'# Change image taghelm upgrade my-demo-app ./demo-app --set image.tag=1.27.0-alpine3.21-perl
# Multiple values at oncehelm upgrade my-demo-app ./demo-app \
--set replicaCount=2\
--set image.tag=1.28.0-alpine3.21-perl \
--set service.type=NodePort
Step 8: View current values
# Show all computed valueshelm get values my-demo-app
# Show all values including defaultshelm get values my-demo-app --all
Part 5: Customization with Values Files
Step 9: Create custom values files
Create values-dev.yaml:
replicaCount: 2image:
tag: "1.28.0-alpine3.21-perl"service:
type: NodePortport: 8080configmap:
data:
index.html: | <!DOCTYPE html>
<html>
<head>
<title>Development Environment</title>
<style>
body { font-family: Arial, sans-serif; background-color: #e8f4f8; }
.container { max-width: 800px; margin: 0 auto; padding: 20px; }
h1 { color: #2c5aa0; }
</style>
</head>
<body>
<div class="container">
<h1>Development Environment</h1>
<p>This is the development version of our demo app.</p>
<p>Deployed with custom values file.</p>
</div>
</body>
</html>
# Deploy development environmenthelm upgrade my-demo-app ./demo-app -f values-dev.yaml
# Deploy production environment (new release)helm install my-demo-app-prod ./demo-app -f values-prod.yaml
# Combine values file with --set (--set takes precedence)helm upgrade my-demo-app ./demo-app -f values-dev.yaml --set replicaCount=4
Part 6: Validation and Testing
Step 11: Validate deployments
# List all releaseshelm list
# Check deployment statuskubectl get deployments
kubectl get pods
# Describe the deployment to see applied configurationkubectl describe deployment my-demo-app
# Check ConfigMap contentkubectl get configmap my-demo-app-config -o yaml
Step 12: Test different configurations
# Test dev environmentkubectl port-forward service/my-demo-app 8080:8080
curl http://localhost:8080
# Test prod environmentkubectl port-forward service/my-demo-app-prod 8081:80
curl http://localhost:8081