Skip to content

Commit

Permalink
feat: deploy whoami app
Browse files Browse the repository at this point in the history
  • Loading branch information
alexis-langlet committed Apr 24, 2024
1 parent bf5b4d0 commit 1fde804
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
41 changes: 41 additions & 0 deletions deployment/terraform/kube/whoami/app.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions deployment/terraform/kube/whoami/scale.yaml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 11 additions & 3 deletions deployment/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"))
}
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"))
}

0 comments on commit 1fde804

Please sign in to comment.