Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Move module mfnf2serlo from modules-kpi to here #63

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions mfnf2serlo/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
locals {
name = "mfnf2serlo"
}

variable "namespace" {
default = "kpi"
}

variable "node_pool" {
type = string
}

variable "image_tag" {
type = string
description = "See https://github.com/serlo/mfnf-to-edtr-mapping/tree/main/mfnf2serlo"
}

output "mfnf2serlo_service_name" {
value = kubernetes_service.mfnf2serlo_service.metadata[0].name
}

output "mfnf2serlo_service_port" {
value = kubernetes_service.mfnf2serlo_service.spec[0].port[0].port
}

resource "kubernetes_deployment" "mfnf2serlo" {
metadata {
name = local.name
namespace = var.namespace

labels = {
app = local.name
}
}

spec {
replicas = "1"

selector {
match_labels = {
app = local.name
}
}

template {
metadata {
labels = {
app = local.name
name = local.name
}
}

spec {
node_selector = {
"cloud.google.com/gke-nodepool" = var.node_pool
}

container {
image = "eu.gcr.io/serlo-shared/mfnf2serlo:${var.image_tag}"
name = local.name

resources {
limits = {
cpu = "950m"
memory = "150M"
}
}
}
}
}
}
}


resource "kubernetes_service" "mfnf2serlo_service" {
metadata {
name = "mfnf2serlo-service"
namespace = var.namespace
}

spec {
selector = {
app = local.name
}

port {
port = 80
target_port = 80
}

type = "ClusterIP"
}
}
9 changes: 9 additions & 0 deletions mfnf2serlo/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = ">= 1.0"
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0"
}
}
}