Skip to content

Commit a6f87e8

Browse files
authored
Feat/v0.7.0 (#53)
* feat: #51 initContainer SecurityContext * feat: update to v5.1.0
1 parent 7a53285 commit a6f87e8

13 files changed

+224
-53
lines changed

charts/featbit/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.6.1
18+
version: 0.7.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "5.0.3"
24+
appVersion: "5.1.0"
2525

2626
kubeVersion: ">=1.23-0"
2727

charts/featbit/templates/_initContainers-wait-for-infrastructure-dependencies.tpl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,46 @@
11
{{/* Common initContainers-wait-for-infrastructure-dependencies definition */}}
22
{{- define "initContainers-wait-for-infrastructure-dependencies" }}
3+
{{- $ctx := .context }}
4+
{{- $component := .component }}
35
- name: wait-for-infrastructure-dependencies
4-
image: {{ include "featbit.init-container.busybox.image" . }}
5-
imagePullPolicy: {{ .Values.busybox.image.pullPolicy }}
6-
{{- if (include "featbit.isPro" .) }}
6+
image: {{ include "featbit.init-container.busybox.image" $ctx }}
7+
imagePullPolicy: {{ $ctx.Values.busybox.image.pullPolicy }}
8+
{{- with (get $ctx.Values $component).securityContext }}
9+
securityContext:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
{{- if (include "featbit.isPro" $ctx) }}
713
env:
8-
{{- include "clickhouse-usr-pass" . | nindent 4 }}
14+
{{- include "clickhouse-usr-pass" $ctx | nindent 4 }}
915
{{- end }}
1016
command:
1117
- /bin/sh
1218
- -c
1319
- >
14-
{{ if and .Values.postgresql.enabled (include "featbit.postgresql.used" .) }}
15-
until (nc -vz -w 1 "{{ include "featbit.postgresql.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.postgresql.port" . }});
20+
{{ if and $ctx.Values.postgresql.enabled (include "featbit.postgresql.used" $ctx) }}
21+
until (nc -vz -w 1 "{{ include "featbit.postgresql.host" $ctx }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.postgresql.port" $ctx }});
1622
do
1723
echo "waiting for Postgresql"; sleep 1;
1824
done
1925
{{ end }}
2026

21-
{{ if and .Values.redis.enabled (include "featbit.redis.used" .) }}
22-
until (nc -vz -w 1 "{{ include "featbit.redis.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.redis.port" . }});
27+
{{ if and $ctx.Values.redis.enabled (include "featbit.redis.used" $ctx) }}
28+
until (nc -vz -w 1 "{{ include "featbit.redis.host" $ctx }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.redis.port" $ctx }});
2329
do
2430
echo "waiting for Redis"; sleep 1;
2531
done
2632
{{ end }}
2733

