Skip to content

Commit

Permalink
chore: adjust mo-ob-opensource/sa/mo-ob-opensource-kube-state-metrics…
Browse files Browse the repository at this point in the history
… creation (#26)

## What type of PR is this?

* [ ] Feature
* [x] BUG
* [ ] Alerts
* [ ] Improvement
* [ ] Documentation
* [ ] Test and CI

## Which issue(s) this PR related:

issue #matrixorigin/MO-Cloud#4464

prepare pr: #25

## What this PR does / why we need it:
解决 mo-ob-opensource 1.0.8 新建 serviceaccount.yaml 的适配问题
  • Loading branch information
xzxiong authored Dec 19, 2024
1 parent 7ef27ac commit 178eea1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
57 changes: 57 additions & 0 deletions charts/mo-ob-opensource/templates/_helpers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "mo-ob-opensource.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts
*/}}
{{- define "mo-ob-opensource.namespace" -}}
{{- if .Values.namespaceOverride -}}
{{- .Values.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "mo-ob-opensource.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Generate basic labels
*/}}
{{- define "mo-ob-opensource.labels" }}
helm.sh/chart: {{ template "mo-ob-opensource.chart" . }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/component: metrics
app.kubernetes.io/part-of: {{ template "mo-ob-opensource.name" . }}
{{- include "mo-ob-opensource.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
{{- if .Values.customLabels }}
{{ toYaml .Values.customLabels }}
{{- end }}
{{- if .Values.releaseLabel }}
release: {{ .Release.Name }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "mo-ob-opensource.selectorLabels" }}
{{- if .Values.selectorOverride }}
{{ toYaml .Values.selectorOverride }}
{{- else }}
app.kubernetes.io/name: {{ include "mo-ob-opensource.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{- end }}
6 changes: 4 additions & 2 deletions charts/mo-ob-opensource/templates/kube-state-metrics-sa.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{{- if not .Values.serviceAccount.kubeStateMetrics.create -}}
{{- if .Values.serviceAccount.kubeStateMetrics.handle -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ default "mo-ob-opensource-kube-state-metrics" .Values.serviceAccount.kubeStateMetrics.name }}
namespace: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "mo-ob-opensource.labels" . | indent 4 }}
{{- end -}}
7 changes: 7 additions & 0 deletions charts/mo-ob-opensource/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ defaultDatasource:
# cooperate with template templates/loki-datasource.yaml
loki: true

## common
nameOverride: ""
namespaceOverride: ""
selectorOverride: {}
customLabels: []
releaseLabel: []

# alloy for k8s events
alloy:
image:
Expand Down

0 comments on commit 178eea1

Please sign in to comment.