From d09f0d43f3a2dd869d4f8591f905610c277633f9 Mon Sep 17 00:00:00 2001 From: takuya <49614391+takuyaymd@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:06:50 +0900 Subject: [PATCH] Add affinity to jobTemplate (#2758) --- .../vald-helm-operator/crds/valdrelease.yaml | 159 +++++++++++++++ charts/vald/templates/_helpers.tpl | 12 ++ charts/vald/values.schema.json | 192 ++++++++++++++++++ charts/vald/values.yaml | 72 +++++++ 4 files changed, 435 insertions(+) diff --git a/charts/vald-helm-operator/crds/valdrelease.yaml b/charts/vald-helm-operator/crds/valdrelease.yaml index 7c1ed31966..e91608a6a5 100644 --- a/charts/vald-helm-operator/crds/valdrelease.yaml +++ b/charts/vald-helm-operator/crds/valdrelease.yaml @@ -8406,6 +8406,51 @@ spec: corrector: type: object properties: + affinity: + type: object + properties: + nodeAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: object + properties: + nodeSelectorTerms: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAntiAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true agent_namespace: type: string discoverer: @@ -9037,6 +9082,9 @@ spec: type: string node_name: type: string + nodeSelector: + type: object + x-kubernetes-preserve-unknown-fields: true observability: type: object properties: @@ -9714,6 +9762,11 @@ spec: minimum: 1 suspend: type: boolean + tolerations: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true ttlSecondsAfterFinished: type: integer version: @@ -9722,6 +9775,51 @@ spec: creator: type: object properties: + affinity: + type: object + properties: + nodeAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: object + properties: + nodeSelectorTerms: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAntiAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true agent_namespace: type: string concurrency: @@ -10157,6 +10255,9 @@ spec: type: string node_name: type: string + nodeSelector: + type: object + x-kubernetes-preserve-unknown-fields: true observability: type: object properties: @@ -10835,6 +10936,11 @@ spec: type: array items: type: string + tolerations: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true ttlSecondsAfterFinished: type: integer version: @@ -13012,6 +13118,51 @@ spec: saver: type: object properties: + affinity: + type: object + properties: + nodeAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: object + properties: + nodeSelectorTerms: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + podAntiAffinity: + type: object + properties: + preferredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true + requiredDuringSchedulingIgnoredDuringExecution: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true agent_namespace: type: string concurrency: @@ -13445,6 +13596,9 @@ spec: type: string node_name: type: string + nodeSelector: + type: object + x-kubernetes-preserve-unknown-fields: true observability: type: object properties: @@ -14123,6 +14277,11 @@ spec: type: array items: type: string + tolerations: + type: array + items: + type: object + x-kubernetes-preserve-unknown-fields: true ttlSecondsAfterFinished: type: integer version: diff --git a/charts/vald/templates/_helpers.tpl b/charts/vald/templates/_helpers.tpl index 6de2c34bb5..11730a90ab 100644 --- a/charts/vald/templates/_helpers.tpl +++ b/charts/vald/templates/_helpers.tpl @@ -896,6 +896,10 @@ spec: {{- toYaml .Job.securityContext | nindent 12 }} {{- end }} {{- end }} + {{- if .Job.affinity }} + affinity: + {{- include "vald.affinity" .Job.affinity | nindent 8 }} + {{- end }} containers: - name: {{ .Job.name }} image: "{{ .Job.image.repository }}:{{ default .default.Values.defaults.image.tag .Job.image.tag }}" @@ -929,6 +933,14 @@ spec: configMap: defaultMode: 420 name: {{ .Job.name }}-config + {{- if .Job.nodeSelector }} + nodeSelector: + {{- toYaml .Job.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Job.tolerations }} + tolerations: + {{- toYaml .Job.tolerations | nindent 8 }} + {{- end }} {{- if .Job.serviceAccount }} serviceAccountName: {{ .Job.serviceAccount.name }} {{- end }} diff --git a/charts/vald/values.schema.json b/charts/vald/values.schema.json index 2cc13ede59..0e35482a1f 100644 --- a/charts/vald/values.schema.json +++ b/charts/vald/values.schema.json @@ -14071,6 +14071,61 @@ "corrector": { "type": "object", "properties": { + "affinity": { + "type": "object", + "properties": { + "nodeAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "node affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "object", + "properties": { + "nodeSelectorTerms": { + "type": "array", + "description": "node affinity required node selectors", + "items": { "type": "object" } + } + } + } + } + }, + "podAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity required scheduling terms", + "items": { "type": "object" } + } + } + }, + "podAntiAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity required scheduling terms", + "items": { "type": "object" } + } + } + } + } + }, "agent_namespace": { "type": "string", "description": "namespace of agent pods to manage" @@ -15172,6 +15227,10 @@ "type": "string", "description": "name of index correction job" }, + "nodeSelector": { + "type": "object", + "description": "node selector" + }, "node_name": { "type": "string", "description": "node name" }, "observability": { "type": "object", @@ -16390,6 +16449,11 @@ "type": "boolean", "description": "CronJob suspend setting for index correction" }, + "tolerations": { + "type": "array", + "description": "tolerations", + "items": { "type": "object" } + }, "ttlSecondsAfterFinished": { "type": "integer", "description": "ttl setting for K8s completed jobs" @@ -16404,6 +16468,61 @@ "creator": { "type": "object", "properties": { + "affinity": { + "type": "object", + "properties": { + "nodeAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "node affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "object", + "properties": { + "nodeSelectorTerms": { + "type": "array", + "description": "node affinity required node selectors", + "items": { "type": "object" } + } + } + } + } + }, + "podAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity required scheduling terms", + "items": { "type": "object" } + } + } + }, + "podAntiAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity required scheduling terms", + "items": { "type": "object" } + } + } + } + } + }, "agent_namespace": { "type": "string", "description": "namespace of agent pods to manage" @@ -17158,6 +17277,10 @@ "type": "string", "description": "name of index creation job" }, + "nodeSelector": { + "type": "object", + "description": "node selector" + }, "node_name": { "type": "string", "description": "node name" }, "observability": { "type": "object", @@ -18376,6 +18499,11 @@ "description": "indexing target addresses", "items": { "type": "string" } }, + "tolerations": { + "type": "array", + "description": "tolerations", + "items": { "type": "object" } + }, "ttlSecondsAfterFinished": { "type": "integer", "description": "ttl setting for K8s completed jobs" @@ -22115,6 +22243,61 @@ "saver": { "type": "object", "properties": { + "affinity": { + "type": "object", + "properties": { + "nodeAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "node affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "object", + "properties": { + "nodeSelectorTerms": { + "type": "array", + "description": "node affinity required node selectors", + "items": { "type": "object" } + } + } + } + } + }, + "podAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod affinity required scheduling terms", + "items": { "type": "object" } + } + } + }, + "podAntiAffinity": { + "type": "object", + "properties": { + "preferredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity preferred scheduling terms", + "items": { "type": "object" } + }, + "requiredDuringSchedulingIgnoredDuringExecution": { + "type": "array", + "description": "pod anti-affinity required scheduling terms", + "items": { "type": "object" } + } + } + } + } + }, "agent_namespace": { "type": "string", "description": "namespace of agent pods to manage" @@ -22865,6 +23048,10 @@ "type": "string", "description": "name of index save job" }, + "nodeSelector": { + "type": "object", + "description": "node selector" + }, "node_name": { "type": "string", "description": "node name" }, "observability": { "type": "object", @@ -24083,6 +24270,11 @@ "description": "index saving target addresses", "items": { "type": "string" } }, + "tolerations": { + "type": "array", + "description": "tolerations", + "items": { "type": "object" } + }, "ttlSecondsAfterFinished": { "type": "integer", "description": "ttl setting for K8s completed jobs" diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index bf2e16c05c..067e804035 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -3427,6 +3427,30 @@ manager: # @schema {"name": "manager.index.corrector.node_name", "type": "string"} # manager.index.corrector.node_name -- node name node_name: "" # _MY_NODE_NAME_ + # @schema {"name": "manager.index.corrector.nodeSelector", "alias": "nodeSelector"} + # manager.index.corrector.nodeSelector -- node selector + nodeSelector: {} + # @schema {"name": "manager.index.corrector.tolerations", "alias": "tolerations"} + # manager.index.corrector.tolerations -- tolerations + tolerations: [] + # @schema {"name": "manager.index.corrector.affinity", "alias": "affinity"} + affinity: + nodeAffinity: + # manager.index.corrector.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution -- node affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + requiredDuringSchedulingIgnoredDuringExecution: + # manager.index.corrector.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms -- node affinity required node selectors + nodeSelectorTerms: [] + podAffinity: + # manager.index.corrector.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.corrector.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] + podAntiAffinity: + # manager.index.corrector.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.corrector.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] # @schema {"name": "manager.index.corrector.gateway", "alias": "grpc.client"} # manager.index.corrector.gateway -- gRPC client for gateway (overrides defaults.grpc.client) gateway: {} @@ -3539,6 +3563,30 @@ manager: # @schema {"name": "manager.index.creator.node_name", "type": "string"} # manager.index.creator.node_name -- node name node_name: "" # _MY_NODE_NAME_ + # @schema {"name": "manager.index.creator.nodeSelector", "alias": "nodeSelector"} + # manager.index.creator.nodeSelector -- node selector + nodeSelector: {} + # @schema {"name": "manager.index.creator.tolerations", "alias": "tolerations"} + # manager.index.creator.tolerations -- tolerations + tolerations: [] + # @schema {"name": "manager.index.creator.affinity", "alias": "affinity"} + affinity: + nodeAffinity: + # manager.index.creator.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution -- node affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + requiredDuringSchedulingIgnoredDuringExecution: + # manager.index.creator.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms -- node affinity required node selectors + nodeSelectorTerms: [] + podAffinity: + # manager.index.creator.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.creator.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] + podAntiAffinity: + # manager.index.creator.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.creator.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] # @schema {"name": "manager.index.creator.discoverer", "type": "object"} discoverer: # @schema {"name": "manager.index.creator.discoverer.duration", "type": "string"} @@ -3645,6 +3693,30 @@ manager: # @schema {"name": "manager.index.saver.node_name", "type": "string"} # manager.index.saver.node_name -- node name node_name: "" # _MY_NODE_NAME_ + # @schema {"name": "manager.index.saver.nodeSelector", "alias": "nodeSelector"} + # manager.index.saver.nodeSelector -- node selector + nodeSelector: {} + # @schema {"name": "manager.index.saver.tolerations", "alias": "tolerations"} + # manager.index.saver.tolerations -- tolerations + tolerations: [] + # @schema {"name": "manager.index.saver.affinity", "alias": "affinity"} + affinity: + nodeAffinity: + # manager.index.saver.affinity.nodeAffinity.preferredDuringSchedulingIgnoredDuringExecution -- node affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + requiredDuringSchedulingIgnoredDuringExecution: + # manager.index.saver.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms -- node affinity required node selectors + nodeSelectorTerms: [] + podAffinity: + # manager.index.saver.affinity.podAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.saver.affinity.podAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] + podAntiAffinity: + # manager.index.saver.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity preferred scheduling terms + preferredDuringSchedulingIgnoredDuringExecution: [] + # manager.index.saver.affinity.podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecution -- pod anti-affinity required scheduling terms + requiredDuringSchedulingIgnoredDuringExecution: [] # @schema {"name": "manager.index.saver.discoverer", "type": "object"} discoverer: # @schema {"name": "manager.index.saver.discoverer.duration", "type": "string"}