diff --git a/dstack/crates/dstack-cli-core/src/config.rs b/dstack/crates/dstack-cli-core/src/config.rs index d2f832bce..d416279e1 100644 --- a/dstack/crates/dstack-cli-core/src/config.rs +++ b/dstack/crates/dstack-cli-core/src/config.rs @@ -123,16 +123,29 @@ pub fn kms_toml(cfg: &HostConfig) -> String { format!( r#"# generated by `dstackup install` — single-node KMS -[rpc] +[listeners.default.tls] +key = "/kms/certs/rpc.key" +certs = "/kms/certs/rpc.crt" + +[listeners.guest] address = "0.0.0.0" port = 8000 -[rpc.tls] -key = "/kms/certs/rpc.key" -certs = "/kms/certs/rpc.crt" +# the key handover path a serving KMS requires; the token stays on the host. +[listeners.admin] +enabled = true +address = "127.0.0.1" +port = 8001 +auth_token_hash = "{admin_token_hash}" + +[listeners.onboard] +address = "0.0.0.0" +port = 8000 [core] cert_dir = "/kms/certs" +# the root keys of every epoch; on the persistent kms-volume. +keyring_dir = "/kms/keyring" # single-node: the KMS does not self-attest to its own auth API before # bootstrap (it still attests the genesis keys via the guest agent, and app # auth + per-app quote checks are unaffected). @@ -152,22 +165,9 @@ type = "webhook" [core.auth_api.webhook] url = "{webhook_url}" -# the key handover path a serving KMS requires; the token stays on the host. -[core.admin] -enabled = true -address = "127.0.0.1" -port = 8001 -auth_token_hash = "{admin_token_hash}" - -[core.admin.tls] -key = "/kms/certs/rpc.key" -certs = "/kms/certs/rpc.crt" - [core.onboard] enabled = true auto_bootstrap_domain = "{bootstrap_domain}" -address = "0.0.0.0" -port = 8000 "#, // AMD SEV-SNP gates EVERY key release (incl. the KMS's own bootstrap) on // `sev_snp_key_release`, which defaults to false — so it must be set on @@ -207,8 +207,8 @@ pub fn auth_allowlist_json(cfg: &HostConfig) -> String { } /// default reproducibly-built KMS image, digest-pinned since it is measured into the -/// compose hash. -pub const DEFAULT_KMS_IMAGE: &str = "dstacktee/dstack-kms:0.5.11@sha256:84b793feed825a5b5e70d04386e931e0e110461492793f17ab2128e39808d989"; +/// compose hash. It has to read the `[listeners.*]` layout `kms_toml` renders. +pub const DEFAULT_KMS_IMAGE: &str = "ghcr.io/dstack-tee/dstack-kms:0.6.7@sha256:693b7c80bad6f759a17f3cc62503eb1ef768852527d448dcfbbb9edb3e8f99f3"; /// Build the KMS app-compose manifest with an embedded `kms.toml` init script. /// Select SGX local provisioning on TDX and native SNP provisioning on AMD. @@ -502,14 +502,27 @@ mod tests { let toml = kms_toml(&cfg); assert!(toml.contains("enforce_self_authorization = false")); let v: toml::Value = toml::from_str(&toml).unwrap(); - let admin = &v["core"]["admin"]; + // the 0.6 KMS refuses to start on listener settings at their old + // locations: [rpc], [core.admin], core.onboard.address/port. + let top: Vec<&String> = v.as_table().unwrap().keys().collect(); + assert_eq!(top, ["core", "listeners"]); + assert!(v["core"].get("admin").is_none()); + assert!(v["core"]["onboard"].get("address").is_none()); + assert!(v["core"]["onboard"].get("port").is_none()); + let listeners = &v["listeners"]; + assert_eq!(listeners["guest"]["port"].as_integer(), Some(8000)); + let admin = &listeners["admin"]; assert_eq!(admin["enabled"].as_bool(), Some(true)); + assert_eq!(admin["address"].as_str(), Some("127.0.0.1")); assert_eq!( admin["auth_token_hash"].as_str(), Some("ab".repeat(32).as_str()) ); - assert_eq!(admin["tls"]["key"].as_str(), Some("/kms/certs/rpc.key")); - assert_eq!(admin["tls"]["certs"].as_str(), Some("/kms/certs/rpc.crt")); + let tls = &listeners["default"]["tls"]; + assert_eq!(tls["key"].as_str(), Some("/kms/certs/rpc.key")); + assert_eq!(tls["certs"].as_str(), Some("/kms/certs/rpc.crt")); + // keep the root keys on the persistent kms-volume instead of /var/lib/kms. + assert_eq!(v["core"]["keyring_dir"].as_str(), Some("/kms/keyring")); assert!(toml.contains(r#"auto_bootstrap_domain = "10.0.2.2""#)); assert!(toml.contains(r#"type = "webhook""#)); assert!(toml.contains(r#"url = "http://10.0.2.2:8001""#));