apiVersion: lifecycle.keptn.sh/v1
kind: KeptnAppContext
metadata:
  name: podtato-head
spec:
  preDeploymentEvaluations:
    - available-cpus
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: podtato-head-entry
  labels:
    app: podtato-head
spec:
  selector:
    matchLabels:
      component: podtato-head-entry
  template:
    metadata:
      labels:
        component: podtato-head-entry
      annotations:
        keptn.sh/app: podtato-head
        keptn.sh/workload: podtato-head-entry
        keptn.sh/version: 0.1.0
    spec:
      terminationGracePeriodSeconds: 5
      containers:
        - name: server
          image: ghcr.io/podtato-head/entry:latest
          imagePullPolicy: Always
          ports:
            - containerPort: 9000
          env:
            - name: PODTATO_PORT
              value: "9000"
---
apiVersion: v1
kind: Service
metadata:
  name: podtato-head-entry
  labels:
    app: podtato-head
spec:
  selector:
    component: podtato-head-entry
  ports:
    - name: http
      port: 9000
      protocol: TCP
      targetPort: 9000
  type: LoadBalancer
---
apiVersion: lifecycle.keptn.sh/v1
kind: KeptnEvaluationDefinition
metadata:
  name: available-cpus
spec:
  objectives:
    - evaluationTarget: ">1000"
      keptnMetricRef:
        name: available-cpus
  retries: 2
  retryInterval: 3s
---
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetric
metadata:
  name: available-cpus
spec:
  fetchIntervalSeconds: 10
  provider:
    name: prometheus
  query: >-
    sum(kube_node_status_capacity{resource='cpu'})
---
apiVersion: metrics.keptn.sh/v1
kind: KeptnMetricsProvider
metadata:
  name: prometheus
spec:
  type: prometheus
  targetServer: "http://prometheus-k8s.monitoring.svc.cluster.local:9090"
