Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ This field contains Restate-specific configuration.
|---|---|---|
| `register` | `object` | **Required**. The location of the Restate Admin API to register this deployment against. See details below. |
| `servicePath` | `string` | Optional path to append to the Service url when registering with Restate. |
| `useHttp11` | `boolean` | Force the use of HTTP/1.1 when registering with Restate. Defaults to HTTP/2 if not specified. |


The `register` field must specify exactly one of `cluster`, `service`, or `url`.

Expand Down
3 changes: 3 additions & 0 deletions crd/RestateDeployment.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Restate {
/// Optional path to append to the Service url when registering with Restate. If not provided, the
/// service will be registered at the root path "/".
servicePath: String?

/// Force the use of HTTP/1.1 when registering with Restate
useHttp11: Boolean?
}

/// The location of the Restate Admin API to register this deployment against
Expand Down
4 changes: 4 additions & 0 deletions crd/restatedeployments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ spec:
description: Optional path to append to the Service url when registering with Restate. If not provided, the service will be registered at the root path "/".
nullable: true
type: string
useHttp11:
description: Force the use of HTTP/1.1 when registering with Restate
nullable: true
type: boolean
required:
- register
type: object
Expand Down
14 changes: 11 additions & 3 deletions src/controllers/restatedeployment/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ impl RestateDeployment {
&ctx.http_client,
&admin_endpoint,
&service_endpoint,
self.spec.restate.use_http11.as_ref().cloned(),
)
.await?;
// if registration succeeded, treat this as an active endpoint
Expand Down Expand Up @@ -492,6 +493,7 @@ impl RestateDeployment {
client: &reqwest::Client,
admin_endpoint: &Url,
service_endpoint: &Url,
use_http11: Option<bool>,
) -> Result<String> {
debug!("Registering endpoint '{service_endpoint}' to Restate at '{admin_endpoint}'",);

Expand All @@ -500,11 +502,17 @@ impl RestateDeployment {
id: String,
}

let mut payload = serde_json::json!({
"uri": service_endpoint,
});

if let Some(use_http11) = use_http11 {
payload["use_http_11"] = serde_json::Value::Bool(use_http11);
}

let resp: DeploymentResponse = client
.post(admin_endpoint.join("/deployments")?)
.json(&serde_json::json!({
"uri": service_endpoint,
}))
.json(&payload)
.send()
.await
.map_err(Error::AdminCallFailed)?
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/restatedeployment/reconcilers/replicaset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ pub fn generate_pod_template_hash(rsd: &RestateDeployment, pod_template: &str) -
hasher.write(service_path.as_bytes());
}

// It's possible that changing this flag will create a new deployment id; by making it part of the replicaset name we guarantee that deployments and replicasets stay 1:1
if let Some(true) = rsd.spec.restate.use_http11 {
hasher.write(b"use_http11");
}
if let Some(collision_count) = rsd.status.as_ref().and_then(|s| s.collision_count) {
hasher.write(&collision_count.to_be_bytes());
}
Expand Down
4 changes: 4 additions & 0 deletions src/resources/restatedeployments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ pub struct RestateSpec {
/// If not provided, the service will be registered at the root path "/".
#[serde(skip_serializing_if = "Option::is_none")]
pub service_path: Option<String>,

/// Force the use of HTTP/1.1 when registering with Restate
#[serde(skip_serializing_if = "Option::is_none")]
pub use_http11: Option<bool>,
}

/// The location of the Restate Admin API to register this deployment against
Expand Down