Skip to content

Commit

Permalink
feat: Add additional labels to the kubernetes resources (#218)
Browse files Browse the repository at this point in the history
* feat(operator): add missing labels

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(operator): Kubernetes recommended labels

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(standalone): Kubernetes recommended labels

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(cluster): Kubernetes recommended labels

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(cluster): new file

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(helm): naming

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(helm): additional labels

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(helm): bump charts versions

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* feat(helm): documentation

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* fix(helm): documentation

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

* fix(helm): use root variable

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>

---------

Signed-off-by: Nicolas Lamirault <nicolas.lamirault@gmail.com>
  • Loading branch information
nlamirault authored Jan 21, 2025
1 parent 9781241 commit 0328d1f
Show file tree
Hide file tree
Showing 30 changed files with 132 additions and 8 deletions.
2 changes: 1 addition & 1 deletion charts/greptimedb-cluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: greptimedb-cluster
description: A Helm chart for deploying GreptimeDB cluster in Kubernetes.
type: application
version: 0.2.44
version: 0.2.45
appVersion: 0.11.2
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
3 changes: 2 additions & 1 deletion charts/greptimedb-cluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for deploying GreptimeDB cluster in Kubernetes.

![Version: 0.2.44](https://img.shields.io/badge/Version-0.2.44-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.11.2](https://img.shields.io/badge/AppVersion-0.11.2-informational?style=flat-square)
![Version: 0.2.45](https://img.shields.io/badge/Version-0.2.45-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.11.2](https://img.shields.io/badge/AppVersion-0.11.2-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -80,6 +80,7 @@ helm uninstall mycluster -n default

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalLabels | object | `{}` | additional labels to add to all resources |
| auth | object | `{"enabled":false,"fileName":"passwd","mountPath":"/etc/greptimedb/auth","users":[{"password":"admin","username":"admin"}]}` | The static auth for greptimedb, only support one user now(https://docs.greptime.com/user-guide/deployments/authentication/static). |
| auth.enabled | bool | `false` | Enable static auth |
| auth.fileName | string | `"passwd"` | The auth file name, the full path is `${mountPath}/${fileName}` |
Expand Down
68 changes: 68 additions & 0 deletions charts/greptimedb-cluster/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "greptimedb-cluster.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "greptimedb-cluster.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "greptimedb-cluster.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "greptimedb-cluster.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

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

{{/*
Common labels
*/}}
{{- define "greptimedb-cluster.labels" -}}
helm.sh/chart: {{ include "greptimedb-cluster.chart" . }}
{{ include "greptimedb-cluster.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: cluster
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: greptimedb-cluster
{{- with .Values.additionalLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "greptimedb-cluster.selectorLabels" -}}
app.kubernetes.io/name: {{ include "greptimedb-cluster.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/greptimedb-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: GreptimeDBCluster
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
spec:
base:
main:
Expand Down
1 change: 1 addition & 0 deletions charts/greptimedb-cluster/templates/debug-depoyment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ metadata:
name: {{ .Release.Name }}-debug-pod
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
app: {{ .Release.Name }}-debug-pod
spec:
replicas: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ kind: ConfigMap
metadata:
name: {{ $value }}
namespace: {{ $root.Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" $root | nindent 4 }}
data:
{{ $key }}.json: |-
{{ $root.Files.Get (printf "dashboards/%s.json" $key) | indent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-cluster/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ apiVersion: v1
metadata:
name: {{ default "storage-credentials" .Values.objectStorage.credentials.secretName }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
kind: Secret
type: Opaque
{{- if .Values.objectStorage.credentials.serviceAccountKey }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-datanode
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
{{- with .Values.datanode.podTemplate.serviceAccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-flownode
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
{{- with .Values.flownode.podTemplate.serviceAccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-frontend
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
{{- with .Values.frontend.podTemplate.serviceAccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-cluster/templates/serviceaccount-meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-meta
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
{{- with .Values.meta.podTemplate.serviceAccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-cluster/templates/users-auth-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Secret
metadata:
name: {{ .Release.Name }}-users-auth
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-cluster.labels" . | nindent 4 }}
type: Opaque
stringData:
{{ .Values.auth.fileName }}: |
Expand Down
3 changes: 3 additions & 0 deletions charts/greptimedb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ image:
# -- The image pull secrets
pullSecrets: []

# -- additional labels to add to all resources
additionalLabels: {}

initializer:
# -- Initializer image registry
registry: docker.io
Expand Down
2 changes: 1 addition & 1 deletion charts/greptimedb-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kubeVersion: ">=1.18.0-0"
description: The greptimedb-operator Helm chart for Kubernetes.
name: greptimedb-operator
appVersion: 0.1.4-alpha.3
version: 0.2.15
version: 0.2.16
type: application
home: https://github.com/GreptimeTeam/greptimedb-operator
sources:
Expand Down
3 changes: 2 additions & 1 deletion charts/greptimedb-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The greptimedb-operator Helm chart for Kubernetes.

![Version: 0.2.15](https://img.shields.io/badge/Version-0.2.15-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.4-alpha.3](https://img.shields.io/badge/AppVersion-0.1.4--alpha.3-informational?style=flat-square)
![Version: 0.2.16](https://img.shields.io/badge/Version-0.2.16-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.1.4-alpha.3](https://img.shields.io/badge/AppVersion-0.1.4--alpha.3-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -100,6 +100,7 @@ Kubernetes: `>=1.18.0-0`

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalLabels | object | `{}` | additional labels to add to all resources |
| affinity | object | `{}` | The pod affinity |
| apiServer | object | `{"enabled":false,"podMetrics":{"enabled":false},"port":8081}` | The configuration for the operator API server |
| apiServer.enabled | bool | `false` | Whether to enable the API server |
Expand Down
5 changes: 5 additions & 0 deletions charts/greptimedb-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ helm.sh/chart: {{ include "greptimedb-operator.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: operator
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: greptimedb-operator
{{- with .Values.additionalLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ include "greptimedb-operator.fullname" . }}-role
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
rules:
- apiGroups:
- apiextensions.k8s.io
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ include "greptimedb-operator.fullname" . }}-rolebinding
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Role
metadata:
name: {{ include "greptimedb-operator.fullname" . }}-leader-election-role
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
rules:
- apiGroups:
- ''
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: RoleBinding
metadata:
name: {{ include "greptimedb-operator.fullname" . }}-leader-election-rolebinding
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Service
metadata:
name: {{ include "greptimedb-operator.fullname" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
spec:
type: ClusterIP
selector:
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-operator/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ kind: ServiceAccount
metadata:
name: {{ include "greptimedb-operator.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-operator.labels" . | nindent 4 }}
{{- end }}
3 changes: 3 additions & 0 deletions charts/greptimedb-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ image:
# -- The image pull secrets
pullSecrets: []

# -- additional labels to add to all resources
additionalLabels: {}

serviceAccount:
# -- Specifies whether a service account should be created
create: true
Expand Down
2 changes: 1 addition & 1 deletion charts/greptimedb-standalone/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: greptimedb-standalone
description: A Helm chart for deploying standalone greptimedb
type: application
version: 0.1.39
version: 0.1.40
appVersion: 0.11.2
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
3 changes: 2 additions & 1 deletion charts/greptimedb-standalone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A Helm chart for deploying standalone greptimedb

![Version: 0.1.39](https://img.shields.io/badge/Version-0.1.39-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.11.2](https://img.shields.io/badge/AppVersion-0.11.2-informational?style=flat-square)
![Version: 0.1.40](https://img.shields.io/badge/Version-0.1.40-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.11.2](https://img.shields.io/badge/AppVersion-0.11.2-informational?style=flat-square)

## Source Code
- https://github.com/GreptimeTeam/greptimedb
Expand Down Expand Up @@ -50,6 +50,7 @@ helm uninstall greptimedb-standalone -n default

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| additionalLabels | object | `{}` | additional labels to add to all resources |
| affinity | object | `{}` | Affinity configuration for pod |
| annotations | object | `{}` | The annotations |
| args | list | `[]` | The container args |
Expand Down
5 changes: 5 additions & 0 deletions charts/greptimedb-standalone/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ helm.sh/chart: {{ include "greptimedb-standalone.chart" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/component: standalone
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/part-of: greptimedb-standalone
{{- with .Values.additionalLabels }}
{{ toYaml . }}
{{- end }}
{{- end }}

{{/*
Expand Down
5 changes: 3 additions & 2 deletions charts/greptimedb-standalone/templates/podmonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ kind: PodMonitor
metadata:
name: {{ include "greptimedb-standalone.fullname" . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.monitoring.labels }}
labels:
{{- include "greptimedb-standalone.labels" . | nindent 4 }}
{{- with .Values.monitoring.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- with .Values.monitoring.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-standalone/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ apiVersion: v1
metadata:
name: {{ include "greptimedb-standalone.fullname" . }}-secret
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-standalone.labels" . | nindent 4 }}
kind: Secret
type: Opaque
{{- if .Values.objectStorage.credentials.serviceAccountKey }}
Expand Down
2 changes: 2 additions & 0 deletions charts/greptimedb-standalone/templates/users-auth-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ kind: Secret
metadata:
name: {{ include "greptimedb-standalone.fullname" . }}-users-auth
namespace: {{ .Release.Namespace }}
labels:
{{- include "greptimedb-standalone.labels" . | nindent 4 }}
type: Opaque
stringData:
{{ .Values.auth.fileName }}: |
Expand Down
3 changes: 3 additions & 0 deletions charts/greptimedb-standalone/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ nameOverride: ""
# -- Provide a name to substitute for the full names of resources
fullnameOverride: ""

# -- additional labels to add to all resources
additionalLabels: {}

serviceAccount:
# -- Specifies whether a service account should be created
create: true
Expand Down

0 comments on commit 0328d1f

Please sign in to comment.