One of the key strengths of Helm is the ability to customize Charts to fit your specific requirements. Helm Charts come with default values, but each application has unique settings that may need to be adjusted. Instead of manually modifying the YAML templates in the Chart, you can override these values through Helm’s flexible configuration system.
Helm provides two main methods for customizing values: using the --set
flag or a values.yaml
file.
1. Using the --set
Flag
For quick and simple overrides, you can use the --set
flag to specify custom values directly from the command line. This method is ideal for making small adjustments without needing to modify a values file.
For example, if you want to change the number of replicas for an Nginx deployment, you can run the following command:
helm install my-nginx bitnami/nginx --set replicaCount=3
Here, you are telling Helm to use 3
replicas instead of the default value for Nginx. You can pass multiple values at once by using multiple --set
flags or separating the values with commas.
helm install my-nginx bitnami/nginx --set replicaCount=3,service.type=NodePort
This command changes both the replica count and the service type to NodePort
.
2. Using a values.yaml
File
For more complex configurations, it’s better to use a values file. This is a separate YAML file where you define all the overrides in one place. Using a values.yaml
file is particularly useful when dealing with large configurations or multiple overrides, as it keeps your changes organized and maintainable.
Here’s an example of what a custom-values.yaml
file might look like for an Nginx deployment:
replicaCount: 3
service:
type: LoadBalancer
port: 8080
To deploy a Chart with this custom configuration, use the following command:
helm install my-nginx bitnami/nginx -f custom-values.yaml
This method allows you to manage your configuration more easily and keep track of changes across different environments.
3. Combining --set
and values.yaml
You can also combine both methods for maximum flexibility. For example, you might have a base values.yaml
file with general settings but need to override a single value dynamically during deployment.
helm install my-nginx bitnami/nginx -f custom-values.yaml --set service.port=8081
This command will apply all the settings from custom-values.yaml
, but override the service.port
value.
4. Checking Effective Values
After installing or upgrading a release, you might want to check which values are in effect. Helm provides the helm get values
command to retrieve this information:
helm get values my-nginx
This command will show you all the current values being used for the my-nginx
release, including any custom overrides applied.
By leveraging Helm’s powerful value system, you can easily customize any Chart to meet the specific needs of your application. This flexibility ensures that your Kubernetes deployments are both scalable and adaptable to different environments, such as development, staging, or production.
In the next section, we’ll explore how to create your own Helm Charts, giving you complete control over your Kubernetes applications.
Top comments (0)