Skip to content

Commit

Permalink
Merge pull request #4303 from jwcesign/metrics-adaptor-helm
Browse files Browse the repository at this point in the history
feat: support install metrics adapter with chart
  • Loading branch information
karmada-bot authored Nov 24, 2023
2 parents 8047d22 + d86d922 commit cf1dbf0
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 0 deletions.
32 changes: 32 additions & 0 deletions charts/karmada/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
*/}}
Expand Down
60 changes: 60 additions & 0 deletions charts/karmada/templates/_karmada_apiservice.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
---
Expand Down
119 changes: 119 additions & 0 deletions charts/karmada/templates/karmada-metrics-adapter.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
61 changes: 61 additions & 0 deletions charts/karmada/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf1dbf0

Please sign in to comment.