From c61bd2c65eaa7e2bef74efb2dd5bdd4dcba3ebc0 Mon Sep 17 00:00:00 2001 From: liyang Date: Wed, 11 Oct 2023 16:09:19 +0800 Subject: [PATCH] feat: add greptimedb standalone chart --- charts/greptimedb-standalone/.helmignore | 23 +++++ charts/greptimedb-standalone/Chart.yaml | 6 ++ .../templates/_helpers.tpl | 62 +++++++++++++ .../templates/deployment.yaml | 86 +++++++++++++++++++ .../templates/podmonitor.yaml | 18 ++++ .../templates/service.yaml | 31 +++++++ .../templates/serviceaccount.yaml | 13 +++ charts/greptimedb-standalone/values.yaml | 53 ++++++++++++ 8 files changed, 292 insertions(+) create mode 100644 charts/greptimedb-standalone/.helmignore create mode 100644 charts/greptimedb-standalone/Chart.yaml create mode 100644 charts/greptimedb-standalone/templates/_helpers.tpl create mode 100644 charts/greptimedb-standalone/templates/deployment.yaml create mode 100644 charts/greptimedb-standalone/templates/podmonitor.yaml create mode 100644 charts/greptimedb-standalone/templates/service.yaml create mode 100644 charts/greptimedb-standalone/templates/serviceaccount.yaml create mode 100644 charts/greptimedb-standalone/values.yaml diff --git a/charts/greptimedb-standalone/.helmignore b/charts/greptimedb-standalone/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/greptimedb-standalone/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/greptimedb-standalone/Chart.yaml b/charts/greptimedb-standalone/Chart.yaml new file mode 100644 index 0000000..01cbb87 --- /dev/null +++ b/charts/greptimedb-standalone/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: greptimedb +description: A Helm chart for deploying standalone greptimedb. +type: application +version: 0.1.0-alpha.1 +appVersion: 0.4.0 diff --git a/charts/greptimedb-standalone/templates/_helpers.tpl b/charts/greptimedb-standalone/templates/_helpers.tpl new file mode 100644 index 0000000..f2fe3a7 --- /dev/null +++ b/charts/greptimedb-standalone/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "greptimedb-standalone.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-standalone.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 chart name and version as used by the chart label. +*/}} +{{- define "greptimedb-standalone.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "greptimedb-standalone.labels" -}} +helm.sh/chart: {{ include "greptimedb-standalone.chart" . }} +{{ include "greptimedb-standalone.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "greptimedb-standalone.selectorLabels" -}} +app.kubernetes.io/name: {{ include "greptimedb-standalone.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "greptimedb-standalone.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "greptimedb-standalone.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/greptimedb-standalone/templates/deployment.yaml b/charts/greptimedb-standalone/templates/deployment.yaml new file mode 100644 index 0000000..f883cd0 --- /dev/null +++ b/charts/greptimedb-standalone/templates/deployment.yaml @@ -0,0 +1,86 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "greptimedb-standalone.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "greptimedb-standalone.labels" . | nindent 4 }} +spec: + # Always set to 1. + replicas: 1 + selector: + matchLabels: + {{- include "greptimedb-standalone.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "greptimedb-standalone.selectorLabels" . | nindent 8 }} + spec: + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + serviceAccountName: {{ include "greptimedb-standalone.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + volumes: + - name: greptimedb-host-volume + hostPath: + path: /var/greptimedb/standalone-test + type: DirectoryOrCreate + containers: + - name: greptimedb + image: {{ printf "%s/%s:%s" .Values.image.registry .Values.image.repository .Values.image.tag }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.command }} + command: + {{- toYaml . | nindent 10 }} + {{- end }} + {{- with .Values.args }} + args: + {{- toYaml . | nindent 10 }} + {{- end }} + env: + {{- range $key, $val := .Values.env }} + - name: {{ $key }} + value: {{ $val | quote }} + {{- end }} + ports: + - containerPort: 4000 + name: http + protocol: TCP + - containerPort: 4001 + name: grpc + protocol: TCP + - containerPort: 4002 + name: mysql + protocol: TCP + - containerPort: 4003 + name: postgres + protocol: TCP + - containerPort: 4004 + name: prom + protocol: TCP + volumeMounts: + - name: greptimedb-host-volume + mountPath: /data + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/greptimedb-standalone/templates/podmonitor.yaml b/charts/greptimedb-standalone/templates/podmonitor.yaml new file mode 100644 index 0000000..2779b46 --- /dev/null +++ b/charts/greptimedb-standalone/templates/podmonitor.yaml @@ -0,0 +1,18 @@ +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ include "greptimedb-standalone.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + release: prometheus +spec: + podMetricsEndpoints: + - interval: 30s + port: http + path: /metrics + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "greptimedb-standalone.selectorLabels" . | nindent 6 }} diff --git a/charts/greptimedb-standalone/templates/service.yaml b/charts/greptimedb-standalone/templates/service.yaml new file mode 100644 index 0000000..385148b --- /dev/null +++ b/charts/greptimedb-standalone/templates/service.yaml @@ -0,0 +1,31 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "greptimedb-standalone.fullname" . }} + labels: + {{- include "greptimedb-standalone.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - name: http + port: 4000 + targetPort: 4000 + protocol: TCP + - name: grpc + port: 4001 + targetPort: 4001 + protocol: TCP + - name: mysql + port: 4002 + targetPort: 4002 + protocol: TCP + - name: postgres + port: 4003 + targetPort: 4003 + protocol: TCP + - name: prom + port: 4004 + targetPort: 4004 + protocol: TCP + selector: + {{- include "greptimedb-standalone.selectorLabels" . | nindent 4 }} diff --git a/charts/greptimedb-standalone/templates/serviceaccount.yaml b/charts/greptimedb-standalone/templates/serviceaccount.yaml new file mode 100644 index 0000000..fb5abec --- /dev/null +++ b/charts/greptimedb-standalone/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "greptimedb-standalone.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "greptimedb-standalone.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/greptimedb-standalone/values.yaml b/charts/greptimedb-standalone/values.yaml new file mode 100644 index 0000000..bb6708b --- /dev/null +++ b/charts/greptimedb-standalone/values.yaml @@ -0,0 +1,53 @@ +image: + registry: docker.io + # The image repository + repository: greptime/greptimedb + # The image tag + tag: "v0.4.0" + + pullPolicy: IfNotPresent + pullSecrets: [] + +nameOverride: "" + +fullnameOverride: "" + +command: [ + "greptime", "standalone", "start" +] + +args: [] + +env: [] + +serviceAccount: + # Specifies whether a service account should be created + create: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +service: + type: ClusterIP + +resources: + limits: + cpu: 800m + memory: 1Gi + requests: + cpu: 200m + memory: 512Mi + +nodeSelector: {} + +tolerations: {} + +affinity: {}