From 4b4bf42ded4278b2c472c8ba504f480a4b1c6ff1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fl=C3=A1vio=20Ramalho?= <framalho@suse.com>
Date: Thu, 12 Nov 2020 11:36:21 +0100
Subject: [PATCH] Configure notary deployments at server/signer level
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This change moves the `podAnnotations`, `nodeSelector`, `affinity` and
`tolerations` from the notary level to the server and signer level.

This allows configuring those options specifically for the server or
signer deployments instead of using the same configuration for both.

Fixes: #789

Signed-off-by: Flávio Ramalho <framalho@suse.com>
---
 templates/notary/notary-server.yaml | 10 +++++-----
 templates/notary/notary-signer.yaml |  9 ++++++---
 values.yaml                         | 15 ++++++++++-----
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/templates/notary/notary-server.yaml b/templates/notary/notary-server.yaml
index a5bbf8a..1991bcb 100644
--- a/templates/notary/notary-server.yaml
+++ b/templates/notary/notary-server.yaml
@@ -21,8 +21,8 @@ spec:
         checksum/secret: {{ include (print $.Template.BasePath "/notary/notary-secret.yaml") . | sha256sum }}
         checksum/secret-core: {{ include (print $.Template.BasePath "/core/core-secret.yaml") . | sha256sum }}
         checksum/secret-database: {{ include (print $.Template.BasePath "/database/database-secret.yaml") . | sha256sum }}
-{{- if .Values.notary.podAnnotations }}
-{{ toYaml .Values.notary.podAnnotations | indent 8 }}
+{{- if .Values.notary.server.podAnnotations }}
+{{ toYaml .Values.notary.server.podAnnotations | indent 8 }}
 {{- end }}
     spec:
       securityContext:
@@ -104,15 +104,15 @@ spec:
           {{- else }}
           secretName: {{ template "harbor.notary-server" . }}
           {{- end }}
-    {{- with .Values.notary.nodeSelector }}
+    {{- with .Values.notary.server.nodeSelector }}
       nodeSelector:
 {{ toYaml . | indent 8 }}
     {{- end }}
-    {{- with .Values.notary.affinity }}
+    {{- with .Values.notary.server.affinity }}
       affinity:
 {{ toYaml . | indent 8 }}
     {{- end }}
-    {{- with .Values.notary.tolerations }}
+    {{- with .Values.notary.server.tolerations }}
       tolerations:
 {{ toYaml . | indent 8 }}
     {{- end }}
diff --git a/templates/notary/notary-signer.yaml b/templates/notary/notary-signer.yaml
index 8799582..20035ed 100644
--- a/templates/notary/notary-signer.yaml
+++ b/templates/notary/notary-signer.yaml
@@ -20,6 +20,9 @@ spec:
       annotations:
         checksum/secret: {{ include (print $.Template.BasePath "/notary/notary-secret.yaml") . | sha256sum }}
         checksum/secret-database: {{ include (print $.Template.BasePath "/database/database-secret.yaml") . | sha256sum }}
+{{- if .Values.notary.signer.podAnnotations }}
+{{ toYaml .Values.notary.signer.podAnnotations | indent 8 }}
+{{- end }}
     spec:
       securityContext:
         fsGroup: 10000
@@ -95,15 +98,15 @@ spec:
           {{- else }}
           secretName: {{ template "harbor.notary-server" . }}
           {{- end }}
-    {{- with .Values.notary.nodeSelector }}
+    {{- with .Values.notary.signer.nodeSelector }}
       nodeSelector:
 {{ toYaml . | indent 8 }}
     {{- end }}
-    {{- with .Values.notary.affinity }}
+    {{- with .Values.notary.signer.affinity }}
       affinity:
 {{ toYaml . | indent 8 }}
     {{- end }}
-    {{- with .Values.notary.tolerations }}
+    {{- with .Values.notary.signer.tolerations }}
       tolerations:
 {{ toYaml . | indent 8 }}
     {{- end }}
diff --git a/values.yaml b/values.yaml
index b30e162..8ae152a 100644
--- a/values.yaml
+++ b/values.yaml
@@ -649,6 +649,11 @@ notary:
     #  requests:
     #    memory: 256Mi
     #    cpu: 100m
+    nodeSelector: {}
+    tolerations: []
+    affinity: {}
+    ## Additional deployment annotations
+    podAnnotations: {}
   signer:
     # set the service account to be used, default if left empty
     serviceAccountName: ""
@@ -660,11 +665,11 @@ notary:
     #  requests:
     #    memory: 256Mi
     #    cpu: 100m
-  nodeSelector: {}
-  tolerations: []
-  affinity: {}
-  ## Additional deployment annotations
-  podAnnotations: {}
+    nodeSelector: {}
+    tolerations: []
+    affinity: {}
+    ## Additional deployment annotations
+    podAnnotations: {}
   # Fill the name of a kubernetes secret if you want to use your own
   # TLS certificate authority, certificate and private key for notary
   # communications.
-- 
2.24.3 (Apple Git-128)

