Skip to content

Commit 6da74cc

Browse files
committed
add admin
1 parent 8dc9b4b commit 6da74cc

File tree

7 files changed

+169
-24
lines changed

7 files changed

+169
-24
lines changed

charts/memobase/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ sources:
66
- https://github.com/memodb-io/memobase
77
- https://github.com/memodb-io/memobase-helm
88
type: application
9-
version: 0.0.4
9+
version: 0.0.5
1010
appVersion: 0.0.31

charts/memobase/README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,29 @@ The following table lists the configurable parameters of the Memobase chart and
5252

5353
| Key | Type | Default | Description |
5454
|-----|------|---------|-------------|
55+
| admin.accessToken | string | `"token"` | |
56+
| admin.enabled | bool | `false` | |
57+
| admin.image.repository | string | `"ghcr.io/memodb-io/memobase-admin"` | |
58+
| admin.image.secret.dockerconfigjson | string | `""` | |
59+
| admin.image.tag | string | `"0.0.7"` | |
60+
| admin.ingress.annotations | object | `{}` | |
61+
| admin.ingress.enabled | bool | `false` | |
62+
| admin.ingress.hosts | list | `[]` | |
63+
| admin.ingress.ingressClassName | string | `""` | |
64+
| admin.name | string | `"memobase-admin"` | |
65+
| admin.prometheusUrl | string | `""` | |
66+
| admin.replicaCount | int | `1` | |
67+
| admin.resources.limits.cpu | string | `"100m"` | |
68+
| admin.resources.limits.memory | string | `"128Mi"` | |
69+
| admin.resources.requests.cpu | string | `"10m"` | |
70+
| admin.resources.requests.memory | string | `"12Mi"` | |
71+
| admin.usageTokenLimitActive | string | `"300000"` | |
72+
| admin.usageTokenLimitPro | string | `"300000000"` | |
5573
| externalStorage.postgresql.enabled | bool | `false` | |
5674
| externalStorage.postgresql.url | string | `""` | |
5775
| externalStorage.redis.enabled | bool | `false` | |
5876
| externalStorage.redis.url | string | `""` | |
59-
| global.image.imagePullPolicy | string | `"IfNotPresent"` | |
77+
| global.image.pullPolicy | string | `"IfNotPresent"` | |
6078
| ingress.annotations | object | `{}` | |
6179
| ingress.enabled | bool | `false` | |
6280
| ingress.hosts | list | `[]` | |
@@ -80,7 +98,6 @@ The following table lists the configurable parameters of the Memobase chart and
8098
| serviceAccount.annotations | object | `{}` | |
8199
| serviceAccount.automount | bool | `true` | |
82100
| serviceAccount.create | bool | `true` | |
83-
| serviceAccount.name | string | `"memobase-sa"` | |
84101

85102
### Core Configuration
86103

charts/memobase/templates/_helpers.tpl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,6 @@ app.kubernetes.io/name: {{ include "memobase.name" . }}
5050
app.kubernetes.io/instance: {{ .Release.Name }}
5151
{{- end }}
5252

53-
{{/*
54-
Create the name of the service account to use
55-
*/}}
56-
{{- define "memobase.serviceAccountName" -}}
57-
{{- if .Values.serviceAccount.create }}
58-
{{- default (include "memobase.fullname" .) .Values.serviceAccount.name }}
59-
{{- else }}
60-
{{- default "default" .Values.serviceAccount.name }}
61-
{{- end }}
62-
{{- end }}
63-
6453
{{- define "memobase.validatePostgresConfig" -}}
6554
{{- if and .Values.postgresql.enabled .Values.externalStorage.postgresql.enabled -}}
6655
{{- fail "Error: Only one PostgreSQL configuration can be enabled. Set either postgresql.enabled=true or externalStorage.postgresql.enabled=true, not both." -}}

