Skip to content

Commit

Permalink
fix: allow the pg container used to create the keycloak database to b…
Browse files Browse the repository at this point in the history
…e overriden (#13385)
  • Loading branch information
bgroff committed Aug 2, 2024
1 parent 6976bf9 commit e42711c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions charts/airbyte-keycloak/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ spec:
{{- if and (eq .Values.global.deploymentMode "oss") (ne .Values.bypassInit true)}}
# This init container will only executed if the deployment mode is "oss" and the bypassInit is not true.
- name: init-db
{{- if .Values.initContainers.initDb.image }}
image: {{ .Values.initContainers.initDb.image }}
{{- else }}
image: postgres:13-alpine
{{- end }}
command: [ "sh", "-c" ]
args:
- >
Expand Down
4 changes: 4 additions & 0 deletions charts/airbyte/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1731,6 +1731,10 @@ keycloak:
# gid=0(root)
fsGroup: 0

initContainers:
initDb:
image: {}

initContainerSecurityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
Expand Down
25 changes: 19 additions & 6 deletions charts/helm-tests/tests/enterprise_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func TestBasicEnterpriseConfigWithHelmValues(t *testing.T) {
})
}

func TestKeycloakSetupInitContainerOverride(t *testing.T) {
func TestKeycloakInitContainerOverride(t *testing.T) {
t.Run("default keycloak readiness image is curlimages/curl", func(t *testing.T) {
helmOpts := baseHelmOptionsForEnterpriseWithValues()
helmOpts.SetValues["global.auth.instanceAdmin.firstName"] = "Octavia"
Expand All @@ -260,8 +260,14 @@ func TestKeycloakSetupInitContainerOverride(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, keycloakSetupJob)

initContainers := keycloakSetupJob.Spec.Template.Spec.InitContainers
assert.Equal(t, "curlimages/curl:8.1.1", initContainers[0].Image)
keycloakStatefulSet, err := getStatefulSet(chartYaml, "airbyte-keycloak")
assert.NoError(t, err)
assert.NotNil(t, keycloakStatefulSet)

setupInitContainers := keycloakSetupJob.Spec.Template.Spec.InitContainers
keycloakInitContainers := keycloakStatefulSet.Spec.Template.Spec.InitContainers
assert.Equal(t, "curlimages/curl:8.1.1", setupInitContainers[0].Image)
assert.Equal(t, "postgres:13-alpine", keycloakInitContainers[0].Image)
})

t.Run("override init container image ", func(t *testing.T) {
Expand All @@ -275,14 +281,21 @@ func TestKeycloakSetupInitContainerOverride(t *testing.T) {
helmOpts.SetValues["global.auth.identityProvider.oidc.clientIdSecretKey"] = "client-id"
helmOpts.SetValues["global.auth.identityProvider.oidc.clientSecretSecretKey"] = "client-secret"
helmOpts.SetValues["keycloak-setup.initContainers.keycloakReadinessCheck.image"] = "airbyte/custom-curl-image"
helmOpts.SetValues["keycloak.initContainers.initDb.image"] = "airbyte/custom-postgres-image"
chartYaml, err := helm.RenderTemplateE(t, helmOpts, chartPath, "airbyte", nil)
assert.NoError(t, err)

keycloakSetupJob, err := getJob(chartYaml, "airbyte-keycloak-setup")
assert.NoError(t, err)
assert.NotNil(t, keycloakSetupJob)
assert.NoError(t, err)

keycloakStatefulSet, err := getStatefulSet(chartYaml, "airbyte-keycloak")
assert.NotNil(t, keycloakStatefulSet)
assert.NoError(t, err)

initContainers := keycloakSetupJob.Spec.Template.Spec.InitContainers
assert.Equal(t, "airbyte/custom-curl-image", initContainers[0].Image)
setupInitContainers := keycloakSetupJob.Spec.Template.Spec.InitContainers
keycloakInitContainers := keycloakStatefulSet.Spec.Template.Spec.InitContainers
assert.Equal(t, "airbyte/custom-curl-image", setupInitContainers[0].Image)
assert.Equal(t, "airbyte/custom-postgres-image", keycloakInitContainers[0].Image)
})
}

0 comments on commit e42711c

Please sign in to comment.