Andy
Andy

Reputation: 738

Is There a Way to Detect Changes made to Resources Deployed by a Helm Chart

We have several resources deployed as part of a helm (v3) chart. Some time ago, I made changes to resources deployed by that helm chart manually, via kubectl. This caused some drift between the values in the yaml resources deployed by the helm release (as show by helm get values <release>) and what is actually deployed in the cluster

Example: kubectl describe deployment <deployment> shows an updated image that was manually applied via a kubectl re-apply. Whereas helm show values <release> shows the original image used by helm for said deployment.

I realize that I should have performed a helm upgrade with a modified values.yaml file to execute the image change, but I am wondering if there is a way for me to sync the state of the values I manually updated with the values in the helm release. The goal is to create a new default values.yaml that reflect the current state of the cluster resources.

Thanks!

Upvotes: 5

Views: 4881

Answers (3)

tof
tof

Reputation: 1

I guess best is to use helm diff with --three-way-merge option. Like that helm will compare the expected chart with the deployed one (including manual changes)

Upvotes: 0

nikhil bhat
nikhil bhat

Reputation: 26

kubectl diff will help to identify the changes but it needs the manifests to do that. One has to generate manifests from the helm and identify drifts from each one of them by running kubectl diff.

I have created a helm plugin helm-drift (heavily depends on kubectl diff) which takes care of communication between helm and kubectl-diff to identify drifts.

Upvotes: 1

Andrew Skorkin
Andrew Skorkin

Reputation: 1376

This is a community wiki answer posted for better visibility. Feel free to expand it.

According to the Helm issue 2730 this feature will not be added in the Helm, as it is outside of the scope of the project.

It looks like there is no existing tool right from the Helm, that would help to port/adapt the life kubernetes resource back into existing or new helm charts/releases.

Based on this, you can use one of the following options:

  1. As suggested by @David Maze. The Helm Diff Plugin will show you the difference between the chart output and the cluster, but then you need to manually update values.yaml and templates.
  2. The helm-adopt plugin is a helm plugin to adopt existing k8s resources into a new generated helm chart.

Upvotes: 2

Related Questions