


Introducing Helm CEL: A More Expressive Way to Validate Your Helm Charts
If you've worked with Helm charts, you're probably familiar with the challenge of validating values.yaml. While Helm's built-in JSON Schema validation works, it can be cumbersome and limiting. Today, I want to introduce you to Helm CEL, a plugin that brings the power of Google's Common Expression Language (CEL) to Helm chart validation.
What is CEL?
Before diving in, let's quickly cover what CEL is. Common Expression Language (CEL) is a simple expression language created by Google that lets you write concise, powerful validation rules. It's used in Kubernetes CRD validation, Istio configuration, and many other projects in the cloud-native ecosystem.
Why Use CEL Instead of JSON Schema?
- More Expressive: CEL allows you to write complex validation rules in a more natural and readable way
- Familiar Syntax: If you're coming from programming languages like Python or JavaScript, CEL's syntax will feel natural
- Type-Safe: CEL provides strong type checking while remaining flexible
- Built for Cloud Native: CEL is already used throughout the Kubernetes ecosystem
Getting Started
First, install the plugin:
helm plugin install https://github.com/idsulik/helm-cel
Instead of creating a values.schema.json, you'll create a values.cel.yaml file in your chart directory. Here's a simple example:
rules: - expr: "has(values.service) && has(values.service.port)" desc: "service port is required" - expr: "values.service.port >= 1 && values.service.port <= 65535" desc: "service port must be between 1 and 65535" - expr: "!(has(values.replicaCount)) || values.replicaCount >= 1" desc: "if replicaCount is set, it must be at least 1"
To validate your chart:
helm cel ./mychart
Real-World Examples
Let's look at some common validation patterns and how they're expressed in both JSON Schema and CEL.
1. Required Fields
JSON Schema:
{ "required": ["service"], "properties": { "service": { "required": ["port"], "properties": { "port": { "type": "integer" } } } } }
CEL:
rules: - expr: "has(values.service) && has(values.service.port)" desc: "service port is required"
2. Conditional Requirements
JSON Schema:
{ "if": { "properties": { "persistence": { "const": true } } }, "then": { "required": ["storageClass"] } }
CEL:
rules: - expr: "!has(values.persistence) || !values.persistence || has(values.storageClass)" desc: "storageClass is required when persistence is enabled"
3. Complex Validations
JSON Schema can become quite verbose for complex validations. Here's a CEL example that would be much more complicated in JSON Schema:
rules: - expr: | !has(values.resources) || (!has(values.resources.limits) && !has(values.resources.requests)) || (has(values.resources.limits.memory) && has(values.resources.requests.memory) && int(values.resources.requests.memory) <= int(values.resources.limits.memory)) desc: "If resources are specified, memory request must not exceed memory limit"
Error Messages That Make Sense
One of the best features of Helm CEL is its clear error messages. When validation fails, you get helpful output like this:
❌ Validation failed: replica count must be at least 1 Rule: values.replicaCount >= 1 Path: replicaCount Current value: 0
Performance Considerations
CEL expressions are compiled and evaluated efficiently. The plugin adds minimal overhead to your Helm workflow, making it suitable for both development and CI/CD pipelines.
Next Steps
- Install the plugin: helm plugin install https://github.com/idsulik/helm-cel
- Check out the GitHub repository for more examples
- Start writing your own validation rules!
Conclusion
Helm CEL brings a more expressive and maintainable way to validate your Helm charts. If you've ever found yourself fighting with JSON Schema or wanting more flexible validation rules, give it a try. The combination of familiar syntax, powerful expressions, and clear error messages makes it a valuable addition to any Helm user's toolkit.
What validation patterns would you like to see? Let me know in the comments below!
The above is the detailed content of Introducing Helm CEL: A More Expressive Way to Validate Your Helm Charts. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

OpenSSL, as an open source library widely used in secure communications, provides encryption algorithms, keys and certificate management functions. However, there are some known security vulnerabilities in its historical version, some of which are extremely harmful. This article will focus on common vulnerabilities and response measures for OpenSSL in Debian systems. DebianOpenSSL known vulnerabilities: OpenSSL has experienced several serious vulnerabilities, such as: Heart Bleeding Vulnerability (CVE-2014-0160): This vulnerability affects OpenSSL 1.0.1 to 1.0.1f and 1.0.2 to 1.0.2 beta versions. An attacker can use this vulnerability to unauthorized read sensitive information on the server, including encryption keys, etc.

Backend learning path: The exploration journey from front-end to back-end As a back-end beginner who transforms from front-end development, you already have the foundation of nodejs,...

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

The library used for floating-point number operation in Go language introduces how to ensure the accuracy is...

Queue threading problem in Go crawler Colly explores the problem of using the Colly crawler library in Go language, developers often encounter problems with threads and request queues. �...

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

What should I do if the custom structure labels in GoLand are not displayed? When using GoLand for Go language development, many developers will encounter custom structure tags...

The difference between string printing in Go language: The difference in the effect of using Println and string() functions is in Go...
