Skip to content

Commit

Permalink
Add grpc health service.
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Nelson <minelson@vmware.com>
  • Loading branch information
absoludity committed Aug 14, 2023
1 parent 6aa5832 commit f928705
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
3 changes: 3 additions & 0 deletions chart/kubeapps/templates/kubeappsapis/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ spec:
env:
- name: OCI_CATALOG_PORT
value: {{ .Values.ociCatalog.containerPorts.http | quote }}
- name: RUST_LOG
# Use info,pinniped_proxy::pinniped=debug for module control.
value: info
{{- if .Values.ociCatalog.extraEnvVars }}
{{- include "common.tplvalues.render" (dict "value" .Values.ociCatalog.extraEnvVars "context" $) | nindent 12 }}
{{- end }}
Expand Down
36 changes: 36 additions & 0 deletions cmd/oci-catalog/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/oci-catalog/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ serde_json = "1.0"
tokio = { version = "1.30", features = ["macros", "rt-multi-thread"] }
tokio-stream = "0.1"
tonic = "0.9"
tonic-health = "0.9.2"
url = "2.4"

[build-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions cmd/oci-catalog/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = ([0, 0, 0, 0], opt.port).into();
let kubeapps_oci_catalog = KubeappsOCICatalog::default();

let (mut _health_reporter, health_service) = tonic_health::server::health_reporter();
// TODO(absoludity): Need to implement a decent check for the actual service
// that won't kill us with request quotas. See
// https://github.com/hyperium/tonic/blob/master/examples/src/health/server.rs
// for an example setup.

let server = Server::builder()
.add_service(OciCatalogServer::new(kubeapps_oci_catalog))
.add_service(health_service)
.serve(addr);
log::info!("listening for gRPC requests at {}", addr);
server.await.expect("unexpected error while serving");
Expand Down

0 comments on commit f928705

Please sign in to comment.