This example demonstrates how to use the helm-values-manager plugin to manage different configurations for staging and production environments using the Bitnami Nginx chart.
Here are the reference values that we'll be managing across environments:
nginx:
image:
registry: docker.io
repository: bitnami/nginx
tag: latest
pullPolicy: IfNotPresent
nginx:
replicaCount: 1
service:
type: ClusterIP
port: 80
ingress:
enabled: true
hostname: staging.example.com
metrics:
enabled: false
nginx:
replicaCount: 3
service:
type: LoadBalancer
port: 80
ingress:
enabled: true
hostname: example.com
tls: true
metrics:
enabled: true
- Add the Bitnami repository:
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo update
- Initialize helm-values-manager for the nginx release:
helm values-manager init --release nginx-app
- Add value configurations with descriptions and validation:
# Core configurations
helm values-manager add-value-config --path nginx.replicaCount --description "Number of nginx replicas" --required
helm values-manager add-value-config --path nginx.service.type --description "Kubernetes service type (ClusterIP/LoadBalancer)" --required
helm values-manager add-value-config --path nginx.service.port --description "Service port number" --required
# Ingress configuration
helm values-manager add-value-config --path nginx.ingress.enabled --description "Enable ingress" --required
helm values-manager add-value-config --path nginx.ingress.hostname --description "Ingress hostname"
helm values-manager add-value-config --path nginx.ingress.tls --description "Enable TLS for ingress"
# Metrics configuration
helm values-manager add-value-config --path nginx.metrics.enabled --description "Enable prometheus metrics"
- Add deployments for different environments:
helm values-manager add-deployment staging
helm values-manager add-deployment production
- Set values for staging environment:
# Basic configuration
helm values-manager set-value --path nginx.replicaCount --value 1 --deployment staging
helm values-manager set-value --path nginx.service.type --value ClusterIP --deployment staging
helm values-manager set-value --path nginx.service.port --value 80 --deployment staging
# Ingress configuration
helm values-manager set-value --path nginx.ingress.enabled --value true --deployment staging
helm values-manager set-value --path nginx.ingress.hostname --value staging.example.com --deployment staging
# Metrics configuration
helm values-manager set-value --path nginx.metrics.enabled --value false --deployment staging
- Generate staging values:
# Generate staging values - this should succeed as all required values are set
helm values-manager generate --deployment staging
- Set up production environment (demonstrating validation):
# Set some of the production values, intentionally omitting service configuration
helm values-manager set-value --path nginx.replicaCount --value 3 --deployment production
helm values-manager set-value --path nginx.ingress.enabled --value true --deployment production
helm values-manager set-value --path nginx.ingress.hostname --value example.com --deployment production
helm values-manager set-value --path nginx.ingress.tls --value true --deployment production
helm values-manager set-value --path nginx.metrics.enabled --value true --deployment production
# Try to generate values - this should fail with validation errors
helm values-manager generate --deployment production
The above command will fail with validation errors because we haven't set two required values:
nginx.service.type
nginx.service.port
This demonstrates how helm-values-manager helps catch missing configurations early in the deployment process.
- Fix validation errors and complete production setup:
# Set the missing required values
helm values-manager set-value --path nginx.service.type --value LoadBalancer --deployment production
helm values-manager set-value --path nginx.service.port --value 80 --deployment production
# Now the generate command should succeed
helm values-manager generate --deployment production
- Verify configurations using helm template:
# Template the chart for staging environment
helm template nginx-staging bitnami/nginx -f common.yaml -f staging.nginx-app.values.yaml
# Template the chart for production environment
helm template nginx-prod bitnami/nginx -f common.yaml -f prod.nginx-app.values.yaml
# You can also save the templated output to files for inspection
helm template nginx-staging bitnami/nginx -f common.yaml -f staging.nginx-app.values.yaml > staging-manifests.yaml
helm template nginx-prod bitnami/nginx -f common.yaml -f prod.nginx-app.values.yaml > prod-manifests.yaml
The helm template command will show you the actual Kubernetes manifests that would be created, allowing you to:
- Verify that all values are correctly applied
- Inspect the differences between environments
- Catch any issues before actual deployment
- Configuration Validation: Early detection of missing or invalid configurations through required value definitions
- Value Documentation: Each configuration value is documented with clear descriptions
- Environment Separation: Clean separation between staging and production configurations
- Structured Management: Organized way to add and modify values
- Value Tracking: Easy to track what values are available and required
To clean up the example:
- Remove generated value files:
rm -f *.nginx-app.values.yaml
- Remove generated manifest files:
rm -f *-manifests.yaml
- Remove helm-values-manager files:
rm -f helm-values.json .helm-values.lock