From 69a3cedfedb0ec30b5519cfb92677ed092ea0af1 Mon Sep 17 00:00:00 2001 From: chaosi-zju Date: Fri, 1 Dec 2023 18:06:29 +0800 Subject: [PATCH] make estimator config in helm values as a list Signed-off-by: chaosi-zju --- charts/karmada/README.md | 34 +++++++------ .../karmada-scheduler-estimator.yaml | 51 ++++++++++--------- charts/karmada/values.yaml | 48 ++++++++--------- 3 files changed, 71 insertions(+), 62 deletions(-) diff --git a/charts/karmada/README.md b/charts/karmada/README.md index 075cc614d9c1..b3c5589ed7d4 100644 --- a/charts/karmada/README.md +++ b/charts/karmada/README.md @@ -159,22 +159,24 @@ components: [ "schedulerEstimator" ] schedulerEstimator: - clusterName: "member" - ## kubeconfig of the member cluster - kubeconfig: - caCrt: | - -----BEGIN CERTIFICATE----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END CERTIFICATE----- - crt: | - -----BEGIN CERTIFICATE----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END CERTIFICATE----- - key: | - -----BEGIN RSA PRIVATE KEY----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END RSA PRIVATE KEY----- - server: "https://apiserver.member" + memberClusters: + - clusterName: "member" + replicaCount: 1 + ## kubeconfig of the member cluster + kubeconfig: + caCrt: | + -----BEGIN CERTIFICATE----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END CERTIFICATE----- + crt: | + -----BEGIN CERTIFICATE----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END CERTIFICATE----- + key: | + -----BEGIN RSA PRIVATE KEY----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END RSA PRIVATE KEY----- + server: "https://apiserver.member" ``` Execute command (switch to the `root` directory of the repo, and sets the `current-context` in a kubeconfig file) diff --git a/charts/karmada/templates/karmada-scheduler-estimator.yaml b/charts/karmada/templates/karmada-scheduler-estimator.yaml index 5521fe8a5f70..4e9dd3117fb5 100644 --- a/charts/karmada/templates/karmada-scheduler-estimator.yaml +++ b/charts/karmada/templates/karmada-scheduler-estimator.yaml @@ -1,6 +1,9 @@ {{- if and (or (eq .Values.installMode "component") (eq .Values.installMode "host")) (has "schedulerEstimator" .Values.components) }} + {{ $namespace := include "karmada.namespace" .}} -{{ $clusterName := .Values.schedulerEstimator.clusterName }} +{{- range $index, $member := .Values.schedulerEstimator.memberClusters }} + +{{ $clusterName := $member.clusterName }} --- apiVersion: apps/v1 kind: Deployment @@ -9,38 +12,38 @@ metadata: namespace: {{ $namespace }} labels: cluster: {{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 4 }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 4 }} spec: - replicas: {{ .Values.schedulerEstimator.replicaCount }} + replicas: {{ $member.replicaCount }} selector: matchLabels: app: karmada-scheduler-estimator-{{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 6 }} - {{- with .Values.schedulerEstimator.strategy }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 6 }} + {{- with $.Values.schedulerEstimator.strategy }} strategy: {{- toYaml . | nindent 4 }} {{- end }} template: metadata: - {{- with .Values.schedulerEstimator.podAnnotations }} + {{- with $.Values.schedulerEstimator.podAnnotations }} annotations: {{- toYaml . | nindent 8 }} {{- end }} labels: app: karmada-scheduler-estimator-{{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 8 }} - {{- include "karmada.schedulerEstimator.podLabels" . | nindent 8 }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 8 }} + {{- include "karmada.schedulerEstimator.podLabels" $ | nindent 8 }} spec: - {{- include "karmada.schedulerEstimator.imagePullSecrets" . | nindent 6 }} - {{- with .Values.schedulerEstimator.tolerations }} + {{- include "karmada.schedulerEstimator.imagePullSecrets" $ | nindent 6 }} + {{- with $.Values.schedulerEstimator.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} automountServiceAccountToken: false containers: - name: karmada-scheduler-estimator - image: {{ template "karmada.schedulerEstimator.image" . }} - imagePullPolicy: {{ .Values.schedulerEstimator.image.pullPolicy }} + image: {{ template "karmada.schedulerEstimator.image" $ }} + imagePullPolicy: {{ $.Values.schedulerEstimator.image.pullPolicy }} command: - /bin/karmada-scheduler-estimator - --kubeconfig=/etc/{{ $clusterName }}-kubeconfig @@ -59,7 +62,7 @@ spec: subPath: {{ $clusterName }}-kubeconfig mountPath: /etc/{{ $clusterName }}-kubeconfig resources: - {{- toYaml .Values.schedulerEstimator.resources | nindent 12 }} + {{- toYaml $.Values.schedulerEstimator.resources | nindent 12 }} volumes: - name: member-kubeconfig secret: @@ -75,7 +78,7 @@ metadata: spec: selector: app: karmada-scheduler-estimator-{{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 4 }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 4 }} ports: - protocol: TCP port: 10352 @@ -92,14 +95,14 @@ stringData: kind: Config clusters: - cluster: - certificate-authority-data: {{ b64enc .Values.schedulerEstimator.kubeconfig.caCrt }} + certificate-authority-data: {{ b64enc $member.kubeconfig.caCrt }} insecure-skip-tls-verify: false - server: {{ .Values.schedulerEstimator.kubeconfig.server }} + server: {{ $member.kubeconfig.server }} name: {{ $clusterName }}-apiserver users: - user: - client-certificate-data: {{ b64enc .Values.schedulerEstimator.kubeconfig.crt }} - client-key-data: {{ b64enc .Values.schedulerEstimator.kubeconfig.key }} + client-certificate-data: {{ b64enc $member.kubeconfig.crt }} + client-key-data: {{ b64enc $member.kubeconfig.key }} name: {{ $clusterName }}-apiserver contexts: - context: @@ -108,22 +111,24 @@ stringData: name: {{ $clusterName }}-apiserver current-context: {{ $clusterName }}-apiserver -{{ if .Values.schedulerEstimator.podDisruptionBudget }} +{{ if $.Values.schedulerEstimator.podDisruptionBudget }} --- apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: karmada-scheduler-estimator-{{ $clusterName }} - namespace: {{ include "karmada.namespace" . }} + namespace: {{ include "karmada.namespace" $ }} labels: cluster: {{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 4 }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 4 }} spec: selector: matchLabels: app: karmada-scheduler-estimator-{{ $clusterName }} - {{- include "karmada.schedulerEstimator.labels" . | nindent 6 }} - {{ toYaml .Values.schedulerEstimator.podDisruptionBudget | nindent 2 }} + {{- include "karmada.schedulerEstimator.labels" $ | nindent 6 }} + {{ toYaml $.Values.schedulerEstimator.podDisruptionBudget | nindent 2 }} {{- end -}} {{- end }} + +{{- end }} diff --git a/charts/karmada/values.yaml b/charts/karmada/values.yaml index 0e1480472810..13a8b5c67942 100644 --- a/charts/karmada/values.yaml +++ b/charts/karmada/values.yaml @@ -746,32 +746,34 @@ agent: ## karmada scheduler estimator schedulerEstimator: - ## schedulerEstimator.clusterName the name of the member cluster - clusterName: "" - ## kubeconfig of the member cluster - kubeconfig: - ## @param schedulerEstimator.kubeconfig.caCrt ca of the certificate - caCrt: | - -----BEGIN CERTIFICATE----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END CERTIFICATE----- - ## @param schedulerEstimator.kubeconfig.crt crt of the certificate - crt: | - -----BEGIN CERTIFICATE----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END CERTIFICATE----- - ## @param schedulerEstimator.kubeconfig.key key of the certificate - key: | - -----BEGIN RSA PRIVATE KEY----- - XXXXXXXXXXXXXXXXXXXXXXXXXXX - -----END RSA PRIVATE KEY----- - ## @param schedulerEstimator.kubeconfig.server apiserver of the member cluster - server: "" + ## @param schedulerEstimator.memberClusters each cluster requires an estimator component, fill in the information for each cluster + memberClusters: + ## @param schedulerEstimator.memberClusterInfo[0].clusterName the name of the member cluster + - clusterName: "" + ## @param schedulerEstimator.memberClusterInfo[0].replicaCount target replicas + replicaCount: 1 + ## kubeconfig of the member cluster + kubeconfig: + ## @param schedulerEstimator.memberClusterInfo[0].kubeconfig.server apiserver of the member cluster + server: "" + ## @param schedulerEstimator.memberClusterInfo[0].kubeconfig.caCrt ca of the certificate + caCrt: | + -----BEGIN CERTIFICATE----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END CERTIFICATE----- + ## @param schedulerEstimator.memberClusterInfo[0].kubeconfig.crt crt of the certificate + crt: | + -----BEGIN CERTIFICATE----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END CERTIFICATE----- + ## @param schedulerEstimator.memberClusterInfo[0].kubeconfig.key key of the certificate + key: | + -----BEGIN RSA PRIVATE KEY----- + XXXXXXXXXXXXXXXXXXXXXXXXXXX + -----END RSA PRIVATE KEY----- ## @param schedulerEstimator.labels labels of the scheduler-estimator deployment labels: app: karmada-scheduler-estimator - ## @param schedulerEstimator.replicaCount target replicas - replicaCount: 1 ## @param schedulerEstimator.podAnnotations annotations of the scheduler-estimator pods podAnnotations: {} ## @param schedulerEstimator.podLabels labels of the scheduler-estimator pods