Skip to content

Commit

Permalink
Enable Helm drift detection
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
  • Loading branch information
stefanprodan committed Nov 23, 2023
1 parent eabe461 commit 4daaf81
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@

# Dependency directories (remove the comment below to include it)
# vendor/
bin/
2 changes: 1 addition & 1 deletion manifests/bases/helm-controller/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
#- https://github.com/fluxcd/helm-controller/releases/download/v0.36.2/helm-controller.crds.yaml
- https://raw.githubusercontent.com/fluxcd/helm-controller/new-reconciler/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
- https://raw.githubusercontent.com/fluxcd/helm-controller/new-drift-detection/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
- https://github.com/fluxcd/helm-controller/releases/download/v0.36.2/helm-controller.deployment.yaml
- account.yaml
transformers:
Expand Down
2 changes: 1 addition & 1 deletion manifests/install/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ images:
newName: ghcr.io/fluxcd/kustomize-controller
- name: fluxcd/helm-controller
newName: ghcr.io/fluxcd/helm-controller
newTag: v2beta2-f03453d8
newTag: v2beta2-a2648034
- name: fluxcd/notification-controller
newName: ghcr.io/fluxcd/notification-controller
- name: fluxcd/image-reflector-controller
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by timoni. DO NOT EDIT.

//timoni:generate timoni vendor crd -f https://raw.githubusercontent.com/fluxcd/helm-controller/new-reconciler/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
//timoni:generate timoni vendor crd -f https://raw.githubusercontent.com/fluxcd/helm-controller/new-drift-detection/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

package v2beta1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Code generated by timoni. DO NOT EDIT.

//timoni:generate timoni vendor crd -f https://raw.githubusercontent.com/fluxcd/helm-controller/new-reconciler/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml
//timoni:generate timoni vendor crd -f https://raw.githubusercontent.com/fluxcd/helm-controller/new-drift-detection/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

package v2beta2

Expand Down Expand Up @@ -146,6 +146,66 @@ import "strings"
namespace?: string
}]

// DriftDetection holds the configuration for detecting and
// handling differences between the manifest in the Helm storage
// and the resources currently existing in the cluster.
driftDetection?: {
// Ignore contains a list of rules for specifying which changes to
// ignore during diffing.
ignore?: [...{
// Paths is a list of JSON Pointer (RFC 6901) paths to be excluded
// from consideration in a Kubernetes object.
paths: [...string]

// Target is a selector for specifying Kubernetes objects to which
// this rule applies. If Target is not set, the Paths will be
// ignored for all Kubernetes objects within the manifest of the
// Helm release.
target?: {
// AnnotationSelector is a string that follows the label selection
// expression
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
// It matches with the resource annotations.
annotationSelector?: string

// Group is the API group to select resources from. Together with
// Version and Kind it is capable of unambiguously identifying
// and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
group?: string

// Kind of the API Group to select resources from. Together with
// Group and Version it is capable of unambiguously identifying
// and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
kind?: string

// LabelSelector is a string that follows the label selection
// expression
// https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api
// It matches with the resource labels.
labelSelector?: string

// Name to match resources with.
name?: string

// Namespace to select resources from.
namespace?: string

// Version of the API Group to select resources from. Together
// with Group and Kind it is capable of unambiguously identifying
// and/or selecting resources.
// https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/api-group.md
version?: string
}
}]

// Mode defines how differences should be handled between the Helm
// manifest and the manifest currently applied to the cluster. If
// not explicitly set, it defaults to DiffModeDisabled.
mode?: "enabled" | "warn" | "disabled"
}

// Install holds the configuration for Helm install actions for
// this HelmRelease.
install?: {
Expand Down Expand Up @@ -247,7 +307,7 @@ import "strings"

// MaxHistory is the number of revisions saved by Helm for this
// HelmRelease. Use '0' for an unlimited number of revisions;
// defaults to '10'.
// defaults to '5'.
maxHistory?: int

// PersistentClient tells the controller to use a persistent
Expand Down
4 changes: 3 additions & 1 deletion timoni/modules/flux-hr-bench/templates/config.cue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import (
interval: int | *60
}

runTests: bool | *false
driftDetection: "enabled" | "warn" | "disabled" | *"enabled"

runTests: bool | *false
failTests: bool | *false

releases: int | *1
Expand Down
3 changes: 3 additions & 0 deletions timoni/modules/flux-hr-bench/templates/helmrelease.cue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
interval: "\(10*_config.chart.interval)m"
}
}
driftDetection: {
mode: _config.driftDetection
}
install: crds: "Create"
upgrade: crds: "CreateReplace"
if _config.pods > 0 {
Expand Down

0 comments on commit 4daaf81

Please sign in to comment.