diff --git a/deployment/terraform/reverse-proxy/main.tf b/deployment/terraform/reverse-proxy/main.tf
new file mode 100644
index 0000000..5282e48
--- /dev/null
+++ b/deployment/terraform/reverse-proxy/main.tf
@@ -0,0 +1,44 @@
+locals {
+ app_name = "blobs-http-reverse-proxy"
+ deployment_yaml_file_path = "${path.module}/templates/deployment.yaml"
+ count = "${var.reverse-proxy["enabled"]?1:0}"
+}
+
+data "template_file" "deployment_yaml" {
+ template = "${file("${local.deployment_yaml_file_path}")}"
+
+ vars {
+ app_name = "${local.app_name}"
+ node_selecter_label = "${var.node_selector_label}"
+ image = "expediadotcom/blobs-http-reverse-proxy:${var.reverse-proxy["version"]}"
+ replicas = "${var.reverse-proxy["proxy_instances"]}"
+ enabled = "${var.reverse-proxy["enabled"]}"
+ cpu_limit = "${var.reverse-proxy["proxy_cpu_limit"]}"
+ cpu_request = "${var.reverse-proxy["proxy_cpu_request"]}"
+ memory_limit = "${var.reverse-proxy["proxy_memory_limit"]}"
+ memory_request = "${var.reverse-proxy["proxy_memory_request"]}"
+ jvm_memory_limit = "${var.reverse-proxy["proxy_jvm_memory_limit"]}"
+ kubectl_context_name = "${var.kubectl_context_name}"
+ kubectl_executable_name = "${var.kubectl_executable_name}"
+ namespace = "${var.namespace}"
+ grpc_server_endpoint = "${var.reverse-proxy["grpc_server_endpoint"]}"
+ service_port = "${var.service_port}"
+ }
+}
+
+resource "null_resource" "reverseproxy_addon" {
+ triggers {
+ template = "${data.template_file.deployment_yaml.rendered}"
+ }
+
+ provisioner "local-exec" {
+ command = "echo '${data.template_file.deployment_yaml.rendered}' | ${var.kubectl_executable_name} apply -f - --context ${var.kubectl_context_name}"
+ }
+
+ provisioner "local-exec" {
+ command = "echo '${data.template_file.deployment_yaml.rendered}' | ${var.kubectl_executable_name} delete -f - --context ${var.kubectl_context_name} || true"
+ when = "destroy"
+ }
+
+ count = "${local.count}"
+}
diff --git a/deployment/terraform/reverse-proxy/templates/deployment.yaml b/deployment/terraform/reverse-proxy/templates/deployment.yaml
new file mode 100644
index 0000000..3f47d06
--- /dev/null
+++ b/deployment/terraform/reverse-proxy/templates/deployment.yaml
@@ -0,0 +1,57 @@
+# ------------------- Deployment ------------------- #
+
+kind: Deployment
+apiVersion: apps/v1beta2
+metadata:
+ labels:
+ k8s-app: ${app_name}
+ name: ${app_name}
+ namespace: ${namespace}
+spec:
+ replicas: ${replicas}
+ revisionHistoryLimit: 10
+ selector:
+ matchLabels:
+ k8s-app: ${app_name}
+ template:
+ metadata:
+ labels:
+ k8s-app: ${app_name}
+ spec:
+ containers:
+ - name: ${app_name}
+ image: ${image}
+ resources:
+ limits:
+ cpu: ${cpu_limit}
+ memory: ${memory_limit}Mi
+ requests:
+ cpu: ${cpu_request}
+ memory: ${memory_request}Mi
+ env:
+ - name: "JAVA_XMS"
+ value: "${jvm_memory_limit}m"
+ - name: "JAVA_XMX"
+ value: "${jvm_memory_limit}m"
+ - name: "grpc-server-endpoint"
+ value: ${grpc_server_endpoint}
+ - name: "http-port"
+ value: ":${service_port}"
+ nodeSelector:
+ ${node_selecter_label}
+
+# ------------------- Service ------------------- #
+---
+apiVersion: v1
+kind: Service
+metadata:
+ labels:
+ k8s-app: ${app_name}
+ name: ${app_name}
+ namespace: ${namespace}
+spec:
+ ports:
+ - port: ${service_port}
+ targetPort: ${service_port}
+ selector:
+ k8s-app: ${app_name}
\ No newline at end of file
diff --git a/deployment/terraform/reverse-proxy/variables.tf b/deployment/terraform/reverse-proxy/variables.tf
new file mode 100644
index 0000000..86d2693
--- /dev/null
+++ b/deployment/terraform/reverse-proxy/variables.tf
@@ -0,0 +1,12 @@
+variable "kubectl_context_name" {}
+variable "kubectl_executable_name" {}
+variable "namespace" {}
+variable "node_selector_label"{}
+
+variable "reverse-proxy" {
+ type = "map"
+}
+
+variable "service_port" {
+ default = 35002
+}
\ No newline at end of file
diff --git a/haystack-blobs/README.md b/haystack-blobs/README.md
index 47c4c4a..814428c 100644
--- a/haystack-blobs/README.md
+++ b/haystack-blobs/README.md
@@ -18,7 +18,7 @@ Below is a sample configuration for blobs in [Haystack-Agent](https://github.com
agents {
ossblobs {
enabled = true
- port = 34001
+ port = 35001
max.blob.size.in.kb = 1536
dispatchers {
s3 {
@@ -44,7 +44,7 @@ This is a GRPC client that is used to send the blob to wherever the server resid
The client is initiated using a builder which can either take a [ManagedChannel](https://grpc.github.io/grpc-java/javadoc/io/grpc/ManagedChannel.html) object or `address` and `port` of the server running.
-The server in the haystack-agent is running at a default port 34001.
+The server in the haystack-agent is running at a default port 35001.
### Agent Provider or Server
We have one agent provider today that is loaded depending upon the configuration as above.
@@ -93,11 +93,11 @@ To run the HTTP proxy to GRPC service locally please follow the below steps as w
1. Inside `reverse-proxy`, build using `go build`
2. You can add 2 optional environment variables using:
- `$ export grpc-server-endpoint=localhost:34001`
+ `$ export grpc-server-endpoint=localhost:35001`
- `$ export http-port=:34002`
+ `$ export http-port=:35002`
- The default value of `http-port` is `:34002` and `grpc-server-endpoint` is `localhost:34001`
+ The default value of `http-port` is `:35002` and `grpc-server-endpoint` is `localhost:35001`
3. To run the server use `./main`.
@@ -158,6 +158,6 @@ protoc -I/usr/local/include -I. \
7. Inside `reverse-proxy` call `go build`
-8. To run the server use `./main -http-port=:34002 -grpc-server-endpoint=localhost:34001`.
+8. To run the server use `./main -http-port=:35002 -grpc-server-endpoint=localhost:35001`.
- The command line arguments are optional with default value of `http-port` as `:34002` and `grpc-server-endpoint` as `localhost:34001`
\ No newline at end of file
+ The command line arguments are optional with default value of `http-port` as `:35002` and `grpc-server-endpoint` as `localhost:35001`
\ No newline at end of file
diff --git a/haystack-blobs/blobs-agent-server/pom.xml b/haystack-blobs/blobs-agent-server/pom.xml
index 8a13000..075567e 100644
--- a/haystack-blobs/blobs-agent-server/pom.xml
+++ b/haystack-blobs/blobs-agent-server/pom.xml
@@ -119,6 +119,11 @@
org.jacoco
jacoco-maven-plugin
+
+
+ **/GrpcHealthServer.*
+
+
diff --git a/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/api/GrpcHealthServer.java b/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/api/GrpcHealthServer.java
new file mode 100644
index 0000000..63f5685
--- /dev/null
+++ b/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/api/GrpcHealthServer.java
@@ -0,0 +1,15 @@
+package com.expedia.www.haystack.agent.blobs.server.api;
+
+import io.grpc.health.v1.HealthCheckRequest;
+import io.grpc.health.v1.HealthCheckResponse;
+import io.grpc.health.v1.HealthGrpc;
+import io.grpc.stub.StreamObserver;
+
+public class GrpcHealthServer extends HealthGrpc.HealthImplBase {
+
+ @Override
+ public void check(HealthCheckRequest request, StreamObserver responseObserver) {
+ responseObserver.onNext(HealthCheckResponse.newBuilder().setStatus(HealthCheckResponse.ServingStatus.SERVING).build());
+ responseObserver.onCompleted();
+ }
+}
diff --git a/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/spi/BlobAgent.java b/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/spi/BlobAgent.java
index ac0672f..89637f0 100644
--- a/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/spi/BlobAgent.java
+++ b/haystack-blobs/blobs-agent-server/src/main/java/com/expedia/www/haystack/agent/blobs/server/spi/BlobAgent.java
@@ -2,6 +2,7 @@
import com.expedia.www.haystack.agent.blobs.dispatcher.core.BlobDispatcher;
import com.expedia.www.haystack.agent.blobs.server.api.BlobAgentGrpcServer;
+import com.expedia.www.haystack.agent.blobs.server.api.GrpcHealthServer;
import com.expedia.www.haystack.agent.core.Agent;
import com.google.common.annotations.VisibleForTesting;
import com.typesafe.config.Config;
@@ -31,7 +32,7 @@ public class BlobAgent implements Agent {
this.server = server;
}
- public BlobAgent(){
+ public BlobAgent() {
}
@@ -58,7 +59,8 @@ void _initialize(List dispatchers, Config config) throws IOExcep
final NettyServerBuilder builder = NettyServerBuilder
.forPort(port)
.directExecutor()
- .addService(new BlobAgentGrpcServer(dispatchers, maxBlobSizeInBytes));
+ .addService(new BlobAgentGrpcServer(dispatchers, maxBlobSizeInBytes))
+ .addService(new GrpcHealthServer());
// default max message size in grpc is 4MB. if our maxBlobSize is greater than 4MB then we should configure this
// limit in the netty based grpc server.
diff --git a/haystack-blobs/pom.xml b/haystack-blobs/pom.xml
index 677e039..caa90d9 100644
--- a/haystack-blobs/pom.xml
+++ b/haystack-blobs/pom.xml
@@ -45,6 +45,12 @@
${grpc.version}
+
+ io.grpc
+ grpc-services
+ ${grpc.version}
+
+
org.easymock
easymock
diff --git a/haystack-blobs/reverse-proxy/Dockerfile b/haystack-blobs/reverse-proxy/Dockerfile
index f10fdbf..37e5216 100644
--- a/haystack-blobs/reverse-proxy/Dockerfile
+++ b/haystack-blobs/reverse-proxy/Dockerfile
@@ -10,5 +10,5 @@ FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=builder /work/app .
-EXPOSE 34002
+EXPOSE 35002
CMD ["./app"]
\ No newline at end of file
diff --git a/haystack-blobs/reverse-proxy/main.go b/haystack-blobs/reverse-proxy/main.go
index 89496c6..051a62b 100644
--- a/haystack-blobs/reverse-proxy/main.go
+++ b/haystack-blobs/reverse-proxy/main.go
@@ -14,9 +14,9 @@ import (
)
const GRPC_SERVER_ENDPOINT_ENV_VAR = "grpc-server-endpoint"
-const DEFAULT_GRPC_SERVER_ENDPOINT = "haystack-agent:34001"
+const DEFAULT_GRPC_SERVER_ENDPOINT = "haystack-agent:35001"
const PROXY_SERVER_HTTP_PORT = "http-port"
-const DEFAULT_PROXY_SERVER_HTTP_PORT = ":34002"
+const DEFAULT_PROXY_SERVER_HTTP_PORT = ":35002"
func getGrpcServerEndpoint() string {
grpcServerEndpoint := os.Getenv(GRPC_SERVER_ENDPOINT_ENV_VAR)