charts/memobase/templates/admin.yaml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{{- if .Values.admin.enabled }}
2+
---
3+
apiVersion: v1
4+
kind: Secret
5+
metadata:
6+
name: {{ include "memobase.name" . }}-admin-secret
7+
namespace: {{ .Values.namespace }}
8+
labels:
9+
app: {{ include "memobase.name" . }}-admin-secret
10+
{{- include "memobase.labels" . | nindent 4 }}
11+
type: kubernetes.io/dockerconfigjson
12+
data:
13+
.dockerconfigjson: {{ .Values.admin.secret.dockerconfigjson | quote }}
14+
---
15+
apiVersion: apps/v1
16+
kind: Deployment
17+
metadata:
18+
name: {{ include "memobase.name" . }}-admin
19+
namespace: {{ .Values.namespace }}
20+
labels:
21+
app: {{ include "memobase.name" . }}-admin
22+
{{- include "memobase.labels" . | nindent 4 }}
23+
spec:
24+
replicas: {{ .Values.admin.replicaCount }}
25+
selector:
26+
matchLabels:
27+
app: {{ include "memobase.name" . }}-admin
28+
{{- include "memobase.selectorLabels" . | nindent 6 }}
29+
template:
30+
metadata:
31+
labels:
32+
app: {{ include "memobase.name" . }}-admin
33+
{{- include "memobase.labels" . | nindent 8 }}
34+
spec:
35+
imagePullSecrets:
36+
- name: {{ include "memobase.name" . }}-admin-secret
37+
containers:
38+
- name: {{ include "memobase.name" . }}-admin
39+
image: {{ .Values.admin.image.repository }}:{{ .Values.admin.image.tag }}
40+
imagePullPolicy: {{ .Values.global.image.pullPolicy }}
41+
env:
42+
- name: DATABASE_URL
43+
{{- if .Values.postgresql.enabled }}
44+
value: >-
45+
postgresql://{{ .Values.postgresql.username }}:{{ .Values.postgresql.password }}@{{ include "memobase.name" . }}-db.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.postgresql.port }}/{{ .Values.postgresql.database }}
46+
{{- else if .Values.externalStorage.postgresql.enabled }}
47+
value: {{ .Values.externalStorage.postgresql.url | quote }}
48+
{{- end }}
49+
- name: REDIS_URL
50+
{{- if .Values.redis.enabled }}
51+
value: >-
52+
redis://:{{ .Values.redis.password }}@{{ include "memobase.name" . }}-redis.{{ .Release.Namespace }}.svc.cluster.local:6379/0
53+
{{- else if .Values.externalStorage.redis.enabled }}
54+
value: {{ .Values.externalStorage.redis.url | quote }}
55+
{{- end }}
56+
- name: ACCESS_TOKEN
57+
value: {{ .Values.admin.accessToken | quote }}
58+
- name: PROMETHEUS_URL
59+
value: {{ .Values.admin.prometheusUrl | quote }}
60+
- name: USAGE_TOKEN_LIMIT_ACTIVE
61+
value: {{ .Values.admin.usageTokenLimitActive | quote }}
62+
- name: USAGE_TOKEN_LIMIT_PRO
63+
value: {{ .Values.admin.usageTokenLimitPro | quote }}
64+
resources:
65+
{{- toYaml .Values.admin.resources | nindent 12 }}
66+
ports:
67+
- containerPort: 8000
68+
---
69+
apiVersion: v1
70+
kind: Service
71+
metadata:
72+
name: {{ include "memobase.name" . }}-admin
73+
labels:
74+
app: {{ include "memobase.name" . }}-admin
75+
{{- include "memobase.labels" . | nindent 4 }}
76+
spec:
77+
ports:
78+
- port: 8000
79+
targetPort: 8000
80+
protocol: TCP
81+
selector:
82+
app: {{ include "memobase.name" . }}-admin
83+
{{- include "memobase.selectorLabels" . | nindent 4 }}
84+
---
85+
{{- if .Values.admin.ingress.enabled }}
86+
apiVersion: networking.k8s.io/v1
87+
kind: Ingress
88+
metadata:
89+
name: {{ include "memobase.name" . }}-admin
90+
namespace: {{ .Release.Namespace }}
91+
labels:
92+
{{- include "memobase.labels" . | nindent 4 }}
93+
annotations:
94+
{{- toYaml .Values.admin.ingress.annotations | nindent 4 }}
95+
spec:
96+
ingressClassName: {{ .Values.admin.ingress.ingressClassName | quote }}
97+
rules:
98+
{{- range .Values.admin.ingress.hosts }}
99+
- host: {{ .host | quote }}
100+
http:
101+
paths:
102+
- path: /
103+
pathType: Prefix
104+
backend:
105+
service:
106+
name: {{ include "memobase.name" $ }}-admin
107+
port:
108+
number: 8000
109+
110+
{{- end }}
111+
{{- end }}
112+
113+
{{- end }}

