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"; version = "57.0.3";
url = "https://github.com/prometheus-community/helm-charts/releases/download/${name}-${version}/${name}-${version}.tgz"; url = "https://github.com/prometheus-community/helm-charts/releases/download/${name}-${version}/${name}-${version}.tgz";
hash = "sha256-oZNaFSfFR2dtf5IMUQ0CnXQeVLvoW22JdRqMmgmdtTs="; hash = "sha256-oZNaFSfFR2dtf5IMUQ0CnXQeVLvoW22JdRqMmgmdtTs=";
patches = [
./patches/kube-prometheus-stack.patch
];
} }
rec { rec {
name = "cert-manager"; name = "cert-manager";

View File

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