forked from mchandramouli/blobs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ExpediaDotCom/deployment
Reverse proxy Deployment
- Loading branch information
Showing
10 changed files
with
153 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" | ||
} |
57 changes: 57 additions & 0 deletions
57
deployment/terraform/reverse-proxy/templates/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...erver/src/main/java/com/expedia/www/haystack/agent/blobs/server/api/GrpcHealthServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<HealthCheckResponse> responseObserver) { | ||
responseObserver.onNext(HealthCheckResponse.newBuilder().setStatus(HealthCheckResponse.ServingStatus.SERVING).build()); | ||
responseObserver.onCompleted(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters