@@ -46,13 +46,15 @@ use strum::{Display, EnumDiscriminants, EnumIter, EnumString, IntoStaticStr};
4646use crate :: crd:: {
4747 affinity:: get_affinity,
4848 authorization:: DruidAuthorization ,
49+ database:: MetadataDatabaseConnection ,
4950 resource:: RoleResource ,
5051 tls:: { DruidTls , default_druid_tls} ,
5152} ;
5253
5354pub mod affinity;
5455pub mod authentication;
5556pub mod authorization;
57+ pub mod database;
5658pub mod memory;
5759pub mod resource;
5860pub mod security;
@@ -109,21 +111,12 @@ pub const AUTH_AUTHORIZERS_VALUE: &str = "[\"OpaAuthorizer\"]";
109111pub const AUTH_AUTHORIZER_OPA_TYPE : & str = "druid.auth.authorizer.OpaAuthorizer.type" ;
110112pub const AUTH_AUTHORIZER_OPA_TYPE_VALUE : & str = "opa" ;
111113pub const AUTH_AUTHORIZER_OPA_URI : & str = "druid.auth.authorizer.OpaAuthorizer.opaUri" ;
112- // metadata storage config properties
113- const METADATA_STORAGE_TYPE : & str = "druid.metadata.storage.type" ;
114- const METADATA_STORAGE_URI : & str = "druid.metadata.storage.connector.connectURI" ;
115- const METADATA_STORAGE_HOST : & str = "druid.metadata.storage.connector.host" ;
116- const METADATA_STORAGE_PORT : & str = "druid.metadata.storage.connector.port" ;
117- const METADATA_STORAGE_USER : & str = "druid.metadata.storage.connector.user" ;
118- const METADATA_STORAGE_PASSWORD : & str = "druid.metadata.storage.connector.password" ;
119114// indexer properties
120115pub const INDEXER_JAVA_OPTS : & str = "druid.indexer.runner.javaOptsArray" ;
121116// historical settings
122117pub const PROCESSING_BUFFER_SIZE_BYTES : & str = "druid.processing.buffer.sizeBytes" ;
123118pub const PROCESSING_NUM_MERGE_BUFFERS : & str = "druid.processing.numMergeBuffers" ;
124119pub const PROCESSING_NUM_THREADS : & str = "druid.processing.numThreads" ;
125- // extra
126- pub const CREDENTIALS_SECRET_PROPERTY : & str = "credentialsSecret" ;
127120// logs
128121pub const MAX_DRUID_LOG_FILES_SIZE : MemoryQuantity = MemoryQuantity {
129122 value : 10.0 ,
@@ -136,10 +129,6 @@ pub const METRICS_PORT: u16 = 9090;
136129
137130pub const COOKIE_PASSPHRASE_ENV : & str = "OIDC_COOKIE_PASSPHRASE" ;
138131
139- // DB credentials - both of these are read from an env var by Druid with the ${env:...} syntax
140- pub const DB_USERNAME_ENV : & str = "DB_USERNAME_ENV" ;
141- pub const DB_PASSWORD_ENV : & str = "DB_PASSWORD_ENV" ;
142-
143132// Graceful shutdown timeouts
144133const DEFAULT_BROKER_GRACEFUL_SHUTDOWN_TIMEOUT : Duration = Duration :: from_minutes_unchecked ( 5 ) ;
145134const DEFAULT_COORDINATOR_GRACEFUL_SHUTDOWN_TIMEOUT : Duration = Duration :: from_minutes_unchecked ( 5 ) ;
@@ -361,7 +350,7 @@ pub mod versioned {
361350 pub ingestion : Option < IngestionSpec > ,
362351
363352 /// Druid requires an SQL database to store metadata into. Specify connection information here.
364- pub metadata_storage_database : DatabaseConnectionSpec ,
353+ pub metadata_database : MetadataDatabaseConnection ,
365354
366355 /// TLS encryption settings for Druid, more information in the
367356 /// [security documentation](DOCS_BASE_URL_PLACEHOLDER/druid/usage-guide/security).
@@ -420,34 +409,6 @@ impl v1alpha1::DruidCluster {
420409 match file {
421410 JVM_CONFIG => { }
422411 RUNTIME_PROPS => {
423- let mds = & self . spec . cluster_config . metadata_storage_database ;
424- result. insert (
425- METADATA_STORAGE_TYPE . to_string ( ) ,
426- Some ( mds. db_type . to_string ( ) ) ,
427- ) ;
428- result. insert (
429- METADATA_STORAGE_URI . to_string ( ) ,
430- Some ( mds. conn_string . to_string ( ) ) ,
431- ) ;
432- result. insert (
433- METADATA_STORAGE_HOST . to_string ( ) ,
434- Some ( mds. host . to_string ( ) ) ,
435- ) ;
436- result. insert (
437- METADATA_STORAGE_PORT . to_string ( ) ,
438- Some ( mds. port . to_string ( ) ) ,
439- ) ;
440- if mds. credentials_secret . is_some ( ) {
441- result. insert (
442- METADATA_STORAGE_USER . to_string ( ) ,
443- Some ( format ! ( "${{env:{DB_USERNAME_ENV}}}" ) ) ,
444- ) ;
445- result. insert (
446- METADATA_STORAGE_PASSWORD . to_string ( ) ,
447- Some ( format ! ( "${{env:{DB_PASSWORD_ENV}}}" ) ) ,
448- ) ;
449- }
450-
451412 // OPA
452413 if let Some ( DruidAuthorization { opa : _ } ) = & self . spec . cluster_config . authorization
453414 {
@@ -1155,43 +1116,6 @@ impl DruidRole {
11551116 }
11561117}
11571118
1158- #[ derive( Clone , Debug , Default , Deserialize , JsonSchema , Serialize ) ]
1159- #[ serde( rename_all = "camelCase" ) ]
1160- pub struct DatabaseConnectionSpec {
1161- /// The database type. Supported values are: `derby`, `mysql` and `postgres`.
1162- /// Note that a Derby database created locally in the container is not persisted!
1163- /// Derby is not suitable for production use.
1164- pub db_type : DbType ,
1165- /// The connect string for the database, for Postgres this could look like:
1166- /// `jdbc:postgresql://postgresql-druid/druid`
1167- pub conn_string : String ,
1168- /// The host, i.e. `postgresql-druid`.
1169- pub host : String ,
1170- /// The port, i.e. 5432
1171- pub port : u16 ,
1172- /// A reference to a Secret containing the database credentials.
1173- /// The Secret needs to contain the keys `username` and `password`.
1174- pub credentials_secret : Option < String > ,
1175- }
1176-
1177- #[ derive(
1178- Clone , Debug , Default , Deserialize , Eq , JsonSchema , PartialEq , Serialize , Display , EnumString ,
1179- ) ]
1180- pub enum DbType {
1181- #[ serde( rename = "derby" ) ]
1182- #[ strum( serialize = "derby" ) ]
1183- #[ default]
1184- Derby ,
1185-
1186- #[ serde( rename = "mysql" ) ]
1187- #[ strum( serialize = "mysql" ) ]
1188- Mysql ,
1189-
1190- #[ serde( rename = "postgresql" ) ]
1191- #[ strum( serialize = "postgresql" ) ]
1192- Postgresql ,
1193- }
1194-
11951119#[ derive( Clone , Debug , Deserialize , JsonSchema , PartialEq , Eq , Serialize , Display ) ]
11961120#[ serde( rename_all = "camelCase" ) ]
11971121pub enum DeepStorageSpec {
0 commit comments