Skip to content

Commit

Permalink
Inject feature flags in the Helm chart deployments (#590)
Browse files Browse the repository at this point in the history
* Inject feature flags in needed deployments

* Add feature-flags file

* Inject FFs file in workspace-api

* Fix

* New fix

* Fix volume

* Fix

* Add file in all needed backend services

* Mount in workspace-wwww

* Change workspace www image and add env var

* Fix

* Allow overriding featureFlags

* Try fix

* Redeploy if FFs change

* Change checksum name

* Last change

* Fix
  • Loading branch information
moicalcob authored Aug 6, 2024
1 parent 693087a commit 757a194
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 6 deletions.
1 change: 1 addition & 0 deletions chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ To install, upgrade or uninstall this chart, please refer to [the root README.md
| `cartoConfigValues.dataObservatoryProjectId` | GCP project ID of the Carto Data Observatory. | `""` |
| `cartoConfigValues.ingressTestingMode` | Enable router testing mode for the application. This will deploy the router in testing mode serving a simple page to check that it works without routing traffic to other components. | `false` |
| `cartoConfigValues.onlyRunRouter` | Enable only the router component in the installation. This will just deploy the router component. Useful to check the ingress layer together with the option `cartoConfigValues.ingressTestingMode`. | `false` |
| `cartoConfigValues.featureFlagsOverrides` | YAML configuration for overriding feature flags. | `[]` |

### App secret

Expand Down
109 changes: 109 additions & 0 deletions chart/feature-flags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
featureFlags:
- name: 2023-builder-hex-code
value: true
- name: 2023-builder-map-explain-public-title
value: true
- name: 2023-builder-map-explain-rich-description
value: true
- name: 2023-builder-map-explain-widget-notes
value: true
- name: 2023-builder-pie-widget
value: true
- name: 2023-cartodw-direct-access
value: true
- name: 2023-custom-schema-imports
value: true
- name: 2023-enable-sharing-apps
value: true
- name: 2023-export-do-subscriptions-from-workspace
value: true
- name: 2023-map-sso-groups-to-roles
value: true
- name: 2023-measure-tool-builder
value: true
- name: 2023-oauth-for-snowflake
value: true
- name: 2023-row-level-security-bq-oauth
value: true
- name: 2023-search-location-by-coordinates
value: true
- name: 2023-server-side-export
value: true
- name: 2023-sql-params-numeric
value: true
- name: 2023-timeseries-improve-multi-and-split
value: true
- name: 2023-timeseries-improve-precision
value: true
- name: 2023-whitelabel-branding
value: true
- name: 2023-workflows-at-home-page
value: true
- name: 2023-workflows-data-export
value: true
- name: 2023-workflows-do
value: true
- name: 2023-workflows-enrichment
value: true
- name: 2023-workflows-export
value: true
- name: 2023-workflows-export-ii
value: true
- name: 2023-workflows-import
value: true
- name: 2023-workflows-scheduling
value: true
- name: 2024-catalog-workflow-templates
value: true
- name: 2024-custom-basemaps
value: true
- name: 2024-databricks-rest-connection-enabled
value: true
- name: 2024-deliver-raw-audit-logs
value: false
- name: 2024-heatmap-aggregation-in-builder
value: true
- name: 2024-query-concurrency-control
value: true
- name: 2024-reduce-number-of-queries
value: true
- name: 2024-tags-for-resources
value: true
- name: 2024-workflows-package-extension
value: false
- name: 2024-workflows-raster-components
value: true
- name: 2024-zoom-to-layer-in-builder
value: true
- name: dynamic-tiling-v-2
value: true
- name: frontend-2022-collaborative-maps
value: true
- name: frontend-2022-enable-postgres-import
value: true
- name: frontend-2022-enable-redshift-import-after-bucket-configuration
value: true
- name: frontend-2022-help-sidebar
value: true
- name: frontend-2022-new-mini-data-explorer
value: true
- name: frontend-2022-workflows
value: true
- name: frontend-2023-connections-with-viewer-credentials
value: true
- name: frontend-2023-enterprise-sso-just-in-time-provisioning
value: true
- name: frontend-2023-new-developer-ui-for-tokens
value: true
- name: frontend-2023-run-table-optimization-from-ui
value: true
- name: frontend-2023-workflows-all-providers
value: true
- name: frontend-2023-workflows-on-homepage
value: true
- name: frontend-2023-workflows-sharing
value: true
- name: 2024-deprecate-create-tileset-from-dataexplorer-ui
value: '2024-07-22T00:00:00.000Z'
- name: 2024-deprecate-enrich-table-from-dataexplorer-ui
value: '2024-04-04T00:00:00.000Z'
14 changes: 14 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -1400,3 +1400,17 @@ Return the absolute path where the proxy CA cert will be mounted
{{- define "carto.proxy.configMapMountAbsolutePath" -}}
{{- printf "%s/%s" (include "carto.proxy.configMapMountDir" .) (include "carto.proxy.configMapMountFilename" .) -}}
{{- end -}}

{{/*
Get the feature flags config map name
*/}}
{{- define "carto.featureFlags.configMapName" -}}
{{- printf "%s-%s" .Release.Name "featureflags" -}}
{{- end -}}

{{/*
Return the directory where the feature flags config file will be mounted
*/}}
{{- define "carto.featureFlags.configMapMountDir" -}}
{{- print "/tmp/feature-flags.yaml" -}}
{{- end -}}
19 changes: 19 additions & 0 deletions chart/templates/feature-flags-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "carto.featureFlags.configMapName" . }}
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
namespace: {{ .Release.Namespace | quote }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
data:
feature-flags.yaml: |-
{{ .Files.Get "feature-flags.yaml" | indent 4 }}
{{- if .Values.cartoConfigValues.featureFlagsOverrides }}
featureFlagsOverrides:
{{ .Values.cartoConfigValues.featureFlagsOverrides | toYaml | indent 6 }}
{{- end }}
11 changes: 11 additions & 0 deletions chart/templates/maps-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/maps-api/configmap.yaml") . | sha256sum }}
checksum/feature-flags-config: {{ include (print $.Template.BasePath "/feature-flags-configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/maps-api/secret.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- if .Values.mapsApi.podAnnotations }}
Expand Down Expand Up @@ -207,6 +208,10 @@ spec:
mountPath: {{ include "carto.proxy.configMapMountDir" . }}
readOnly: true
{{- end }}
- name: feature-flags
mountPath: {{ include "carto.featureFlags.configMapMountDir" . }}
subPath: feature-flags.yaml
readOnly: true
{{- if .Values.mapsApi.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.mapsApi.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -243,6 +248,12 @@ spec:
configMap:
name: {{ include "carto.proxy.configMapName" . }}
{{- end }}
- name: feature-flags
configMap:
name: {{ template "carto.featureFlags.configMapName" . }}
items:
- key: feature-flags.yaml
path: feature-flags.yaml
{{- if .Values.mapsApi.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.mapsApi.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
11 changes: 11 additions & 0 deletions chart/templates/sql-worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/sql-worker/configmap.yaml") . | sha256sum }}
checksum/feature-flags-config: {{ include (print $.Template.BasePath "/feature-flags-configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/sql-worker/secret.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- if .Values.sqlWorker.podAnnotations }}
Expand Down Expand Up @@ -178,6 +179,10 @@ spec:
mountPath: {{ include "carto.proxy.configMapMountDir" . }}
readOnly: true
{{- end }}
- name: feature-flags
mountPath: {{ include "carto.featureFlags.configMapMountDir" . }}
subPath: feature-flags.yaml
readOnly: true
{{- if .Values.sqlWorker.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.sqlWorker.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -209,6 +214,12 @@ spec:
configMap:
name: {{ include "carto.proxy.configMapName" . }}
{{- end }}
- name: feature-flags
configMap:
name: {{ template "carto.featureFlags.configMapName" . }}
items:
- key: feature-flags.yaml
path: feature-flags.yaml
{{- if .Values.sqlWorker.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.sqlWorker.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
11 changes: 11 additions & 0 deletions chart/templates/workspace-api/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/workspace-api/configmap.yaml") . | sha256sum }}
checksum/feature-flags-config: {{ include (print $.Template.BasePath "/feature-flags-configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/workspace-api/secret.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- if .Values.workspaceApi.podAnnotations }}
Expand Down Expand Up @@ -293,6 +294,10 @@ spec:
mountPath: {{ include "carto.proxy.configMapMountDir" . }}
readOnly: true
{{- end }}
- name: feature-flags
mountPath: {{ include "carto.featureFlags.configMapMountDir" . }}
subPath: feature-flags.yaml
readOnly: true
{{- if .Values.workspaceApi.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceApi.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -329,6 +334,12 @@ spec:
configMap:
name: {{ include "carto.proxy.configMapName" . }}
{{- end }}
- name: feature-flags
configMap:
name: {{ template "carto.featureFlags.configMapName" . }}
items:
- key: feature-flags.yaml
path: feature-flags.yaml
{{- if .Values.workspaceApi.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceApi.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
11 changes: 11 additions & 0 deletions chart/templates/workspace-subscriber/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/workspace-subscriber/configmap.yaml") . | sha256sum }}
checksum/feature-flags-config: {{ include (print $.Template.BasePath "/feature-flags-configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/workspace-subscriber/secret.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- if .Values.workspaceSubscriber.podAnnotations }}
Expand Down Expand Up @@ -181,6 +182,10 @@ spec:
mountPath: {{ include "carto.proxy.configMapMountDir" . }}
readOnly: true
{{- end }}
- name: feature-flags
mountPath: {{ include "carto.featureFlags.configMapMountDir" . }}
subPath: feature-flags.yaml
readOnly: true
{{- if .Values.workspaceSubscriber.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceSubscriber.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand Down Expand Up @@ -209,6 +214,12 @@ spec:
configMap:
name: {{ include "carto.proxy.configMapName" . }}
{{- end }}
- name: feature-flags
configMap:
name: {{ template "carto.featureFlags.configMapName" . }}
items:
- key: feature-flags.yaml
path: feature-flags.yaml
{{- if .Values.workspaceSubscriber.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceSubscriber.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
1 change: 1 addition & 0 deletions chart/templates/workspace-www/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ metadata:
{{- end }}
data:
CARTO_DATA_WAREHOUSE_ENABLED: {{ .Values.cartoConfigValues.cartoDataWarehouseEnabled | quote }}
CARTO_FEATURE_FLAGS_FILE_PATH: {{ include "carto.featureFlags.configMapMountDir" . | quote }}
{{- if $.Values.appConfigValues.bigqueryOauth2ClientId }}
REACT_APP_BIGQUERY_OAUTH: "true"
{{- else }}
Expand Down
11 changes: 11 additions & 0 deletions chart/templates/workspace-www/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ spec:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/workspace-www/configmap.yaml") . | sha256sum }}
checksum/feature-flags-config: {{ include (print $.Template.BasePath "/feature-flags-configmap.yaml") . | sha256sum }}
checksum/secret: {{ include (print $.Template.BasePath "/workspace-www/secret.yaml") . | sha256sum }}
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
{{- if .Values.workspaceWww.podAnnotations }}
Expand Down Expand Up @@ -164,6 +165,10 @@ spec:
mountPath: /tmp
- name: nginx-shared-snippets
mountPath: /etc/nginx/conf.d/shared-snippets
- name: feature-flags
mountPath: {{ include "carto.featureFlags.configMapMountDir" . }}
subPath: feature-flags.yaml
readOnly: true
{{- if .Values.workspaceWww.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceWww.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
Expand All @@ -179,6 +184,12 @@ spec:
medium: Memory
- name: tmp
emptyDir: {}
- name: feature-flags
configMap:
name: {{ template "carto.featureFlags.configMapName" . }}
items:
- key: feature-flags.yaml
path: feature-flags.yaml
{{- if .Values.workspaceWww.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.workspaceWww.extraVolumes "context" $) | nindent 8 }}
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ cartoConfigValues:
ingressTestingMode: false
## @param cartoConfigValues.onlyRunRouter Enable only the router component in the installation. This will just deploy the router component. Useful to check the ingress layer together with the option `cartoConfigValues.ingressTestingMode`.
onlyRunRouter: false
## @param cartoConfigValues.featureFlagsOverrides YAML configuration for overriding feature flags.
featureFlagsOverrides: []

## @section App secret
## Global secrets to be edited by the client
Expand Down
13 changes: 7 additions & 6 deletions manifests/kots-helm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@ spec:
## Values from Advanced Configuration
optionalValues:
## TEMPORAL PATCHED IMAGED
# - when: 'true'
# recursiveMerge: true
# values:
# router:
# image:
# tag: "feature_sc_415629_add_ingress_debug_mode_in_carto_self_hosted"
- when: 'true'
recursiveMerge: true
values:
workspaceWww:
image:
registry: registry.self-hosted.carto.com/proxy/carto/gcr.io/carto-artifacts
tag: "feature_sc_431460_inject_the_default_value_and_the_overrides"

## Specify service account if workload identity is disabled
- when: '{{repl ConfigOptionEquals "enableGoogleWorkloadIdentity" "0" }}'
Expand Down

0 comments on commit 757a194

Please sign in to comment.