Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(greptimedb-standalone): Refactor the object storage configuration to make it simplify #178

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.22
version: 0.2.23
appVersion: 0.9.5
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
2 changes: 1 addition & 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.22](https://img.shields.io/badge/Version-0.2.22-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.5](https://img.shields.io/badge/AppVersion-0.9.5-informational?style=flat-square)
![Version: 0.2.23](https://img.shields.io/badge/Version-0.2.23-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.5](https://img.shields.io/badge/AppVersion-0.9.5-informational?style=flat-square)

## Source Code

Expand Down
10 changes: 8 additions & 2 deletions charts/greptimedb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,16 @@ prometheusMonitor:
# -- Configure to object storage
objectStorage:
# credentials:
# secretName: ""

# # AWS or AliCloud cloudProvider accessKeyID and secretAccessKey
# accessKeyId: "you-should-set-the-access-key-id-here"
# secretAccessKey: "you-should-set-the-secret-access-key-here"

# # GCP cloudProvider serviceAccountKey JSON-formatted base64 value
# serviceAccountKey: "you-should-set-the-base64-service-account-key-here"
# secretName: ""

# # Set the existing secret to get the key's of cloudProvider
# existingSecretName: ""

# configure to use s3 storage.
Expand All @@ -629,7 +635,7 @@ objectStorage:
# configure to use gcs storage
gcs: {}
# bucket: "bucket-name"
# Scope: "" # example: "https://www.googleapis.com/auth/devstorage.read_write"
# scope: "" # example: "https://www.googleapis.com/auth/devstorage.read_write"

# # The data directory in gcs will be: 'gcs://<bucket>/<root>/data/...'.
# root: "mycluster"
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.24
version: 0.1.25
appVersion: 0.9.5
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
4 changes: 2 additions & 2 deletions 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.24](https://img.shields.io/badge/Version-0.1.24-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.5](https://img.shields.io/badge/AppVersion-0.9.5-informational?style=flat-square)
![Version: 0.1.25](https://img.shields.io/badge/Version-0.1.25-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.5](https://img.shields.io/badge/AppVersion-0.9.5-informational?style=flat-square)

## Source Code
- https://github.com/GreptimeTeam/greptimedb
Expand Down Expand Up @@ -72,7 +72,7 @@ helm uninstall greptimedb-standalone -n default
| mysqlServicePort | int | `4002` | GreptimeDB mysql service port |
| nameOverride | string | `""` | Overrides the chart's name |
| nodeSelector | object | `{}` | NodeSelector to apply pod |
| objectStorage | object | `{"oss":{},"s3":{}}` | Configure to object storage |
| objectStorage | object | `{"gcs":{},"oss":{},"s3":{}}` | Configure to object storage |
| persistence.enableStatefulSetAutoDeletePVC | bool | `false` | Enable StatefulSetAutoDeletePVC feature |
| persistence.enabled | bool | `true` | Enable persistent disk |
| persistence.mountPath | string | `"/data/greptimedb"` | Mount path of persistent disk. |
Expand Down
45 changes: 45 additions & 0 deletions charts/greptimedb-standalone/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,48 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "greptimedb-standalone.objectStorageConfig" -}}
{{- if or .Values.objectStorage.s3 .Values.objectStorage.oss .Values.objectStorage.gcs }}
{{- $provider := "" }}
{{- $bucket := "" }}
{{- $root := "" }}

{{- if .Values.objectStorage.s3 }}
{{- $provider = "S3" }}
{{- $bucket = .Values.objectStorage.s3.bucket }}
{{- $root = .Values.objectStorage.s3.root }}
{{- else if .Values.objectStorage.oss }}
{{- $provider = "Oss" }}
{{- $bucket = .Values.objectStorage.oss.bucket }}
{{- $root = .Values.objectStorage.oss.root }}
{{- else if .Values.objectStorage.gcs }}
{{- $provider = "Gcs" }}
{{- $bucket = .Values.objectStorage.gcs.bucket }}
{{- $root = .Values.objectStorage.gcs.root }}
{{- end }}
daviderli614 marked this conversation as resolved.
Show resolved Hide resolved

{{- if and $provider $bucket }}
[storage]
# Storage provider type: S3, Oss, or Gcs
type = "{{ $provider }}"

# Bucket name in the storage provider
bucket = "{{ $bucket }}"

# Root path within the bucket
root = "{{ $root }}"

{{- if .Values.objectStorage.s3 }}
endpoint = "{{ .Values.objectStorage.s3.endpoint }}"
region = "{{ .Values.objectStorage.s3.region }}"
{{- else if .Values.objectStorage.oss }}
endpoint = "{{ .Values.objectStorage.oss.endpoint }}"
region = "{{ .Values.objectStorage.oss.region }}"
{{- else if .Values.objectStorage.gcs }}
endpoint = "{{ .Values.objectStorage.gcs.endpoint }}"
scope = "{{ .Values.objectStorage.gcs.scope }}"
{{- end }}
{{- end }}
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions charts/greptimedb-standalone/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ metadata:
data:
config.toml: |
{{ .Values.configToml | indent 4 }}
{{ include "greptimedb-standalone.objectStorageConfig" . | indent 4 }}
{{- end -}}
21 changes: 9 additions & 12 deletions charts/greptimedb-standalone/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
{{- if .Values.objectStorage }}
{{- if .Values.objectStorage.credentials }}
{{- if not .Values.objectStorage.credentials.existingSecretName }}
apiVersion: v1
metadata:
name: {{ .Release.Name }}-secret
namespace: {{ .Release.Namespace }}
kind: Secret
type: Opaque
{{- if .Values.objectStorage.credentials.serviceAccountKey }}
data:
GREPTIMEDB_STANDALONE__STORAGE__CREDENTIAL: {{ .Values.objectStorage.credentials.serviceAccountKey | b64enc }}
{{- else }}
stringData:
{{- if .Values.objectStorage.s3}}
GREPTIMEDB_STANDALONE__STORAGE__TYPE: "S3"
GREPTIMEDB_STANDALONE__STORAGE__ACCESS_KEY_ID: {{ .Values.objectStorage.credentials.accessKeyId }}
GREPTIMEDB_STANDALONE__STORAGE__SECRET_ACCESS_KEY: {{ .Values.objectStorage.credentials.secretAccessKey }}
GREPTIMEDB_STANDALONE__STORAGE__BUCKET: {{ .Values.objectStorage.s3.bucket}}
GREPTIMEDB_STANDALONE__STORAGE__ROOT: {{ .Values.objectStorage.s3.root }}
GREPTIMEDB_STANDALONE__STORAGE__REGION: {{ .Values.objectStorage.s3.region }}
GREPTIMEDB_STANDALONE__STORAGE__ENDPOINT: {{ .Values.objectStorage.s3.endpoint }}
{{ else if .Values.objectStorage.oss }}
GREPTIMEDB_STANDALONE__STORAGE__TYPE: "Oss"
GREPTIMEDB_STANDALONE__STORAGE__ACCESS_KEY_ID: {{ .Values.objectStorage.credentials.accessKeyId }}
GREPTIMEDB_STANDALONE__STORAGE__ACCESS_KEY_SECRET: {{ .Values.objectStorage.credentials.secretAccessKey }}
GREPTIMEDB_STANDALONE__STORAGE__BUCKET: {{ .Values.objectStorage.oss.bucket}}
GREPTIMEDB_STANDALONE__STORAGE__ROOT: {{ .Values.objectStorage.oss.root }}
GREPTIMEDB_STANDALONE__STORAGE__REGION: {{ .Values.objectStorage.oss.region }}
GREPTIMEDB_STANDALONE__STORAGE__ENDPOINT: {{ .Values.objectStorage.oss.endpoint }}
{{- end}}
GREPTIMEDB_STANDALONE__STORAGE__ACCESS_KEY_SECRET: {{ .Values.objectStorage.credentials.accessKeySecret }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/greptimedb-standalone/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ spec:
{{- if .Values.objectStorage.credentials }}
envFrom:
- secretRef:
{{- if .Values.objectStorage.credentials.existingSecretName }}
name: {{ .Values.objectStorage.credentials.existingSecretName }}
{{- else }}
name: {{ .Release.Name }}-secret
{{- end }}
daviderli614 marked this conversation as resolved.
Show resolved Hide resolved
{{- end }}
{{- end }}
{{- with .Values.securityContext }}
Expand Down
27 changes: 24 additions & 3 deletions charts/greptimedb-standalone/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,21 @@ dataHome: "/data/greptimedb/"

# -- Configure to object storage
objectStorage:
# credentials:
# accessKeyId: "you-should-set-the-access-key-id-here"
# secretAccessKey: "you-should-set-the-secret-access-key-here"
# credentials:
# # AWS or AliCloud cloudProvider accessKeyID
# accessKeyId: "you-should-set-the-access-key-id-here"

# # AWS cloudProvider secretAccessKey
# secretAccessKey: "you-should-set-the-secret-access-key-here"

# # AliCloud cloudProvider secretAccessKey
# accessKeySecret: "you-should-set-the-access-key-secret-here"

# # GCP cloudProvider serviceAccountKey JSON-formatted base64 value
# serviceAccountKey: "you-should-set-the-base64-service-account-key-here"

# # Set the existing secret to get the key's of cloudProvider
# existingSecretName: ""

# configure to use s3 storage
s3: {}
Expand All @@ -63,6 +75,15 @@ objectStorage:
# root: "greptimedb-standalone"
# endpoint: "oss-cn-hangzhou.aliyuncs.com"

# configure to use gcs storage
gcs: {}
# bucket: "bucket-name"
# scope: "" # example: "https://www.googleapis.com/auth/devstorage.read_write"

# # The data directory in gcs will be: 'gcs://<bucket>/<root>/data/...'.
# root: "greptimedb-standalone"
# endpoint: "https://storage.googleapis.com"

daviderli614 marked this conversation as resolved.
Show resolved Hide resolved
# -- Environment variables
env:
GREPTIMEDB_STANDALONE__HTTP__ADDR: "0.0.0.0:4000"
Expand Down
Loading