Skip to content

Commit 0cd3717

Browse files
committed
working TLS integration tests
1 parent 9c2158a commit 0cd3717

8 files changed

Lines changed: 1160 additions & 28 deletions

File tree

Cargo.lock

Lines changed: 127 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "postgres-operator"
3-
version = "0.1.1"
3+
version = "0.2.0"
44
edition = "2024"
55
rust-version = "1.92"
66
description = "A Kubernetes operator for managing PostgreSQL clusters"
@@ -56,7 +56,7 @@ tracing-subscriber = { version = "=0.3.22", default-features = false, features =
5656

5757
# HTTP server for health endpoints and metrics
5858
axum = { version = "=0.8.8", default-features = false, features = ["http1", "tokio", "json"] }
59-
axum-server = { version = "=0.7.3", default-features = false, features = ["tls-rustls-no-provider"] }
59+
axum-server = { version = "=0.8.0", default-features = false, features = ["tls-rustls-no-provider"] }
6060
prometheus-client = { version = "=0.24.0", default-features = false }
6161
rustls-pemfile = { version = "=2.2.0", default-features = false, features = ["std"] }
6262

@@ -81,7 +81,9 @@ hostname = { version = "=0.4.2", default-features = false }
8181

8282
[dev-dependencies]
8383
tokio-test = { version = "=0.4.5", default-features = false }
84-
tokio-postgres = { version = "=0.7.13", default-features = false, features = ["runtime"] }
84+
tokio-postgres = { version = "=0.7.15", default-features = false, features = ["runtime"] }
85+
tokio-postgres-rustls = { version = "=0.13.0", default-features = false }
86+
rustls-pki-types = { version = "=1.13.2", default-features = false, features = ["std"] }
8587
uuid = { version = "=1.19.0", default-features = false, features = ["v4"] }
8688
serde_yaml = { version = "=0.9.34", default-features = false }
8789
proptest = { version = "=1.9.0", default-features = false, features = ["std"] }

src/controller/reconciler.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,16 @@ async fn reconcile_cluster(cluster: &PostgresCluster, ctx: &Context, ns: &str) -
857857
if pgbouncer::is_pgbouncer_enabled(cluster) {
858858
info!("PgBouncer is enabled for cluster {}", name);
859859

860+
// Apply PgBouncer TLS certificate if TLS is enabled
861+
// This must be done before the deployment so the secret is ready
862+
if let Some(cert) = certificate::generate_pgbouncer_certificate(cluster) {
863+
apply_certificate(ctx, ns, &cert).await?;
864+
debug!(
865+
"Applied cert-manager Certificate for PgBouncer pooler {}",
866+
name
867+
);
868+
}
869+
860870
// Apply PgBouncer ConfigMap
861871
let pgbouncer_config = pgbouncer::generate_pgbouncer_configmap(cluster);
862872
apply_resource(ctx, ns, &pgbouncer_config).await?;
@@ -884,6 +894,15 @@ async fn reconcile_cluster(cluster: &PostgresCluster, ctx: &Context, ns: &str) -
884894
if pgbouncer::is_replica_pooler_enabled(cluster) {
885895
info!("Replica PgBouncer pooler is enabled for cluster {}", name);
886896

897+
// Apply replica PgBouncer TLS certificate if TLS is enabled
898+
if let Some(cert) = certificate::generate_pgbouncer_replica_certificate(cluster) {
899+
apply_certificate(ctx, ns, &cert).await?;
900+
debug!(
901+
"Applied cert-manager Certificate for PgBouncer replica pooler {}",
902+
name
903+
);
904+
}
905+
887906
let pgbouncer_replica_config = pgbouncer::generate_pgbouncer_replica_configmap(cluster);
888907
apply_resource(ctx, ns, &pgbouncer_replica_config).await?;
889908

0 commit comments

Comments
 (0)