Skip to content

Commit

Permalink
chore: Introduce failing observability example for podtatohead (#204)
Browse files Browse the repository at this point in the history
Signed-off-by: odubajDT <ondrej.dubaj@dynatrace.com>
  • Loading branch information
odubajDT committed Oct 20, 2022
1 parent fde0c67 commit f29910d
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 10 deletions.
22 changes: 22 additions & 0 deletions examples/observability/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,28 @@ deploy-podtatohead:
kubectl create namespace "$(PODTATO_NAMESPACE)" --dry-run=client -o yaml | kubectl apply -f -
kubectl annotate namespace "$(PODTATO_NAMESPACE)" keptn.sh/lifecycle-controller=enabled --overwrite
kubectl apply -f ./assets/podtatohead-deployment-evaluation/.
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition1.yaml
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition2.yaml
kubectl wait --for=condition=available deployment/podtato-head-entry -n podtato-kubectl --timeout=120s
@echo "Watch Workload Deployment Progress: kubectl get keptnworkloadinstances -n podtato-kubectl -w"

.PHONY: deploy-podtatohead-failed-post
deploy-podtatohead-failed-post:
kubectl create namespace "$(PODTATO_NAMESPACE)" --dry-run=client -o yaml | kubectl apply -f -
kubectl annotate namespace "$(PODTATO_NAMESPACE)" keptn.sh/lifecycle-controller=enabled --overwrite
kubectl apply -f ./assets/podtatohead-deployment-evaluation/.
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition1.yaml
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition3.yaml
kubectl wait --for=condition=available deployment/podtato-head-entry -n podtato-kubectl --timeout=120s
@echo "Watch Workload Deployment Progress: kubectl get keptnworkloadinstances -n podtato-kubectl -w"

.PHONY: deploy-podtatohead-failed-pre
deploy-podtatohead-failed-pre:
kubectl create namespace "$(PODTATO_NAMESPACE)" --dry-run=client -o yaml | kubectl apply -f -
kubectl annotate namespace "$(PODTATO_NAMESPACE)" keptn.sh/lifecycle-controller=enabled --overwrite
kubectl apply -f ./assets/podtatohead-deployment-evaluation/.
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition3.yaml
kubectl apply -f ./assets/podtatohead-evaluationdefinitions/keptnevaluationdefinition4.yaml
kubectl wait --for=condition=available deployment/podtato-head-entry -n podtato-kubectl --timeout=120s
@echo "Watch Workload Deployment Progress: kubectl get keptnworkloadinstances -n podtato-kubectl -w"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ spec:
version: 0.1.0
postDeploymentTasks:
- post-deployment-hello
preDeploymentEvaluations: #Comment out this two lines if you do not have a prometheus installation
- my-prometheus-definition
preDeploymentEvaluations: #Comment out this four lines if you do not have a prometheus installation
- my-prometheus-definition1
postDeploymentEvaluations:
- my-prometheus-definition2
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ metadata:
name: prometheus
namespace: podtato-kubectl
spec:
targetServer: "http://prometheus-k8s.monitoring.svc.cluster.local:9090" #string
targetServer: "http://prometheus-k8s.monitoring.svc.cluster.local:9090"
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ spec:
labels:
component: podtato-head-hat
keptn.sh/pre-deployment-tasks: check-entry-service
keptn.sh/pre-deployment-evaluations: my-prometheus-definition
keptn.sh/post-deployment-evaluations: my-prometheus-definition
keptn.sh/pre-deployment-evaluations: my-prometheus-definition1
keptn.sh/post-deployment-evaluations: my-prometheus-definition1
annotations:
keptn.sh/app: podtato-head
keptn.sh/workload: podtato-head-hat
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: lifecycle.keptn.sh/v1alpha1
kind: KeptnEvaluationDefinition
metadata:
name: my-prometheus-definition1
namespace: podtato-kubectl
spec:
source: prometheus
objectives:
- name: available-cpus ## this query should pass
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
evaluationTarget: "<1"

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: lifecycle.keptn.sh/v1alpha1
kind: KeptnEvaluationDefinition
metadata:
name: my-prometheus-definition2
namespace: podtato-kubectl
spec:
source: prometheus
objectives:
- name: consumed-memory ## this query should pass
query: "sum(kube_node_status_capacity{resource='memory'})"
evaluationTarget: "<1000000000000"

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: lifecycle.keptn.sh/v1alpha1
kind: KeptnEvaluationDefinition
metadata:
name: my-prometheus-definition
name: my-prometheus-definition2
namespace: podtato-kubectl
spec:
source: prometheus
objectives:
- name: available-cpus
- name: available-cpus ## this query should fail
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
evaluationTarget: ">1" #string: can only be starting with < or >
- name: consumed-memory
evaluationTarget: ">1"
- name: consumed-memory ## this query should pass
query: "sum(kube_node_status_capacity{resource='memory'})"
evaluationTarget: "<1000000000000" #string: can only be starting with < or >
evaluationTarget: "<1000000000000"

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: lifecycle.keptn.sh/v1alpha1
kind: KeptnEvaluationDefinition
metadata:
name: my-prometheus-definition1
namespace: podtato-kubectl
spec:
source: prometheus
objectives:
- name: available-cpus ## this query should fail
query: "sum(kube_pod_container_resource_limits{resource='cpu'}) - sum(kube_node_status_capacity{resource='cpu'})"
evaluationTarget: ">1000"

0 comments on commit f29910d

Please sign in to comment.