charts/memobase/templates/deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ spec:
2020
app: {{ include "memobase.name" . }}
2121
{{- include "memobase.labels" . | nindent 8 }}
2222
spec:
23-
serviceAccountName: {{ include "memobase.serviceAccountName" . }}
23+
serviceAccountName: {{ include "memobase.name" . }}-sa
2424
containers:
2525
- name: memobase
2626
image: {{ .Values.core.image.repository }}:{{ .Values.core.image.tag | default .Chart.AppVersion }}
27-
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
27+
imagePullPolicy: {{ .Values.global.image.pullPolicy }}
2828
env:
2929
- name: DATABASE_URL
3030
{{- if .Values.postgresql.enabled }}

charts/memobase/templates/serviceaccount.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: ServiceAccount
44
metadata:
5-
name: {{ include "memobase.serviceAccountName" . }}
5+
name: {{ include "memobase.name" . }}-sa
66
labels:
77
{{- include "memobase.labels" . | nindent 4 }}
88
namespace: {{ .Release.Namespace }}

charts/memobase/values.yaml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
global:
66
image:
7-
imagePullPolicy: IfNotPresent
7+
pullPolicy: IfNotPresent
88

99
core:
1010
name: memobase
@@ -98,15 +98,9 @@ externalStorage:
9898
url: ""
9999

100100
serviceAccount:
101-
# Specifies whether a service account should be created
102101
create: true
103-
# Automatically mount a ServiceAccount's API credentials?
104102
automount: true
105-
# Annotations to add to the service account
106103
annotations: {}
107-
# The name of the service account to use.
108-
# If not set and create is true, a name is generated using the fullname template
109-
name: memobase-sa
110104

111105
service:
112106
type: ClusterIP
@@ -124,3 +118,35 @@ ingress:
124118
# - secretName: chart-example-tls
125119
# hosts:
126120
# - chart-example.local
121+
122+
123+
# this is internal, end users don't need to set this
124+
admin:
125+
enabled: false
126+
name: memobase-admin
127+
replicaCount: 1
128+
accessToken: "token"
129+
prometheusUrl: ""
130+
usageTokenLimitActive: "300000"
131+
usageTokenLimitPro: "300000000"
132+
image:
133+
repository: ghcr.io/memodb-io/memobase-admin
134+
tag: "0.0.7"
135+
secret:
136+
# you can get the dockerconfigjson from the command:
137+
# kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --dry-run=client -o yaml
138+
dockerconfigjson: ""
139+
resources:
140+
requests:
141+
cpu: 10m
142+
memory: 12Mi
143+
limits:
144+
cpu: 100m
145+
memory: 128Mi
146+
ingress:
147+
enabled: false
148+
annotations: {}
149+
ingressClassName: ""
150+
hosts: []
151+
# - host: chart-example.local
152+

0 commit comments

Comments
 (0)