Skip to the content.

33. Helm: Use values.schema.json

Date: 2024-10-21

Status

Accepted

Context

As our infrastructure grows, maintaining consistency and ensuring the correctness of Helm chart configurations has become increasingly challenging. We have multiple Helm charts across different services, and without proper validation, misconfigurations in values.yaml can lead to deployment failures or unexpected behavior in our applications.

Currently, there’s no standardized way in our workflow to enforce schema validation on the values provided to Helm charts. This lack of validation increases the risk of runtime errors and complicates the debugging process when deployments fail due to incorrect configurations.

We need a solution that allows us to define, validate, and enforce the structure and types of the configurations expected by our Helm charts.

Decision

We have decided to utilize values.schema.json files in our Helm charts to define the expected configuration schema and enforce validation of values.yaml files. This will be implemented by:

Pipeline Schema

Below is a PlantUML diagram illustrating the schema validation pipeline:

@startuml
title Helm Values Schema Validation Pipeline

start

:Developer updates `values.yaml`;
:Commit changes to repository;

if (Is `.schema.yaml` present?) then (Yes)
  :Run `helm-values-generate` target;
  :Generate `values.schema.json` using helm-values-schema-json;
  :Validate `values.yaml` against `values.schema.json`;
  if (Validation Success?) then (Yes)
    :Proceed with CI/CD pipeline;
  else (No)
    :Fail the build with validation errors;
  endif
else (No)
  :Skip schema validation;
  :Proceed with CI/CD pipeline;
endif

stop

@enduml

Consequences

Benefits:

Drawbacks:

References