28-
{{ if and .Values.mongodb.enabled (include "featbit.mongodb.used" .) }}
29-
until (nc -vz -w 1 "{{ include "featbit.mongodb.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.mongodb.port" . }});
34+
{{ if and $ctx.Values.mongodb.enabled (include "featbit.mongodb.used" $ctx) }}
35+
until (nc -vz -w 1 "{{ include "featbit.mongodb.host" $ctx }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local" {{ include "featbit.mongodb.port" $ctx }});
3036
do
3137
echo "waiting for Mongodb"; sleep 1;
3238
done
3339
{{ end }}
3440

35-
{{ if and .Values.kafka.enabled (include "featbit.isPro" .) }}
41+
{{ if and $ctx.Values.kafka.enabled (include "featbit.isPro" $ctx) }}
3642

37-
KAFKA_BROKERS="{{ include "featbit.kafka.consumer.brokers" . }}"
43+
KAFKA_BROKERS="{{ include "featbit.kafka.consumer.brokers" $ctx }}"
3844

3945
KAFKA_HOST=$(echo $KAFKA_BROKERS | cut -f1 -d:)
4046
KAFKA_PORT=$(echo $KAFKA_BROKERS | cut -f2 -d:)
@@ -45,13 +51,13 @@
4551
done
4652
{{ end }}
4753

48-
{{ if and .Values.clickhouse.enabled (include "featbit.isPro" .) }}
54+
{{ if and $ctx.Values.clickhouse.enabled (include "featbit.isPro" $ctx) }}
4955
until (
5056
NODES_COUNT=$(wget -qO- \
51-
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "featbit.clickhouse.host" . }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8123" \
57+
"http://$CLICKHOUSE_USER:$CLICKHOUSE_PASSWORD@{{ include "featbit.clickhouse.host" $ctx }}.$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).svc.cluster.local:8123" \
5258
--post-data "SELECT count() FROM clusterAllReplicas('featbit_ch_cluster', system, one)"
5359
)
54-
test ! -z $NODES_COUNT && test $NODES_COUNT -eq {{ mul .Values.clickhouse.shards .Values.clickhouse.replicaCount }}
60+
test ! -z $NODES_COUNT && test $NODES_COUNT -eq {{ mul $ctx.Values.clickhouse.shards $ctx.Values.clickhouse.replicaCount }}
5561
);
5662
do
5763
echo "waiting for all ClickHouse nodes to be available"; sleep 1;

charts/featbit/templates/_initContainers-wait-for-other-components.tpl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
{{/* ui waits for other components */}}
22
{{- define "initContainers-wait-for-other-components" }}
3+
{{- $ctx := .context }}
4+
{{- $component := .component }}
35
- name: wait-for-other-components
4-
image: {{ include "featbit.init-container.busybox.image" . }}
5-
imagePullPolicy: {{ .Values.busybox.image.pullPolicy }}
6+
image: {{ include "featbit.init-container.busybox.image" $ctx }}
7+
imagePullPolicy: {{ $ctx.Values.busybox.image.pullPolicy }}
8+
{{- with (get $ctx.Values $component).securityContext }}
9+
securityContext:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
612
command:
713
- /bin/sh
814
- -c
915
- >
10-
{{ if (include "api.svc.fqdn" .) }}
11-
until (nc -vz -w 1 {{ include "api.svc.fqdn" . }} {{ include "api.svc.port" . }});
16+
{{ if (include "api.svc.fqdn" $ctx) }}
17+
until (nc -vz -w 1 {{ include "api.svc.fqdn" $ctx }} {{ include "api.svc.port" $ctx }});
1218
do
1319
echo "waiting for API"; sleep 1;
1420
done
1521
{{ end }}
1622

17-
{{ if (include "els.svc.fqdn" .) }}
18-
until (nc -vz -w 1 {{ include "els.svc.fqdn" . }} {{ include "els.svc.port" . }});
23+
{{ if (include "els.svc.fqdn" $ctx) }}
24+
until (nc -vz -w 1 {{ include "els.svc.fqdn" $ctx }} {{ include "els.svc.port" $ctx }});
1925
do
2026
echo "waiting for Evaluation Server"; sleep 1;
2127
done
2228
{{ end }}
2329

24-
{{ if (include "das.svc.fqdn" .) }}
25-
until (nc -vz -w 1 {{ include "das.svc.fqdn" . }} {{ include "das.svc.port" . }});
30+
{{ if (include "das.svc.fqdn" $ctx) }}
31+
until (nc -vz -w 1 {{ include "das.svc.fqdn" $ctx }} {{ include "das.svc.port" $ctx }});
2632
do
2733
echo "waiting for DA Server"; sleep 1;
2834
done

charts/featbit/templates/_mongodb-config.tpl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ Return the Mongodb secret key
7070
{{- else -}}
7171
{{- printf "mongodb-conn-str" -}}
7272
{{- end -}}
73+
{{- end -}}
74+
75+
{{- define "featbit.mongodb.db" -}}
76+
{{- $db := "featbit" -}}
77+
{{- if and .Values.mongodb.enabled .Values.mongodb.userDatabase.name -}}
78+
{{- $db = .Values.mongodb.userDatabase.name -}}
79+
{{- else if .Values.externalMongodb.database -}}
80+
{{- $db = .Values.externalMongodb.database -}}
81+
{{- end -}}
82+
{{- printf "%s" $db -}}
7383
{{- end -}}

