Skip to content

Commit

Permalink
feat: compatible with 2.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
dsun0720 committed Nov 27, 2023
1 parent 5b056e3 commit d6d8dd4
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 113 deletions.
4 changes: 2 additions & 2 deletions charts/featbit/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.7
version: 0.0.8

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "2.5.2"
appVersion: "2.5.3"

kubeVersion: ">=1.23-0"

Expand Down
98 changes: 47 additions & 51 deletions charts/featbit/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,17 @@ Return the Mongodb host
{{- end -}}

{{- define "featbit.mongodb.port" -}}
{{- if .Values.mongodb.enabled }}
{{- if .Values.mongodb.enabled -}}
{{- .Values.mongodb.service.ports.mongodb -}}
{{- end -}}
{{- end -}}

{{- define "featbit.mongodb.createSecret" -}}
{{- if and (not .Values.mongodb.enabled) (not .Values.externalMongodb.existingSecret) -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "featbit.mongodb.connStr" -}}
{{- if .Values.mongodb.enabled -}}
{{- printf "mongodb://%s:%s@%s:%s" .Values.mongodb.auth.rootUser .Values.mongodb.auth.rootPassword (include "featbit.mongodb.host" .) (include "featbit.mongodb.port" .) -}}
Expand All @@ -153,20 +159,45 @@ Return the Mongodb host
Return the Mongodb secret name
*/}}
{{- define "featbit.mongodb.secretName" -}}
{{- if and (not .Values.mongodb.enabled) .Values.externalMongodb.existingSecret -}}
{{- printf "%s" .Values.externalMongodb.existingSecret -}}
{{- else -}}
{{- printf "%s-conn-str" (include "featbit.mongodb.fullname" .) -}}
{{- end -}}
{{- end -}}

{{/*
Return the Mongodb secret key
*/}}
{{- define "featbit.mongodb.secretKey" -}}
{{- if and (not .Values.mongodb.enabled) .Values.externalMongodb.existingSecret -}}
{{- required "You need to provide existingSecretKey when an existingSecret is specified in external MongoDB" .Values.externalMongodb.existingSecretKey | printf "%s" -}}
{{- else -}}
{{- printf "mongodb-conn-str" -}}
{{- end -}}

{{- end -}}
{{/*
-----REDIS-----
*/}}

