From 871faf649e23189a39e3b58453a7bb58e379682b Mon Sep 17 00:00:00 2001 From: mikutas <23391543+mikutas@users.noreply.github.com> Date: Wed, 4 Dec 2024 18:31:54 +0900 Subject: [PATCH] add health check --- helm/greeter/values.yaml | 10 ++++------ main.go | 4 ++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/helm/greeter/values.yaml b/helm/greeter/values.yaml index a35d854..989d6c7 100644 --- a/helm/greeter/values.yaml +++ b/helm/greeter/values.yaml @@ -88,13 +88,11 @@ resources: {} # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ livenessProbe: - httpGet: - path: / - port: http + grpc: + port: 50051 readinessProbe: - httpGet: - path: / - port: http + grpc: + port: 50051 #This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ autoscaling: diff --git a/main.go b/main.go index 0fabd75..0324378 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,8 @@ import ( "google.golang.org/grpc" pb "google.golang.org/grpc/examples/helloworld/helloworld" + "google.golang.org/grpc/health" + healthgrpc "google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/reflection" ) @@ -51,6 +53,8 @@ func main() { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() + hc := health.NewServer() + healthgrpc.RegisterHealthServer(s, hc) pb.RegisterGreeterServer(s, &server{}) reflection.Register(s) if err := s.Serve(lis); err != nil {