charts/featbit/templates/_mongodb-env.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
key: {{ include "featbit.mongodb.secretKey" . }}
88

99
- name: MongoDb__Database
10-
value: featbit
10+
value: {{ include "featbit.mongodb.db" . }}
1111

1212
- name: DbProvider
1313
value: MongoDb
@@ -20,7 +20,7 @@
2020
key: {{ include "featbit.mongodb.secretKey" . }}
2121

2222
- name: MONGO_INITDB_DATABASE
23-
value: featbit
23+
value: {{ include "featbit.mongodb.db" . }}
2424

2525
- name: DB_PROVIDER
2626
value: MongoDb

charts/featbit/templates/api-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
securityContext:
4242
{{- toYaml .Values.api.podSecurityContext | nindent 8 }}
4343
initContainers:
44-
{{- include "initContainers-wait-for-infrastructure-dependencies" . | indent 8 }}
44+
{{- include "initContainers-wait-for-infrastructure-dependencies" (dict "context" . "component" "api") | indent 8 }}
4545
containers:
4646
- name: {{ .Chart.Name }}-api
4747
securityContext:

charts/featbit/templates/da-server-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
securityContext:
4242
{{- toYaml .Values.das.podSecurityContext | nindent 8 }}
4343
initContainers:
44-
{{- include "initContainers-wait-for-infrastructure-dependencies" . | indent 8 }}
44+
{{- include "initContainers-wait-for-infrastructure-dependencies" (dict "context" . "component" "das") | indent 8 }}
4545
containers:
4646
- name: {{ .Chart.Name }}-das
4747
securityContext:

charts/featbit/templates/eval-server-deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ spec:
4141
securityContext:
4242
{{- toYaml .Values.els.podSecurityContext | nindent 8 }}
4343
initContainers:
44-
{{- include "initContainers-wait-for-infrastructure-dependencies" . | indent 8 }}
44+
{{- include "initContainers-wait-for-infrastructure-dependencies" (dict "context" . "component" "els") | indent 8 }}
4545
containers:
4646
- name: {{ .Chart.Name }}-els
4747
securityContext:

charts/featbit/templates/mongodb-init-scripts-configmap.yaml

