From 7571b2aa9e1b2e5cb943c55a781ea01995c3ef6a Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Tue, 2 Jul 2024 12:14:15 +0200 Subject: [PATCH] no message --- .../lib/dependencies/_volsyncDirectWait.tpl | 22 +++++++++++++++++++ library/common/templates/spawner/_pvc.tpl | 2 ++ 2 files changed, 24 insertions(+) diff --git a/library/common/templates/lib/dependencies/_volsyncDirectWait.tpl b/library/common/templates/lib/dependencies/_volsyncDirectWait.tpl index 66384663..4f919d47 100644 --- a/library/common/templates/lib/dependencies/_volsyncDirectWait.tpl +++ b/library/common/templates/lib/dependencies/_volsyncDirectWait.tpl @@ -63,6 +63,7 @@ command: {{ end }} {{ end }} enabled: true +allServiceAccounts: true primary: {{ $primarypresent }} clusterWide: false rules: @@ -76,6 +77,26 @@ rules: - watch {{- end -}} +{{- define "tc.v1.common.dependencies.volsync.primarywaitsa" -}} +enabled: true +primary: true +{{ end }} + +{{- define "tc.v1.common.dependencies.volsync.primarywaitsa.inject" -}} +{{ $primarypresent := false }} +{{- range .values.rbac -}} + {{ if and .enabled .primary }} + {{ $primarypresent = true }} + {{ end }} +{{- if not $primarypresent -}} +{{- $sa := include "tc.v1.common.dependencies.volsync.directwait" $ | fromYaml -}} +{{- $_ := set .Values.serviceAccount "main" $sa -}} +{{ end }} +{{- end -}} + +{{- define "tc.v1.common.dependencies.volsync.waitonlysa" -}} +{{/* TODO: if there are pods without SA, implement an SA anyway */}} +{{- end -}} {{- define "tc.v1.common.lib.deps.volsync.wait" -}} {{- $volSyncDetect := false -}} @@ -113,6 +134,7 @@ rules: {{- $container := include "tc.v1.common.dependencies.volsync.directwait" $ | fromYaml -}} {{- if $container -}} {{- range .Values.workload -}} + {{ $_ := set .podSpec.automountServiceAccountToken true }} {{- if not (hasKey .podSpec "initContainers") -}} {{- $_ := set .podSpec "initContainers" dict -}} {{- end -}} diff --git a/library/common/templates/spawner/_pvc.tpl b/library/common/templates/spawner/_pvc.tpl index 427c6162..662b5170 100644 --- a/library/common/templates/spawner/_pvc.tpl +++ b/library/common/templates/spawner/_pvc.tpl @@ -134,9 +134,11 @@ {{- include "tc.v1.common.class.replicationdestination" (dict "rootCtx" $ "objectData" $objectData "volsyncData" $volsyncData) -}} {{/* modify PVC if enabled */}} + {{- if eq $volsyncData.copyMethod "Snapshot" -}} {{- $destname := printf "%s-%s-dest" $objectData.name $volsyncData.name -}} {{- $datasourceref := dict "kind" "ReplicationDestination" "apiGroup" "volsync.backube" "name" $destname -}} {{- $_ := set $objectData "dataSourceRef" $datasourceref -}} + {{- end -}} {{- end -}} {{- end -}} {{- end -}}