Skip to content

Commit

Permalink
make estimator config in helm values as a list
Browse files Browse the repository at this point in the history
Signed-off-by: chaosi-zju <chaosi@zju.edu.cn>
  • Loading branch information
chaosi-zju committed Dec 6, 2023
1 parent 01b086d commit 3da3df7
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 61 deletions.
34 changes: 18 additions & 16 deletions charts/karmada/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,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)
Expand Down
49 changes: 27 additions & 22 deletions charts/karmada/templates/karmada-scheduler-estimator.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -73,7 +76,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
Expand All @@ -90,14 +93,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:
Expand All @@ -106,22 +109,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 }}
48 changes: 25 additions & 23 deletions charts/karmada/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -740,32 +740,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
Expand Down

0 comments on commit 3da3df7

Please sign in to comment.