Use patches in the Helm POC

This commit is contained in:
Patrick MARIE 2024-03-21 22:25:22 +01:00
parent 29f9361073
commit 37c49982f5
4 changed files with 37 additions and 4 deletions

7
helm-poc/README.md Normal file
View File

@ -0,0 +1,7 @@
# Notes
Patch was generated with:
```sh
diff -ruN kube-prometheus-stack.orig kube-prometheus-stack.new > ../patches/kube-prometheus-stack.patch
```

View File

@ -10,6 +10,9 @@ let
version = "57.0.3";
url = "https://github.com/prometheus-community/helm-charts/releases/download/${name}-${version}/${name}-${version}.tgz";
hash = "sha256-oZNaFSfFR2dtf5IMUQ0CnXQeVLvoW22JdRqMmgmdtTs=";
patches = [
./patches/kube-prometheus-stack.patch
];
}
rec {
name = "cert-manager";

View File

@ -4,9 +4,16 @@
, lib ? pkgs.lib
}:
let
mkHelm = { name, version, url, hash ? lib.fakeSha256 }:
mkHelm = {
name,
version,
url,
hash ? lib.fakeSha25,
namespace ? "",
patches ? []
}:
pkgs.stdenv.mkDerivation {
inherit name;
inherit name patches;
src = pkgs.fetchurl {
inherit url hash;
@ -14,13 +21,18 @@ let
phases = [
"unpackPhase"
"patchPhase"
"build"
];
namespace = if namespace != "" then "--namespace ${namespace}" else "";
build = ''
mkdir -p $out
${helm} template ${name} ./ > $out/${name}-${version}.yaml
#${helm} version > $out/README
${helm} template \
--namespace ${namespace} \
${name} ./ > $out/${name}-${version}.yaml
${helm} version > $out/VERSION
'';
};

View File

@ -0,0 +1,11 @@
diff '--color=auto' -ruN kube-prometheus-stack.orig/templates/alertmanager/alertmanager.yaml kube-prometheus-stack.new/templates/alertmanager/alertmanager.yaml
--- kube-prometheus-stack.orig/templates/alertmanager/alertmanager.yaml 2024-03-14 23:04:27.000000000 +0100
+++ kube-prometheus-stack.new/templates/alertmanager/alertmanager.yaml 2024-03-21 21:35:56.775410551 +0100
@@ -1,6 +1,6 @@
{{- if .Values.alertmanager.enabled }}
apiVersion: monitoring.coreos.com/v1
-kind: Alertmanager
+kind: Alertmanager # Patch Testaroo
metadata:
name: {{ template "kube-prometheus-stack.alertmanager.crname" . }}
namespace: {{ template "kube-prometheus-stack.namespace" . }}