Lines changed: 110 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ metadata:
99
annotations:
1010
{{- include "featbit-metadata-annotations-common" . | nindent 4 }}
1111
data:
12-
init.js: |-
13-
const dbName = "featbit";
12+
{{- $db := (include "featbit.mongodb.db" .) }}
13+
01_init.js: |-
14+
const dbName = "{{ $db }}";
1415
print('use', dbName, 'database')
1516
db = db.getSiblingDB(dbName)
1617
@@ -266,16 +267,112 @@ data:
266267
267268
// add indexes
268269
print('add indexes...')
269-
db.AuditLogs.createIndex({ createdAt: 1 });
270-
db.EndUsers.createIndex({ updatedAt: 1 });
271-
db.ExperimentMetrics.createIndex({ updatedAt: 1 });
272-
db.FeatureFlags.createIndex({ updatedAt: 1 });
273-
db.Segments.createIndex({ updatedAt: 1 });
274-
db.AccessTokens.createIndex({ createdAt: 1 });
275-
db.Policies.createIndex({ createdAt: 1 });
276-
db.Projects.createIndex({ createdAt: 1 });
277-
db.RelayProxies.createIndex({ createdAt: 1 });
278-
db.Webhooks.createIndex({ createdAt: 1 });
279-
db.Webhooks.createIndex({ startedAt: 1 });
270+
db.AuditLogs.createIndex({createdAt: 1});
271+
272+
db.EndUsers.createIndex({envId: 1, keyId: 1});
273+
db.EndUsers.createIndex({updatedAt: 1});
274+
275+
db.ExperimentMetrics.createIndex({updatedAt: 1});
276+
db.FeatureFlags.createIndex({updatedAt: 1});
277+
db.Segments.createIndex({updatedAt: 1});
278+
db.AccessTokens.createIndex({createdAt: 1});
279+
db.Policies.createIndex({createdAt: 1});
280+
db.Projects.createIndex({createdAt: 1});
281+
db.RelayProxies.createIndex({createdAt: 1});
282+
db.Webhooks.createIndex({createdAt: 1});
283+
db.Webhooks.createIndex({startedAt: 1});
280284
print('indexes added')
285+
02_update_admin_policies_workspace_perm.js: |-
286+
const dbName = "{{ $db }}";
287+
print('use', dbName, 'database')
288+
db = db.getSiblingDB(dbName)
289+
290+
db.Policies.updateOne(
291+
{
292+
_id: UUID("3e961f0f-6fd4-4cf4-910f-52d356f8cc08"),
293+
"statements.resourceType": { $ne: "workspace" }
294+
},
295+
{
296+
$push: {
297+
statements: {
298+
_id: "7a910fbd-9463-4563-af72-fa977d34fdb2",
299+
resourceType: "workspace",
300+
effect: "allow",
301+
actions: [
302+
"UpdateWorkspaceGeneralSettings",
303+
"UpdateWorkspaceLicense",
304+
"UpdateWorkspaceSSOSettings"
305+
],
306+
resources: ["workspace/*"]
307+
}
308+
}
309+
}
310+
);
311+
03_update_admin_policies_new_CreateOrg_perm.js: |-
312+
const dbName = "{{ $db }}";
313+
print('use', dbName, 'database')
314+
db = db.getSiblingDB(dbName)
315+
316+
const administratorPolicyId = UUID("3e961f0f-6fd4-4cf4-910f-52d356f8cc08")
317+
318+
function getUUIDString() {
319+
return UUID().toString().split('"')[1];
320+
}
321+
322+
const newStatement = {
323+
_id: getUUIDString(),
324+
resourceType: "organization",
325+
effect: "allow",
326+
actions: [
327+
"UpdateOrgName",
328+
"UpdateOrgDefaultUserPermissions",
329+
"CreateOrg"
330+
],
331+
resources: ["organization/*"]
332+
};
333+
334+
db.Policies.updateOne(
335+
{ _id: administratorPolicyId },
336+
{ $pull: { statements: { resourceType: "organization" } } }
337+
);
338+
339+
db.Policies.updateOne(
340+
{ _id: administratorPolicyId },
341+
{ $push: { statements: newStatement } }
342+
);
343+
04_update_proxy_policies_auto_agents.js: |-
344+
const dbName = "{{ $db }}";
345+
print('use', dbName, 'database')
346+
db = db.getSiblingDB(dbName)
347+
348+
db.RelayProxies.updateMany(
349+
{},
350+
{ $set: { autoAgents: [] } }
351+
);
352+
353+
const bulkOps = [];
354+
355+
const relayProxies = db.RelayProxies.find(
356+
{ scopes: { $exists: true, $ne: null } },
357+
{ _id: 1, scopes: 1 }
358+
).toArray();
359+
360+
relayProxies.forEach(proxy => {
361+
if (proxy.scopes && Array.isArray(proxy.scopes)) {
362+
const flattenedEnvIds = proxy.scopes.flatMap(scope =>
363+
scope && scope.envIds ? scope.envIds.map(envId => envId.toString()) : []
364+
);
365+
366+
bulkOps.push({
367+
updateOne: {
368+
filter: { _id: proxy._id },
369+
update: { $set: { scopes: flattenedEnvIds } }
370+
}
371+
});
372+
}
373+
});
374+
375+
if (bulkOps.length > 0) {
376+
db.RelayProxies.bulkWrite(bulkOps, { ordered: false });
377+
}
281378
{{- end -}}

0 commit comments

Comments
 (0)