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: add static auth configuration #156

Merged
merged 1 commit into from
Aug 14, 2024
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.6
version: 0.2.7
appVersion: 0.9.1
home: https://github.com/GreptimeTeam/greptimedb
sources:
Expand Down
7 changes: 6 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.6](https://img.shields.io/badge/Version-0.2.6-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.1](https://img.shields.io/badge/AppVersion-0.9.1-informational?style=flat-square)
![Version: 0.2.7](https://img.shields.io/badge/Version-0.2.7-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.9.1](https://img.shields.io/badge/AppVersion-0.9.1-informational?style=flat-square)

## Source Code

Expand Down Expand Up @@ -73,6 +73,11 @@ helm uninstall mycluster -n default

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| 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/clients/authentication#authentication). |
| auth.enabled | bool | `false` | Enable static auth |
| auth.fileName | string | `"passwd"` | The auth file name, the full path is `${mountPath}/${fileName}` |
| auth.mountPath | string | `"/etc/greptimedb/auth"` | The auth file path to store the auth info |
| auth.users | list | `[{"password":"admin","username":"admin"}]` | The users to be created in the auth file |
| base.podTemplate | object | `{"affinity":{},"annotations":{},"labels":{},"main":{"args":[],"command":[],"env":[],"readinessProbe":{},"resources":{"limits":{},"requests":{}}},"nodeSelector":{},"serviceAccountName":"","tolerations":[]}` | The pod template for base |
| base.podTemplate.affinity | object | `{}` | The pod affinity |
| base.podTemplate.annotations | object | `{}` | The annotations to be created to the pod. |
Expand Down
30 changes: 26 additions & 4 deletions charts/greptimedb-cluster/templates/cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,25 @@ spec:
{{- if .Values.frontend.podTemplate.main.args }}
args: {{ .Values.frontend.podTemplate.main.args | toYaml | nindent 8 }}
{{- end }}
{{- if or .Values.auth.enabled .Values.frontend.podTemplate.main.env }}
env:
{{- if .Values.auth.enabled }}
- name: GREPTIMEDB_FRONTEND__USER_PROVIDER
value: "static_user_provider:file:{{ .Values.auth.mountPath }}/{{ .Values.auth.fileName }}"
{{- end }}
{{- if .Values.frontend.podTemplate.main.env }}
env: {{- toYaml .Values.frontend.podTemplate.main.env | nindent 8 }}
{{- toYaml .Values.frontend.podTemplate.main.env | nindent 8 }}
{{- end }}
{{- end }}
{{- if or .Values.auth.enabled .Values.frontend.podTemplate.main.volumeMounts }}
volumeMounts:
{{- if .Values.frontend.podTemplate.main.volumeMounts }}
volumeMounts: {{- toYaml .Values.frontend.podTemplate.main.volumeMounts | nindent 8 }}
{{- toYaml .Values.frontend.podTemplate.main.volumeMounts | nindent 8 }}
{{- end }}
{{- if .Values.auth.enabled }}
- name: auth
mountPath: {{ .Values.auth.mountPath }}
{{- end }}
{{- end }}
resources:
requests: {{ .Values.frontend.podTemplate.main.resources.requests | toYaml | nindent 12 }}
Expand All @@ -104,8 +118,16 @@ spec:
{{- if .Values.frontend.podTemplate.nodeSelector }}
nodeSelector: {{ .Values.frontend.podTemplate.nodeSelector | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.frontend.podTemplate.volumes}}
volumes: {{ .Values.frontend.podTemplate.volumes | toYaml | nindent 8 }}
{{- if or .Values.auth.enabled .Values.frontend.podTemplate.volumes }}
volumes:
{{- if .Values.frontend.podTemplate.volumes }}
{{- toYaml .Values.frontend.podTemplate.volumes | nindent 8 }}
{{- end }}
{{- if .Values.auth.enabled }}
- name: auth
secret:
secretName: {{ .Release.Name }}-users-auth
{{- end }}
{{- end }}
meta:
replicas: {{ .Values.meta.replicas }}
Expand Down
13 changes: 13 additions & 0 deletions charts/greptimedb-cluster/templates/users-auth-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.auth.enabled -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-users-auth
namespace: {{ .Release.Namespace }}
type: Opaque
stringData:
{{ .Values.auth.fileName }}: |
{{- range .Values.auth.users }}
{{ printf "%s=%s" .username .password }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/greptimedb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,16 @@ remoteWal:
kafka:
# -- The kafka broker endpoints
brokerEndpoints: []

# -- The static auth for greptimedb, only support one user now(https://docs.greptime.com/user-guide/clients/authentication#authentication).
auth:
# -- Enable static auth
enabled: false
# -- The auth file path to store the auth info
mountPath: "/etc/greptimedb/auth"
# -- The auth file name, the full path is `${mountPath}/${fileName}`
fileName: "passwd"
# -- The users to be created in the auth file
users:
- username: "admin"
password: "admin"
Loading