Checking a Helm Chart Refactor with Manifest Diff

Published: (March 12, 2026 at 12:06 PM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Introduction

When refactoring Helm charts—whether moving logic, simplifying templates, merging files, or cleaning up loops and functions—the goal is to keep the final Kubernetes manifests unchanged. Rendering the manifests before and after the refactor and comparing them provides a simple verification method.

Prerequisites

  • yq – used to sort Kubernetes manifests.
    brew install yq
  • dyff – compares YAML files, highlighting real configuration changes while ignoring formatting differences.
    brew install dyff

Steps

Step 1: Render manifests before changes

helm template my-release ./chart -f values.yaml > before.yaml

Step 2: Refactor the Helm chart

(Make your desired changes to the chart files.)

Step 3: Render manifests again

helm template my-release ./chart -f values.yaml > after.yaml

Step 4: Sort manifests (to avoid noise from ordering)

yq -s 'sort_by(.kind, .metadata.name)' before.yaml > before_sorted.yaml
yq -s 'sort_by(.kind, .metadata.name)' after.yaml > after_sorted.yaml

Sorting prevents differences caused only by resource order changes.

Step 5: Compare manifests

dyff between before_sorted.yaml after_sorted.yaml

If no differences are reported, the refactor did not alter the resulting Kubernetes manifests, indicating that the refactor is safe.

0 views
Back to Blog

Related posts

Read more »

Welcome to Container Harbour! 🚢 Ep.1

Episode 1: Welcome to Container Harbour! 🚢 Listen. LISTEN. We Need to Talk About Your Apps. 🎤 You know what cracks me up? Every time someone asks “What IS Ku...

AWS Cloud Praticttioner #01

Well, when I decided to focus my career in the area of DevOps, I searched for a roadmap. The roadmap highlighted the following topics: - Programming Languages:...