A Helm chart for deploying nginx web server in Kubernetes with LoadBalancer service support.
This Helm chart deploys nginx in a Kubernetes cluster with the following features:
- High Availability: Deploys 2 nginx pod replicas by default
- LoadBalancer Service: Exposes nginx through a LoadBalancer service for external access
- Production Ready: Includes resource limits, liveness/readiness probes, and proper security contexts
- Highly Configurable: Comprehensive values.yaml with sensible defaults
- Kubernetes Best Practices: Follows Helm and Kubernetes recommended practices
- Kubernetes cluster v1.19+
- Helm 3.0+
- LoadBalancer support in your Kubernetes environment (cloud provider or MetalLB for on-premises)
To install the chart with the release name my-nginx:
helm install my-nginx ./nginx-chartTo install with custom values:
helm install my-nginx ./nginx-chart --set replicaCount=3 --set service.type=NodePort- Create a custom values file:
# custom-values.yaml
replicaCount: 4
image:
tag: "1.25-alpine"
resources:
limits:
cpu: 200m
memory: 256Mi
requests:
cpu: 100m
memory: 128Mi- Install using the custom values:
helm install my-nginx ./nginx-chart -f custom-values.yamlThe following table lists the configurable parameters and their default values:
| Parameter | Description | Default |
|---|---|---|
replicaCount |
Number of nginx replicas | 2 |
image.repository |
nginx image repository | nginx |
image.tag |
nginx image tag | "1.25" |
image.pullPolicy |
Image pull policy | IfNotPresent |
service.type |
Kubernetes service type | LoadBalancer |
service.port |
Service port | 80 |
resources.limits.cpu |
CPU resource limit | 100m |
resources.limits.memory |
Memory resource limit | 128Mi |
resources.requests.cpu |
CPU resource request | 50m |
resources.requests.memory |
Memory resource request | 64Mi |
ingress.enabled |
Enable ingress controller resource | false |
autoscaling.enabled |
Enable horizontal pod autoscaler | false |
For a full list of configurable parameters, see values.yaml.
helm install my-nginx ./nginx-charthelm install my-nginx ./nginx-chart --set replicaCount=5helm install my-nginx ./nginx-chart --set service.type=NodePorthelm install my-nginx ./nginx-chart \
--set ingress.enabled=true \
--set ingress.hosts[0].host=my-nginx.example.com \
--set ingress.hosts[0].paths[0].path=/ \
--set ingress.hosts[0].paths[0].pathType=PrefixAfter installation, follow the instructions in the NOTES output to access your nginx deployment.
For LoadBalancer service (default):
# Wait for external IP to be assigned
kubectl get svc -w <release-name>-nginx-chart
# Get the external IP
export SERVICE_IP=$(kubectl get svc <release-name>-nginx-chart --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
echo "Application URL: http://$SERVICE_IP:80"kubectl get all -l "app.kubernetes.io/instance=<release-name>"kubectl logs -l "app.kubernetes.io/name=nginx-chart,app.kubernetes.io/instance=<release-name>"helm upgrade <release-name> ./nginx-chart --set replicaCount=5To upgrade your deployment:
helm upgrade my-nginx ./nginx-chartTo uninstall the chart:
helm uninstall my-nginxThis will remove all Kubernetes components associated with the chart and delete the release.
- Lint the chart:
helm lint ./nginx-chart- Test template rendering:
helm template test-release ./nginx-chart- Test installation (dry-run):
helm install test-release ./nginx-chart --dry-run --debugnginx-chart/
├── Chart.yaml # Chart metadata
├── values.yaml # Default configuration values
├── templates/
│ ├── deployment.yaml # nginx Deployment
│ ├── service.yaml # LoadBalancer Service
│ ├── serviceaccount.yaml # Service Account
│ ├── ingress.yaml # Ingress (optional)
│ ├── hpa.yaml # Horizontal Pod Autoscaler (optional)
│ ├── NOTES.txt # Post-installation notes
│ └── _helpers.tpl # Template helpers
└── tests/
└── test-connection.yaml # Connection test
If your LoadBalancer service shows <pending> for the external IP:
- Ensure your Kubernetes cluster supports LoadBalancer services
- For on-premises clusters, consider using MetalLB or similar solutions
- Check with your cloud provider for any quotas or issues
Check pod events and logs:
kubectl describe pods -l "app.kubernetes.io/name=nginx-chart"
kubectl logs -l "app.kubernetes.io/name=nginx-chart"If pods are pending due to resource constraints:
kubectl describe nodes
kubectl top podsConsider adjusting resource requests/limits in values.yaml.
This chart is automatically published to GitHub Pages at: https://albal.github.io/nginx-helm
helm repo add nginx-helm https://albal.github.io/nginx-helm
helm repo updatehelm install my-nginx nginx-helm/nginx-chart- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly (run
helm lint nginx-chart) - Submit a pull request
Charts are automatically published when:
- Changes are pushed to the
mainbranch - Version tags (e.g.,
v1.0.1) are created
The GitHub Action workflow will:
- Lint and test the chart
- Package the chart
- Create a GitHub release
- Update the Helm repository index on GitHub Pages
This project is licensed under the terms specified in the LICENSE file.
For support and questions:
- Create an issue in this repository
- Check the troubleshooting section above
- Review Kubernetes and Helm documentation