diff --git a/charts/karmada/templates/_helpers.tpl b/charts/karmada/templates/_helpers.tpl index 9727620d3520..42eab897f328 100644 --- a/charts/karmada/templates/_helpers.tpl +++ b/charts/karmada/templates/_helpers.tpl @@ -62,6 +62,24 @@ app: {{- include "karmada.name" .}}-aggregated-apiserver {{- end }} {{- end -}} +{{- define "karmada.metricsAdapter.labels" -}} +{{- if .Values.metricsAdapter.labels }} +{{- range $key, $value := .Values.metricsAdapter.labels }} +{{ $key }}: {{ $value }} +{{- end }} +{{- else}} +app: {{- include "karmada.name" .}}-metrics-adapter +{{- end }} +{{- end -}} + +{{- define "karmada.metricsAdapter.podLabels" -}} +{{- if .Values.metricsAdapter.podLabels }} +{{- range $key, $value := .Values.metricsAdapter.podLabels }} +{{ $key }}: {{ $value }} +{{- end }} +{{- end }} +{{- end -}} + {{- define "karmada.kube-cm.labels" -}} {{- if .Values.kubeControllerManager.labels }} {{- range $key, $value := .Values.kubeControllerManager.labels }} @@ -422,6 +440,20 @@ Return the proper Docker Image Registry Secret Names {{ include "common.images.pullSecrets" (dict "images" (list .Values.aggregatedApiServer.image) "global" .Values.global) }} {{- end -}} +{{/* +Return the proper karmada metricsAdapter image name +*/}} +{{- define "karmada.metricsAdapter.image" -}} +{{ include "common.images.image" (dict "imageRoot" .Values.metricsAdapter.image "global" .Values.global) }} +{{- end -}} + +{{/* +Return the proper Docker Image Registry Secret Names +*/}} +{{- define "karmada.metricsAdapter.imagePullSecrets" -}} +{{ include "common.images.pullSecrets" (dict "images" (list .Values.metricsAdapter.image) "global" .Values.global) }} +{{- end -}} + {{/* Return the proper karmada search image name */}} diff --git a/charts/karmada/templates/_karmada_apiservice.tpl b/charts/karmada/templates/_karmada_apiservice.tpl index baf274e5f142..8b4ba5a7912b 100644 --- a/charts/karmada/templates/_karmada_apiservice.tpl +++ b/charts/karmada/templates/_karmada_apiservice.tpl @@ -28,6 +28,66 @@ metadata: spec: type: ExternalName externalName: {{ $name }}-aggregated-apiserver.{{ include "karmada.namespace" . }}.svc.{{ .Values.clusterDomain }} +--- +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1beta1.metrics.k8s.io + labels: + app: {{ $name }}-metrics-adapter + apiserver: "true" +spec: + {{- include "karmada.apiserver.caBundle" . | nindent 2 }} + group: metrics.k8s.io + groupPriorityMinimum: 100 + service: + name: {{ $name }}-metrics-adapter + namespace: {{ $systemNamespace }} + version: v1beta1 + versionPriority: 200 +--- +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1beta2.custom.metrics.k8s.io + labels: + app: {{ $name }}-metrics-adapter + apiserver: "true" +spec: + {{- include "karmada.apiserver.caBundle" . | nindent 2 }} + group: custom.metrics.k8s.io + groupPriorityMinimum: 100 + service: + name: {{ $name }}-metrics-adapter + namespace: {{ $systemNamespace }} + version: v1beta2 + versionPriority: 200 +--- +apiVersion: apiregistration.k8s.io/v1 +kind: APIService +metadata: + name: v1beta1.custom.metrics.k8s.io + labels: + app: {{ $name }}-metrics-adapter + apiserver: "true" +spec: + {{- include "karmada.apiserver.caBundle" . | nindent 2 }} + group: custom.metrics.k8s.io + groupPriorityMinimum: 100 + service: + name: {{ $name }}-metrics-adapter + namespace: {{ $systemNamespace }} + version: v1beta1 + versionPriority: 200 +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $name }}-metrics-adapter + namespace: {{ $systemNamespace }} +spec: + type: ExternalName + externalName: {{ $name }}-metrics-adapter.{{ include "karmada.namespace" . }}.svc.{{ .Values.clusterDomain }} {{- end }} {{- if has "search" .Values.components }} --- diff --git a/charts/karmada/templates/karmada-metrics-adapter.yaml b/charts/karmada/templates/karmada-metrics-adapter.yaml new file mode 100644 index 000000000000..620779ea12ac --- /dev/null +++ b/charts/karmada/templates/karmada-metrics-adapter.yaml @@ -0,0 +1,119 @@ +{{- if eq .Values.installMode "host" }} +{{- $name := include "karmada.name" . -}} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $name }}-metrics-adapter + namespace: {{ include "karmada.namespace" . }} + labels: + {{- include "karmada.metricsAdapter.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "karmada.metricsAdapter.labels" . | nindent 6 }} + replicas: {{ .Values.metricsAdapter.replicaCount }} + {{- with .Values.metricsAdapter.strategy }} + strategy: + {{- toYaml . | nindent 4 }} + {{- end }} + template: + metadata: + {{- with .Values.metricsAdapter.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "karmada.metricsAdapter.labels" . | nindent 8 }} + {{- include "karmada.metricsAdapter.podLabels" . | nindent 8 }} + spec: + {{- include "karmada.metricsAdapter.imagePullSecrets" . | nindent 6 }} + automountServiceAccountToken: false + containers: + - name: {{ $name }}-aggregated-apiserver + image: {{ template "karmada.metricsAdapter.image" . }} + imagePullPolicy: {{ .Values.metricsAdapter.image.pullPolicy }} + volumeMounts: + {{- include "karmada.kubeconfig.volumeMount" . | nindent 12 }} + - name: apiserver-cert + mountPath: /etc/kubernetes/pki + readOnly: true + command: + - /bin/karmada-metrics-adapter + - --kubeconfig=/etc/kubeconfig + - --authentication-kubeconfig=/etc/kubeconfig + - --authorization-kubeconfig=/etc/kubeconfig + - --tls-cert-file=/etc/kubernetes/pki/karmada.crt + - --tls-private-key-file=/etc/kubernetes/pki/karmada.key + - --audit-log-path=- + - --audit-log-maxage=0 + - --audit-log-maxbackup=0 + - --tls-min-version=VersionTLS13 + resources: + {{- toYaml .Values.metricsAdapter.resources | nindent 12 }} + readinessProbe: + httpGet: + path: /readyz + port: 443 + scheme: HTTPS + initialDelaySeconds: 1 + periodSeconds: 3 + timeoutSeconds: 15 + livenessProbe: + httpGet: + path: /healthz + port: 443 + scheme: HTTPS + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 15 + {{- with .Values.metricsAdapter.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.metricsAdapter.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.metricsAdapter.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + volumes: + {{- include "karmada.kubeconfig.volume" . | nindent 8 }} + - name: apiserver-cert + secret: + secretName: {{ $name }}-cert +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $name }}-metrics-adapter + namespace: {{ include "karmada.namespace" . }} + labels: + {{- include "karmada.metricsAdapter.labels" . | nindent 4 }} +spec: + ports: + - port: 443 + protocol: TCP + targetPort: 443 + selector: + {{- include "karmada.metricsAdapter.labels" . | nindent 4 }} + +{{ if and .Values.metricsAdapter .Values.metricsAdapter.podDisruptionBudget }} +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ $name }}-metrics-adapter + namespace: {{ include "karmada.namespace" . }} + labels: + {{- include "karmada.metricsAdapter.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "karmada.metricsAdapter.labels" . | nindent 6 }} + {{ toYaml .Values.metricsAdapter.podDisruptionBudget | nindent 2 }} +{{- end -}} + +{{- end }} diff --git a/charts/karmada/values.yaml b/charts/karmada/values.yaml index ffd2e42c2f16..0b204c771f1f 100644 --- a/charts/karmada/values.yaml +++ b/charts/karmada/values.yaml @@ -469,6 +469,67 @@ aggregatedApiServer: ## @param apiServer.podDisruptionBudget podDisruptionBudget: *podDisruptionBudget +## karmada metrics adapter config +metricsAdapter: + ## @param metricsAdapter.labels labels of the karmada-metrics-adapter pods + labels: + app: karmada-metrics-adapter + ## @param metricsAadpter.replicaCount target replicas of the karmada-mertics-adapter + replicaCount: 1 + ## @param metricsAadpter.podAnnotations annotations of the karmada-mertics-adapter pods + podAnnotations: {} + ## @param metricsAadpter.podLabels labels of the karmada-mertics-adapter pods + podLabels: {} + ## @param image.registry karmada metricsAadpter image registry + ## @param image.repository karmada metricsAadpter image repository + ## @param image.tag karmada metricsAadpter image tag (immutable tags are recommended) + ## @param image.pullPolicy karmada metricsAadpter image pull policy + ## @param image.pullSecrets Specify docker-registry secret names as an array + ## + image: + registry: docker.io + repository: karmada/karmada-metrics-adapter + tag: *karmadaImageVersion + ## Specify a imagePullPolicy + ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' + ## + pullPolicy: Always + ## Optionally specify an array of imagePullSecrets. + ## Secrets must be manually created in the namespace. + ## Example: + ## pullSecrets: + ## - myRegistryKeySecretName + ## + pullSecrets: [] + ## @param metricsAadpter.resources resource quota of the karmada-mertics-adapter + resources: + requests: + cpu: 100m + # If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + ## @param metricsAadpter.nodeSelector node selector of the karmada-mertics-adapter + nodeSelector: {} + ## @param metricsAadpter.affinity affinity of the karmada-mertics-adapter + affinity: {} + ## @param metricsAadpter.tolerations tolerations of the karmada-mertics-adapter + tolerations: [] + # - key: node-role.kubernetes.io/master + # operator: Exists + ## @param metricsAadpter.strategy strategy of the karmada-mertics-adapter + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 0 + maxSurge: 50% + ## @param apiServer.podDisruptionBudget + podDisruptionBudget: *podDisruptionBudget + ## kubernetes controller manager config kubeControllerManager: ## @param kubeControllerManager.labels labels of the kube-controller-manager deployment