{{- define "featbit.redis.cluster.enabled" -}}
{{- if and (not .Values.redis.enabled) .Values.externalRedis.cluster.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "featbit.redis.sentinel.enabled" -}}
{{- if and (not .Values.redis.enabled) .Values.externalRedis.sentinel.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "featbit.redis.standalone.enabled" -}}
{{- if and (not (include "featbit.redis.cluster.enabled" .)) (not (include "featbit.redis.sentinel.enabled" .)) -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{/*
Return the Redis fullname
*/}}
Expand All @@ -186,8 +217,11 @@ Return the Redis host
{{- define "featbit.redis.host" -}}
{{- if .Values.redis.enabled -}}
{{- printf "%s-master" (include "featbit.redis.fullname" .) -}}
{{- else if and (include "featbit.redis.standalone.enabled") (not .Values.externalRedis.hosts) -}}
{{- $parts:= split ":" (first .Values.externalRedis.hosts) -}}
{{- printf "%s" (first $parts) -}}
{{- else -}}
{{- required "You need to provide a host when using external redis" (join "," .Values.externalRedis.hosts) | printf "%s" -}}
{{- required "You need to provide a host-pair when using external redis" (join "," .Values.externalRedis.hosts) | printf "%s" -}}
{{- end -}}
{{- end -}}

Expand All @@ -197,6 +231,13 @@ Return the Redis port
{{- define "featbit.redis.port" -}}
{{- if .Values.redis.enabled }}
{{- .Values.redis.master.service.ports.redis -}}
{{- else if and (include "featbit.redis.standalone.enabled") (not .Values.externalRedis.hosts) -}}
{{- $parts:= split ":" (first .Values.externalRedis.hosts) -}}
{{- if gt (len $parts) 1 -}}
{{- last $parts -}}
{{- else -}}
{{- 6379 -}}
{{- end -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -239,18 +280,6 @@ Return the Redis secret password key
{{- end -}}
{{- end -}}

{{- define "featbit.redis.cluster.enabled" -}}
{{- if and (not .Values.redis.enabled) .Values.externalRedis.cluster.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "featbit.redis.sentinel.enabled" -}}
{{- if and (not .Values.redis.enabled) .Values.externalRedis.sentinel.enabled -}}
{{- true -}}
{{- end -}}
{{- end -}}

{{- define "featbit.redis.db" -}}
{{- $db := "" -}}
{{- if and (not .Values.externalRedis.cluster.enabled) (not .Values.redis.enabled) -}}
Expand Down Expand Up @@ -280,7 +309,7 @@ Return whether Redis uses password authentication or not


{{- define "featbit.redis.config.0" -}}
{{- if .Values.redis.enabled -}}
{{- if (include "featbit.redis.standalone.enabled" .) -}}
{{- printf "%s:%s" (include "featbit.redis.host" .) (include "featbit.redis.port" .) -}}
{{- else -}}
{{- printf "%s" (include "featbit.redis.host" .) -}}
Expand All @@ -298,44 +327,11 @@ Return whether Redis uses password authentication or not
{{- end -}}

{{- define "featbit.redis.config.2" -}}
{{- if (include "featbit.redis.auth.enabled" .) -}}
{{- printf "%s,password=%s" (include "featbit.redis.config.1" .) (default .Values.redis.auth.password .Values.externalRedis.password) -}}
{{- else -}}
{{- printf "%s" (include "featbit.redis.config.1" .) -}}
{{- end -}}
{{- end -}}

{{- define "featbit.redis.config.3" -}}
{{- if and .Values.externalRedis.user (not .Values.redis.enabled) -}}
{{- printf "%s,user=%s" (include "featbit.redis.config.2" .) .Values.externalRedis.user -}}
{{- printf "%s,user=%s" (include "featbit.redis.config.1" .) .Values.externalRedis.user -}}
{{- else -}}
{{- printf "%s" (include "featbit.redis.config.2" .) -}}
{{- end -}}
{{- end -}}


{{- define "featbit.redis.url" -}}
{{- $protocol := "redis://" -}}
{{- if and .Values.externalRedis.ssl (not .Values.redis.enabled) -}}
{{- $protocol = "rediss://" -}}
{{- end -}}
{{- $user := "" -}}
{{- if and .Values.externalRedis.user (not .Values.redis.enabled) -}}
{{- $user = .Values.externalRedis.user -}}
{{- end -}}
{{- $pass := "" -}}
{{- if (include "featbit.redis.auth.enabled" .) -}}
{{- $pass = (default .Values.redis.auth.password .Values.externalRedis.password) -}}
{{- end -}}
{{- $usrpass := "" -}}
{{- if or $pass $user -}}
{{- $usrpass = (printf "%s:%s@" $user $pass) -}}
{{- end -}}
{{- printf "%s%s%s/%s" $protocol $usrpass (include "featbit.redis.config.0" .) (include "featbit.redis.db" .) -}}
{{- printf "%s" (include "featbit.redis.config.1" .) -}}
{{- end -}}

{{- define "featbit.redis.conn.secretName" -}}
{{- printf "%s-conn-str" (include "featbit.redis.fullname" .) -}}
{{- end -}}

{*
Expand Down
41 changes: 21 additions & 20 deletions charts/featbit/templates/_redis-env.tpl
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
{{/* Common Redis ENV variables */}}
{{- define "redis-env" }}
- name: Redis__ConnectionString
valueFrom:
secretKeyRef:
name: {{ include "featbit.redis.conn.secretName" . }}
key: featbit-redis-config

{{- if or (include "featbit.redis.sentinel.enabled" .) (include "featbit.redis.cluster.enabled" .) }}
- name: REDIS_SSL
value: {{ (include "featbit.redis.ssl" .) | quote }}
value: {{ include "featbit.redis.config.2" . }}
{{- if (include "featbit.redis.auth.enabled" .) }}
{{- if .Values.externalRedis.user }}
- name: REDIS_USER
value: {{ .Values.externalRedis.user }}
{{- end }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "featbit.redis.secretName" . }}
key: {{ include "featbit.redis.secretPasswordKey" . }}
- name: Redis__Password
valueFrom:
secretKeyRef:
name: {{ include "featbit.redis.secretName" . }}
key: {{ include "featbit.redis.secretPasswordKey" . }}
{{- end }}
{{- if .Values.externalRedis.user }}
- name: REDIS_USER
value: {{ .Values.externalRedis.user }}
{{- end }}
{{- end }}

- name: REDIS_SSL
value: {{ (include "featbit.redis.ssl" .) | quote }}

- name: REDIS_DB
value: {{ (include "featbit.redis.db" .) | quote }}

{{- if (include "featbit.redis.cluster.enabled" .) }}
- name: CACHE_TYPE
value: RedisClusterCache
Expand All @@ -31,13 +35,10 @@
value: RedisSentinelCache
- name: REDIS_SENTINEL_HOST_PORT_PAIRS
value: {{ include "featbit.redis.config.0" . }}
- name: REDIS_SENTINEL_DB
value: {{ (include "featbit.redis.db" .) | quote }}
{{- else }}
- name: REDIS_URL
valueFrom:
secretKeyRef:
name: {{ include "featbit.redis.conn.secretName" . }}
key: featbit-redis-url
- name: REDIS_HOST
value: {{ include "featbit.redis.host" . }}
- name: REDIS_PORT
value: {{ (include "featbit.redis.port" .) | quote }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/featbit/templates/mongodb-conn-string-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if (include "featbit.mongodb.createSecret" .) }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -9,4 +10,5 @@ metadata:
{{- include "featbit-metadata-annotations-common" . | nindent 4 }}
type: Opaque
data:
{{ include "featbit.mongodb.secretKey" . }}: {{ include "featbit.mongodb.connStr" . | b64enc | quote }}
{{ include "featbit.mongodb.secretKey" . }}: {{ include "featbit.mongodb.connStr" . | b64enc | quote }}
{{- end }}
24 changes: 2 additions & 22 deletions charts/featbit/templates/mongodb-init-scripts-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ data:
print('seed started...')
// seed ids
const workspaceId = UUID()
const userId = UUID()
const organizationId = UUID()
Expand All @@ -31,22 +30,6 @@ data:
return UUID().toString().split('"')[1];
}
// seed workspace
print('clean and seed collection: Workspaces')
db.Workspaces.deleteMany({})
db.Workspaces.insertOne(
{
_id: workspaceId,
name: "Default Workspace",
key: "default-workspace",
sso: null,
license: null,
createdAt: new Date(),
updatedAt: new Date()
}
)
print('collection seeded: Workspaces')
// seed user
print('clean and seed collection: Users')
db.Users.deleteMany({})
Expand All @@ -56,8 +39,6 @@ data:
email: "[email protected]",
password: "AQAAAAEAACcQAAAAELDHEjCrDQrmnAXU5C//mOLvUBJ7lnVFEMMFxNMDIIrF7xK8JDQKUifU3HH4gexNAQ==",
name: "tester",
origin: "Local",
workspaceId: workspaceId,
createAt: new Date(),
updatedAt: new Date()
}
Expand All @@ -70,7 +51,6 @@ data:
db.Organizations.insertOne(
{
_id: organizationId,
workspaceId: workspaceId,
name: "playground",
initialized: false,
createdAt: new Date(),
Expand Down Expand Up @@ -128,10 +108,10 @@ data:
statements: [
{
_id: getUUIDString(),
resourceType: "organization",
resourceType: "account",
effect: "allow",
actions: ["UpdateOrgName"],
resources: ["organization/*"]
resources: ["account/*"]
},
{
_id: getUUIDString(),
Expand Down
13 changes: 0 additions & 13 deletions charts/featbit/templates/redis-conn-str-secret.yaml

This file was deleted.

13 changes: 9 additions & 4 deletions charts/featbit/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ui:
repository: featbit/featbit-ui
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 2.5.2
tag: 2.5.3

imagePullSecrets: [ ]

Expand Down Expand Up @@ -116,7 +116,7 @@ api:
repository: featbit/featbit-api-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 2.5.2
tag: 2.5.3

imagePullSecrets: [ ]

Expand Down Expand Up @@ -194,7 +194,7 @@ els:
repository: featbit/featbit-evaluation-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 2.5.2
tag: 2.5.3

imagePullSecrets: [ ]

Expand Down Expand Up @@ -273,7 +273,7 @@ das:
repository: featbit/featbit-data-analytics-server
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: 2.5.2
tag: 2.5.3

imagePullSecrets: [ ]

Expand Down Expand Up @@ -441,6 +441,11 @@ mongodb:

externalMongodb:
fullConnectionString: ""
# -- Name of an existing Kubernetes secret object containing the full conn string
existingSecret: ""
# -- Name of the key pointing to the full conn string in your Kubernetes secret.
existingSecretKey: ""



busybox:
Expand Down

0 comments on commit d6d8dd4

Please sign in to comment.