From 1fde804b3dec4f143e8e7a9b9dd4fdc876bacc6b Mon Sep 17 00:00:00 2001 From: Alexis Langlet Date: Wed, 24 Apr 2024 16:31:13 +0200 Subject: [PATCH] feat: deploy whoami app --- deployment/terraform/kube/whoami/app.yaml | 41 +++++++++++++++++++++ deployment/terraform/kube/whoami/scale.yaml | 15 ++++++++ deployment/terraform/main.tf | 14 +++++-- 3 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 deployment/terraform/kube/whoami/app.yaml create mode 100644 deployment/terraform/kube/whoami/scale.yaml diff --git a/deployment/terraform/kube/whoami/app.yaml b/deployment/terraform/kube/whoami/app.yaml new file mode 100644 index 0000000..22bc5d4 --- /dev/null +++ b/deployment/terraform/kube/whoami/app.yaml @@ -0,0 +1,41 @@ +apiVersion: core.spinoperator.dev/v1alpha1 +kind: SpinApp +metadata: + name: whoami-app + namespace: default +spec: + image: index.docker.io/sautax/variable-explorer:v1 + executor: containerd-shim-spin + enableAutoscaling: true + resources: + limits: + cpu: 500m + memory: 500Mi + requests: + cpu: 100m + memory: 400Mi + variables: + - name: pod_name + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: pod_namespace + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: pod_uid + valueFrom: + fieldRef: + fieldPath: metadata.uid + - name: pod_ip + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: node_name + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: host_ip + valueFrom: + fieldRef: + fieldPath: status.hostIP diff --git a/deployment/terraform/kube/whoami/scale.yaml b/deployment/terraform/kube/whoami/scale.yaml new file mode 100644 index 0000000..fd0d690 --- /dev/null +++ b/deployment/terraform/kube/whoami/scale.yaml @@ -0,0 +1,15 @@ +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: cpu-scaling + namespace: default +spec: + scaleTargetRef: + name: whoami-app + minReplicaCount: 1 + maxReplicaCount: 50 + triggers: + - type: cpu + metricType: Utilization + metadata: + value: "50" \ No newline at end of file diff --git a/deployment/terraform/main.tf b/deployment/terraform/main.tf index 9adef14..1d8597a 100644 --- a/deployment/terraform/main.tf +++ b/deployment/terraform/main.tf @@ -76,6 +76,10 @@ resource "kubectl_manifest" "spin_operator_shrim_executor" { yaml_body = data.http.spin_operator_shrim_executor.response_body } +resource "kubernetes_manifest" "spin_app_ingress" { + manifest = yamldecode(file("${path.module}/kube/network/ingress.yaml")) +} + resource "helm_release" "keda" { name = "keda" namespace = "keda" @@ -84,6 +88,10 @@ resource "helm_release" "keda" { chart = "keda" } -resource "kubernetes_manifest" "spin_app_ingress" { - manifest = yamldecode(file("${path.module}/kube/network/ingress.yaml")) -} \ No newline at end of file +resource "kubernetes_manifest" "whoami_app" { + manifest = yamldecode(file("${path.module}/kube/whoami/app.yaml")) +} + +resource "kubernetes_manifest" "whoami_scale" { + manifest = yamldecode(file("${path.module}/kube/whoami/scale.yaml")) +}