wip: public postgres many fixes and refactoring to have a more cohesive routing management
Some checks failed
Run Check Script / check (pull_request) Failing after 41s
Some checks failed
Run Check Script / check (pull_request) Failing after 41s
This commit is contained in:
34
examples/public_postgres/src/main.rs
Normal file
34
examples/public_postgres/src/main.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use harmony::{
|
||||
inventory::Inventory,
|
||||
modules::{network::TlsPassthroughScore, postgresql::PostgreSQLScore},
|
||||
topology::{K8sAnywhereTopology, TlsRoute},
|
||||
};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let namespace = "harmony-postgres-example".to_string();
|
||||
let postgresql = PostgreSQLScore {
|
||||
name: "harmony-postgres-example".to_string(), // Override default name
|
||||
namespace: namespace.clone(),
|
||||
..Default::default() // Use harmony defaults, they are based on CNPG's default values :
|
||||
// "default" namespace, 1 instance, 1Gi storage
|
||||
};
|
||||
|
||||
let tls_passthrough = TlsPassthroughScore {
|
||||
route: TlsRoute {
|
||||
hostname: "postgres.example.com".to_string(), // CNPG creates a -rw service for read-write endpoint
|
||||
backend: format!("{}-rw", postgresql.name), // Public hostname for TLS SNI
|
||||
namespace: namespace.clone(),
|
||||
target_port: 5432, // PostgreSQL default port
|
||||
},
|
||||
};
|
||||
|
||||
harmony_cli::run(
|
||||
Inventory::autoload(),
|
||||
K8sAnywhereTopology::from_env(),
|
||||
vec![Box::new(postgresql), Box::new(tls_passthrough)],
|
||||
None,
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user