Skip to content

Commit

Permalink
refactor: add serviceaccount creation for greptimedb-cluster (#91)
Browse files Browse the repository at this point in the history
* refactor: add serviceaccount creation for greptimedb-cluster

* refactor: expand podtemplate configs

* refactor: polish comments

* refactor: modify datanode serviceaccount name

* refactor: modify annotations
  • Loading branch information
zyy17 authored Dec 27, 2023
1 parent b6446a5 commit aae6ff1
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 20 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,5 +2,5 @@ apiVersion: v2
name: greptimedb-cluster
description: A Helm chart for deploying GreptimeDB cluster in Kubernetes
type: application
version: 0.1.7
version: 0.1.8
appVersion: 0.4.4
49 changes: 45 additions & 4 deletions 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.1.7](https://img.shields.io/badge/Version-0.1.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.4.4](https://img.shields.io/badge/AppVersion-0.4.4-informational?style=flat-square)
![Version: 0.1.8](https://img.shields.io/badge/Version-0.1.8-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.4.4](https://img.shields.io/badge/AppVersion-0.4.4-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -65,14 +65,42 @@ helm uninstall mycluster -n default
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| datanode.config | string | `""` | Extra datanode config in toml format. |
| datanode.podTemplate | object | `{}` | The pod template for datanode. |
| datanode.podTemplate | object | `{"affinity":{},"annotations":{},"labels":{},"main":{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}},"nodeSelector":{},"serviceaccount":{"annotations":{},"create":false,"name":"datanode-sa"},"tolerations":[]}` | The pod template for datanode |
| datanode.podTemplate.affinity | object | `{}` | The pod affinity |
| datanode.podTemplate.annotations | object | `{}` | The annotations to be created to the pod. |
| datanode.podTemplate.labels | object | `{}` | The labels to be created to the pod. |
| datanode.podTemplate.main | object | `{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}}` | The spec of main container |
| datanode.podTemplate.main.args | list | `[]` | The arguments to be passed to the command |
| datanode.podTemplate.main.command | list | `[]` | The command to be executed in the container |
| datanode.podTemplate.main.env | list | `[]` | The environment variables for the container |
| datanode.podTemplate.main.image | string | `""` | The datanode image. |
| datanode.podTemplate.main.resources.limits | object | `{}` | The resources limits for the container |
| datanode.podTemplate.main.resources.requests | object | `{}` | The requested resources for the container |
| datanode.podTemplate.nodeSelector | object | `{}` | The pod node selector |
| datanode.podTemplate.serviceaccount.annotations | object | `{}` | The annotations for datanode serviceaccount |
| datanode.podTemplate.serviceaccount.create | bool | `false` | Create a service account |
| datanode.podTemplate.serviceaccount.name | string | `"datanode-sa"` | The serviceaccount name |
| datanode.podTemplate.tolerations | list | `[]` | The pod tolerations |
| datanode.replicas | int | `3` | Datanode replicas |
| datanode.storage.storageClassName | string | `nil` | Storage class for datanode persistent volume |
| datanode.storage.storageRetainPolicy | string | `"Retain"` | Storage retain policy for datanode persistent volume |
| datanode.storage.storageSize | string | `"10Gi"` | Storage size for datanode persistent volume |
| datanode.storage.walDir | string | `"/tmp/greptimedb/wal"` | The wal directory of the storage, default is "/tmp/greptimedb/wal" |
| frontend.config | string | `""` | Extra frontend config in toml format. |
| frontend.podTemplate | object | `{}` | The pod template for frontend. |
| frontend.podTemplate | object | `{"affinity":{},"annotations":{},"labels":{},"main":{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}},"nodeSelector":{},"serviceAccountName":"","tolerations":[]}` | The pod template for frontend |
| frontend.podTemplate.affinity | object | `{}` | The pod affinity |
| frontend.podTemplate.annotations | object | `{}` | The annotations to be created to the pod. |
| frontend.podTemplate.labels | object | `{}` | The labels to be created to the pod. |
| frontend.podTemplate.main | object | `{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}}` | The spec of main container |
| frontend.podTemplate.main.args | list | `[]` | The arguments to be passed to the command |
| frontend.podTemplate.main.command | list | `[]` | The command to be executed in the container |
| frontend.podTemplate.main.env | list | `[]` | The environment variables for the container |
| frontend.podTemplate.main.image | string | `""` | The frontend image. |
| frontend.podTemplate.main.resources.limits | object | `{}` | The resources limits for the container |
| frontend.podTemplate.main.resources.requests | object | `{}` | The requested resources for the container |
| frontend.podTemplate.nodeSelector | object | `{}` | The pod node selector |
| frontend.podTemplate.serviceAccountName | string | `""` | The service account for frontend |
| frontend.podTemplate.tolerations | list | `[]` | The pod tolerations |
| frontend.replicas | int | `1` | Frontend replicas |
| frontend.service | object | `{}` | Frontend service |
| frontend.tls | object | `{}` | Frontend tls configure |
Expand All @@ -87,7 +115,20 @@ helm uninstall mycluster -n default
| initializer.tag | string | `"0.1.0-alpha.17"` | Initializer image tag |
| meta.config | string | `""` | Extra Meta config in toml format. |
| meta.etcdEndpoints | string | `"etcd.default.svc.cluster.local:2379"` | Meta etcd endpoints |
| meta.podTemplate | object | `{}` | The pod template for Meta. |
| meta.podTemplate | object | `{"affinity":{},"annotations":{},"labels":{},"main":{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}},"nodeSelector":{},"serviceAccountName":"","tolerations":[]}` | The pod template for meta |
| meta.podTemplate.affinity | object | `{}` | The pod affinity |
| meta.podTemplate.annotations | object | `{}` | The annotations to be created to the pod. |
| meta.podTemplate.labels | object | `{}` | The labels to be created to the pod. |
| meta.podTemplate.main | object | `{"args":[],"command":[],"env":[],"image":"","resources":{"limits":{},"requests":{}}}` | The spec of main container |
| meta.podTemplate.main.args | list | `[]` | The arguments to be passed to the command |
| meta.podTemplate.main.command | list | `[]` | The command to be executed in the container |
| meta.podTemplate.main.env | list | `[]` | The environment variables for the container |
| meta.podTemplate.main.image | string | `""` | The meta image. |
| meta.podTemplate.main.resources.limits | object | `{}` | The resources limits for the container |
| meta.podTemplate.main.resources.requests | object | `{}` | The requested resources for the container |
| meta.podTemplate.nodeSelector | object | `{}` | The pod node selector |
| meta.podTemplate.serviceAccountName | string | `""` | The service account for meta |
| meta.podTemplate.tolerations | list | `[]` | The pod tolerations |
| meta.replicas | int | `1` | Meta replicas |
| mysqlServicePort | int | `4002` | GreptimeDB mysql service port |
| openTSDBServicePort | int | `4242` | GreptimeDB opentsdb service port |
Expand Down
114 changes: 105 additions & 9 deletions charts/greptimedb-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,41 @@ spec:
{{- if .Values.frontend.service }}
service: {{- toYaml .Values.frontend.service | nindent 6 }}
{{- end }}
{{- if .Values.frontend.podTemplate }}
template: {{- toYaml .Values.frontend.podTemplate | nindent 6 }}
{{- end }}
template:
main:
{{- if .Values.frontend.podTemplate.main.image }}
image: {{ .Values.frontend.podTemplate.main.image }}
{{- end }}
{{- if .Values.frontend.podTemplate.main.command }}
command: {{ .Values.frontend.podTemplate.main.command }}
{{- end }}
{{- if .Values.frontend.podTemplate.main.args }}
args: {{ .Values.frontend.podTemplate.main.args }}
{{- end }}
{{- if .Values.frontend.podTemplate.main.env }}
env: {{- toYaml .Values.frontend.podTemplate.main.env | nindent 8 }}
{{- end }}
resources:
requests: {{ .Values.frontend.podTemplate.main.resources.requests | toYaml | nindent 12 }}
limits: {{ .Values.frontend.podTemplate.main.resources.limits | toYaml | nindent 12 }}
{{- if .Values.frontend.podTemplate.annotations }}
annotations: {{ .Values.frontend.podTemplate.annotations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.frontend.podTemplate.labels }}
labels: {{ .Values.frontend.podTemplate.labels | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.frontend.podTemplate.serviceAccountName }}
serviceAccountName: {{ .Values.frontend.podTemplate.serviceAccountName }}
{{- end }}
{{- if .Values.frontend.podTemplate.tolerations }}
tolerations: {{ .Values.frontend.podTemplate.tolerations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.frontend.podTemplate.affinity }}
affinity: {{ .Values.frontend.podTemplate.affinity | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.frontend.podTemplate.nodeSelector }}
nodeSelector: {{ .Values.frontend.podTemplate.nodeSelector | toYaml | nindent 8 }}
{{- end }}
meta:
replicas: {{ .Values.meta.replicas }}
{{- if .Values.meta.config }}
Expand All @@ -42,18 +74,82 @@ spec:
etcdEndpoints:
- {{ .Values.meta.etcdEndpoints }}
{{- end }}
{{- if .Values.meta.podTemplate }}
template: {{- toYaml .Values.meta.podTemplate | nindent 6 }}
{{- end }}
template:
main:
{{- if .Values.meta.podTemplate.main.image }}
image: {{ .Values.meta.podTemplate.main.image }}
{{- end }}
{{- if .Values.meta.podTemplate.main.command }}
command: {{ .Values.meta.podTemplate.main.command }}
{{- end }}
{{- if .Values.meta.podTemplate.main.args }}
args: {{ .Values.meta.podTemplate.main.args }}
{{- end }}
{{- if .Values.meta.podTemplate.main.env }}
env: {{- toYaml .Values.meta.podTemplate.main.env | nindent 8 }}
{{- end }}
resources:
requests: {{ .Values.meta.podTemplate.main.resources.requests | toYaml | nindent 12 }}
limits: {{ .Values.meta.podTemplate.main.resources.limits | toYaml | nindent 12 }}
{{- if .Values.meta.podTemplate.annotations }}
annotations: {{ .Values.meta.podTemplate.annotations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.meta.podTemplate.labels }}
labels: {{ .Values.meta.podTemplate.labels | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.meta.podTemplate.serviceAccountName }}
serviceAccountName: {{ .Values.meta.podTemplate.serviceAccountName }}
{{- end }}
{{- if .Values.meta.podTemplate.tolerations }}
tolerations: {{ .Values.meta.podTemplate.tolerations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.meta.podTemplate.affinity }}
affinity: {{ .Values.meta.podTemplate.affinity | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.meta.podTemplate.nodeSelector }}
nodeSelector: {{ .Values.meta.podTemplate.nodeSelector | toYaml | nindent 8 }}
{{- end }}
datanode:
replicas: {{ .Values.datanode.replicas }}
{{- if .Values.datanode.config }}
config: |-
{{ .Values.datanode.config | nindent 6 }}
{{- end }}
{{- if .Values.datanode.podTemplate }}
template: {{- toYaml .Values.datanode.podTemplate | nindent 6 }}
{{- end }}
template:
main:
{{- if .Values.datanode.podTemplate.main.image }}
image: {{ .Values.datanode.podTemplate.main.image }}
{{- end }}
{{- if .Values.datanode.podTemplate.main.command }}
command: {{ .Values.datanode.podTemplate.main.command }}
{{- end }}
{{- if .Values.datanode.podTemplate.main.args }}
args: {{ .Values.datanode.podTemplate.main.args }}
{{- end }}
{{- if .Values.datanode.podTemplate.main.env }}
env: {{- toYaml .Values.datanode.podTemplate.main.env | nindent 8 }}
{{- end }}
resources:
requests: {{ .Values.datanode.podTemplate.main.resources.requests | toYaml | nindent 12 }}
limits: {{ .Values.datanode.podTemplate.main.resources.limits | toYaml | nindent 12 }}
{{- if .Values.datanode.podTemplate.annotations }}
annotations: {{ .Values.datanode.podTemplate.annotations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.datanode.podTemplate.labels }}
labels: {{ .Values.datanode.podTemplate.labels | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.datanode.podTemplate.serviceaccount.create }}
serviceAccountName: {{ .Release.Name }}-datanode
{{- end }}
{{- if .Values.datanode.podTemplate.tolerations }}
tolerations: {{ .Values.datanode.podTemplate.tolerations | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.datanode.podTemplate.affinity }}
affinity: {{ .Values.datanode.podTemplate.affinity | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.datanode.podTemplate.nodeSelector }}
nodeSelector: {{ .Values.datanode.podTemplate.nodeSelector | toYaml | nindent 8 }}
{{- end }}
storage:
storageClassName: {{ .Values.datanode.storage.storageClassName }}
storageSize: {{ .Values.datanode.storage.storageSize }}
Expand Down
10 changes: 10 additions & 0 deletions charts/greptimedb-cluster/templates/datanode-serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if .Values.datanode.podTemplate.serviceaccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-datanode
namespace: {{ .Release.Namespace }}
{{- with .Values.datanode.podTemplate.serviceaccount.annotations }}
annotations: {{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
128 changes: 122 additions & 6 deletions charts/greptimedb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,45 @@ frontend:
# -- Extra frontend config in toml format.
config: ""

# -- The pod template for frontend.
podTemplate: {}
# -- The pod template for frontend
podTemplate:
# -- The spec of main container
main:
# -- The frontend image.
image: ""

resources:
# -- The requested resources for the container
requests: {}
# cpu: "1"
# memory: "2Gi"

# -- The resources limits for the container
limits: {}
# cpu: "1"
# memory: "2Gi"

# -- The environment variables for the container
env: []

# -- The command to be executed in the container
command: []

# -- The arguments to be passed to the command
args: []

# -- The annotations to be created to the pod.
annotations: {}
# -- The labels to be created to the pod.
labels: {}
# -- The pod node selector
nodeSelector: {}
# -- The pod tolerations
tolerations: []
# -- The pod affinity
affinity: {}
# -- The service account for frontend
serviceAccountName: ""

# -- Frontend service
service: {}
Expand All @@ -42,8 +79,45 @@ meta:
# -- Extra Meta config in toml format.
config: ""

# -- The pod template for Meta.
podTemplate: {}
# -- The pod template for meta
podTemplate:
# -- The spec of main container
main:
# -- The meta image.
image: ""

resources:
# -- The requested resources for the container
requests: {}
# cpu: "1"
# memory: "2Gi"

# -- The resources limits for the container
limits: {}
# cpu: "1"
# memory: "2Gi"

# -- The environment variables for the container
env: []

# -- The command to be executed in the container
command: []

# -- The arguments to be passed to the command
args: []

# -- The annotations to be created to the pod.
annotations: {}
# -- The labels to be created to the pod.
labels: {}
# -- The pod node selector
nodeSelector: {}
# -- The pod tolerations
tolerations: []
# -- The pod affinity
affinity: {}
# -- The service account for meta
serviceAccountName: ""

# -- Meta etcd endpoints
etcdEndpoints: "etcd.default.svc.cluster.local:2379"
Expand All @@ -55,8 +129,50 @@ datanode:
# -- Extra datanode config in toml format.
config: ""

# -- The pod template for datanode.
podTemplate: {}
# -- The pod template for datanode
podTemplate:
# -- The spec of main container
main:
# -- The datanode image.
image: ""

resources:
# -- The requested resources for the container
requests: {}
# cpu: "1"
# memory: "2Gi"

# -- The resources limits for the container
limits: {}
# cpu: "1"
# memory: "2Gi"

# -- The environment variables for the container
env: []

# -- The command to be executed in the container
command: []

# -- The arguments to be passed to the command
args: []

# -- The annotations to be created to the pod.
annotations: {}
# -- The labels to be created to the pod.
labels: {}
# -- The pod node selector
nodeSelector: {}
# -- The pod tolerations
tolerations: []
# -- The pod affinity
affinity: {}
serviceaccount:
# -- Create a service account
create: false
# -- The serviceaccount name
name: datanode-sa
# -- The annotations for datanode serviceaccount
annotations: {}

storage:
# -- Storage class for datanode persistent volume
Expand Down

0 comments on commit aae6ff1

Please sign in to comment.