Skip to content

Commit

Permalink
Add mr_web_client deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbat00 committed Nov 18, 2021
1 parent 205b056 commit 0082dee
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 29 deletions.
7 changes: 6 additions & 1 deletion k8s/agones/mr_server_fleet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ resource "kubernetes_manifest" "mr_server_fleet" {
# Pod template configuration
# https://v1-20.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.20/#podtemplate-v1-core
template = {
metadata = {
labels = {
app = "mr_server"
}
}
spec = {
nodeSelector = {
"app" = "mr_server"
app = "mr_server"
}
tolerations = [
{
Expand Down
31 changes: 3 additions & 28 deletions k8s/matchmaker/module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ resource "kubernetes_deployment" "mr_matchmaker" {
spec {
selector {
match_labels = {
app = "mr-matchmaker"
service = "mr-matchmaker"
}
}
replicas = 2
template {
metadata {
labels = {
app = "mr-matchmaker"
app = "muddle-run"
service = "mr-matchmaker"
}
}
spec {
Expand All @@ -30,29 +31,3 @@ resource "kubernetes_deployment" "mr_matchmaker" {
}
}
}

# https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html
# If this service gets stuck creating (processing finalizers), use the following command to enable force-deleting it:
# `kubectl patch service mr-matchmaker-service -p '{"metadata":{"finalizers":[]}}' --type=merge`
resource "kubernetes_service" "mr_matchmaker_service" {
metadata {
name = "mr-matchmaker-service"
annotations = {
"service.beta.kubernetes.io/aws-load-balancer-type" : "external"
"service.beta.kubernetes.io/aws-load-balancer-scheme" : "internet-facing"
"service.beta.kubernetes.io/aws-load-balancer-nlb-target-type" : "ip"
}
}

spec {
type = "LoadBalancer"
selector = {
app = "mr-matchmaker"
}
port {
port = 8080
}
}

depends_on = [kubernetes_cluster_role_binding.matchmaker_role_binding]
}
28 changes: 28 additions & 0 deletions k8s/service/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# https://docs.aws.amazon.com/eks/latest/userguide/network-load-balancing.html
# If this service gets stuck creating (processing finalizers), use the following command to enable force-deleting it:
# `kubectl patch service mr-matchmaker-service -p '{"metadata":{"finalizers":[]}}' --type=merge`
resource "kubernetes_service" "muddle-run-service" {
metadata {
name = "mr-service"
annotations = {
"service.beta.kubernetes.io/aws-load-balancer-type" : "external"
"service.beta.kubernetes.io/aws-load-balancer-scheme" : "internet-facing"
"service.beta.kubernetes.io/aws-load-balancer-nlb-target-type" : "ip"
}
}

spec {
type = "LoadBalancer"
selector = {
app = "muddle-run"
}
port {
name = "http"
port = 80
}
port {
name = "ws"
port = 8080
}
}
}
33 changes: 33 additions & 0 deletions k8s/web_client/module.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource "kubernetes_deployment" "mr_web_client" {
metadata {
name = "mr-web-client"
}

spec {
selector {
match_labels = {
service = "mr-web-client"
}
}
replicas = 2
template {
metadata {
labels = {
app = "muddle-run"
service = "mr-web-client"
}
}
spec {
termination_grace_period_seconds = 5
container {
name = "mr-web-client"
image = "mvlabat/mr_web_client:latest"
image_pull_policy = "Always"
port {
container_port = 80
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ module "matchmaker" {
depends_on = [module.aws_load_balancer_controller, module.helm_agones]
}

module "web_client" {
source = "./k8s/web_client"
depends_on = [module.aws_load_balancer_controller]
}

module "service" {
source = "./k8s/service"
depends_on = [module.matchmaker, module.web_client]
}

# Comment this out if running for the first time (i.e. when `helm_agones` is not installed).
module "agones" {
source = "./k8s/agones"
Expand Down

0 comments on commit 0082dee

Please sign in to comment.