From f715b5c5583da232f818f4bce7f68a46f1de9f1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernard=20G=C3=BCtermann?= Date: Sat, 21 Sep 2024 20:29:05 +0200 Subject: [PATCH] fix existing media pvc issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bernard Gütermann --- README.md | 3 +++ .../templates/sharedStorage.pvc.yaml | 2 ++ helm-adopt.sh | 14 ++++++++++++++ 3 files changed, 19 insertions(+) create mode 100755 helm-adopt.sh diff --git a/README.md b/README.md index d6b0889..65ab41d 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,9 @@ transmission: See the chart [values.yaml](charts/k8s-mediamanager/values.yaml) for more details on available parameters. +If you already have pre-existing volumes you can patch them using the `helm-adopt.sh` script to avoid having the +`error : resources already exist` issue when running the install script + ## Usage Upon deploying the chart with the command above the following endpoints will become available externally: diff --git a/charts/k8s-mediamanager/templates/sharedStorage.pvc.yaml b/charts/k8s-mediamanager/templates/sharedStorage.pvc.yaml index c5ad778..a067c66 100644 --- a/charts/k8s-mediamanager/templates/sharedStorage.pvc.yaml +++ b/charts/k8s-mediamanager/templates/sharedStorage.pvc.yaml @@ -1,4 +1,5 @@ {{- with .Values.general.sharedStorage }} +{{- if not (lookup "v1" "persistentVolumeClaim" "" .persistentVolumeClaim.claimName) }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -22,4 +23,5 @@ spec: selector: {{- toYaml . | nindent 4 }} {{- end }} +{{- end }} {{- end }} \ No newline at end of file diff --git a/helm-adopt.sh b/helm-adopt.sh new file mode 100755 index 0000000..6311cfc --- /dev/null +++ b/helm-adopt.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +# This script is used to adopt pre-existing pvcs into a Helm release. It is used in the +# following way: +# helm-adpot.sh + +[ "$#" -eq 2 ] || { echo "Usage: $0 "; exit 1; } + +NAMESPACE=$1 +RELEASE_NAME=$2 +kubectl get -n $NAMESPACE pvc -o name | xargs -I % kubectl label -n $NAMESPACE % app.kubernetes.io/managed-by=Helm +kubectl get -n $NAMESPACE pvc -o name | xargs -I % kubectl annotate -n $NAMESPACE % meta.helm.sh/release-name=$RELEASE_NAME +kubectl get -n $NAMESPACE pvc -o name | xargs -I % kubectl annotate -n $NAMESPACE % meta.helm.sh/release-namespace=$NAMESPACE +kubectl get -n $NAMESPACE pvc -o name | xargs -I % kubectl annotate -n $NAMESPACE % helm.sh/resource-policy=keep