-
Notifications
You must be signed in to change notification settings - Fork 17
feat: support postgres mtls #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -90,6 +90,7 @@ spec: | |
| {{- else }} | ||
| {{- toYaml .Values.coderd.securityContext | nindent 12 }} | ||
| {{- end }} | ||
| {{- include "coder.volumeMounts" . | indent 10 }} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How did this work before?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It didn't need volume mounts before. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, I would've thought we'd need volume mounts for TLS certs and stuff 🤷♂️ |
||
| {{- end }} | ||
| containers: | ||
| - name: {{ include "coder.serviceName" . }} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| package tests | ||
|
|
||
| import ( | ||
| "path" | ||
| "strings" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| corev1 "k8s.io/api/core/v1" | ||
| "k8s.io/utils/pointer" | ||
| ) | ||
|
|
||
| func TestPgSSL(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| var ( | ||
| secretName = pointer.String("pg-certs") | ||
| pgval = &PostgresValues{ | ||
| Default: &PostgresDefaultValues{Enable: pointer.Bool(false)}, | ||
| Host: pointer.String("1.1.1.1"), | ||
| Port: pointer.String("5432"), | ||
| User: pointer.String("postgres"), | ||
| Database: pointer.String("postgres"), | ||
| PasswordSecret: pointer.String("pg-pass"), | ||
| SSLMode: pointer.String("require"), | ||
| SSL: &PostgresSSLValues{ | ||
| CertSecret: &CertsSecretValues{ | ||
| Name: secretName, | ||
| Key: pointer.String("cert"), | ||
| }, | ||
| KeySecret: &CertsSecretValues{ | ||
| Name: secretName, | ||
| Key: pointer.String("key"), | ||
| }, | ||
| RootCertSecret: &CertsSecretValues{ | ||
| Name: secretName, | ||
| Key: pointer.String("rootcert"), | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| objs = LoadChart(t).MustRender(t, func(cv *CoderValues) { cv.Postgres = pgval }) | ||
| coderd = MustFindDeployment(t, objs, "coderd") | ||
| ) | ||
|
|
||
| for _, vol := range []string{"pgcert", "pgkey", "pgrootcert"} { | ||
| AssertVolume(t, coderd.Spec.Template.Spec.Volumes, vol, func(t testing.TB, v corev1.Volume) { | ||
| require.NotNilf(t, v.Secret, "secret nil for %q", vol) | ||
| assert.Equalf(t, "pg-certs", v.Secret.SecretName, "secret name incorrect for %q", vol) | ||
| }) | ||
| } | ||
|
|
||
| for _, cnt := range []string{"migrations", "coderd"} { | ||
| // Combine both init and regular containers. | ||
| cnts := append(coderd.Spec.Template.Spec.InitContainers, coderd.Spec.Template.Spec.Containers...) | ||
|
|
||
| AssertContainer(t, cnts, cnt, func(t testing.TB, c corev1.Container) { | ||
| for _, vol := range []string{"pgcert", "pgkey", "pgrootcert"} { | ||
| AssertVolumeMount(t, c.VolumeMounts, vol, func(t testing.TB, v corev1.VolumeMount) { | ||
| assert.Equalf(t, vol, v.Name, "volume mount name incorrect for %q", vol) | ||
| assert.Truef(t, v.ReadOnly, "readonly incorrect for %q", vol) | ||
| assert.Equalf(t, path.Join("/etc/ssl/certs/pg/", strings.TrimPrefix(v.Name, "pg")), v.MountPath, "mount path incorrect for %q", vol) | ||
| }) | ||
| } | ||
| }) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.