Skip to content

Commit 499d406

Browse files
committed
Add tasks to evals
Signed-off-by: Alberto Gutierrez <[email protected]>
1 parent 4b52f1e commit 499d406

File tree

14 files changed

+554
-0
lines changed

14 files changed

+554
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
kind: Task
2+
metadata:
3+
name: "Create a gateway"
4+
category: "Istio Configuration & Management"
5+
difficulty: medium
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
set -euo pipefail
11+
verify:
12+
inline: |-
13+
#!/usr/bin/env bash
14+
set -euo pipefail
15+
NS="istio-system"
16+
NAME="my-gateway"
17+
if kubectl get gw "$NAME" -n "$NS" >/dev/null 2>&1; then
18+
echo "Verified: Gateway '$NAME' exists in namespace '$NS'."
19+
else
20+
echo "Gateway '$NAME' not found in namespace '$NS'."
21+
exit 1
22+
fi
23+
cleanup:
24+
inline: |-
25+
#!/usr/bin/env bash
26+
set -euo pipefail
27+
NS="istio-system"
28+
NAME="my-gateway"
29+
kubectl delete gw "$NAME" -n "$NS" --ignore-not-found
30+
prompt:
31+
inline: Create a Gateway named my-gateway in the istio-system namespace.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
kind: Task
2+
metadata:
3+
name: "Remove fault Injection"
4+
category: "Istio Configuration & Management"
5+
difficulty: medium
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
set -euo pipefail
11+
cat <<'EOF' | kubectl apply -f -
12+
apiVersion: networking.istio.io/v1
13+
kind: DestinationRule
14+
metadata:
15+
namespace: bookinfo
16+
name: ratings
17+
labels:
18+
gevals.kiali.io/test: delete-fault-injection
19+
spec:
20+
host: ratings.bookinfo.svc.cluster.local
21+
subsets:
22+
- name: v1
23+
labels:
24+
version: v1
25+
---
26+
apiVersion: networking.istio.io/v1
27+
kind: VirtualService
28+
metadata:
29+
namespace: bookinfo
30+
name: ratings
31+
labels:
32+
gevals.kiali.io/test: delete-fault-injection
33+
spec:
34+
hosts:
35+
- ratings.bookinfo.svc.cluster.local
36+
http:
37+
- route:
38+
- destination:
39+
host: ratings.bookinfo.svc.cluster.local
40+
subset: v1
41+
weight: 100
42+
fault:
43+
abort:
44+
percentage:
45+
value: 100
46+
httpStatus: 503
47+
EOF
48+
verify:
49+
inline: |-
50+
#!/usr/bin/env bash
51+
vs_fault_names="$(kubectl get virtualservice -n "${NAMESPACE}" -o json \
52+
| jq -r '[.items[] | select(any(.spec.http[]?; has("fault"))) | .metadata.name] | .[]?')"
53+
if [[ -n "${vs_fault_names}" ]]; then
54+
exit 1
55+
fi
56+
57+
# Verify DestinationRule 'ratings' does not exist (created during setup)
58+
if kubectl get destinationrule ratings -n "${NAMESPACE}" >/dev/null 2>&1; then
59+
exit 1
60+
fi
61+
cleanup:
62+
inline: |-
63+
#!/usr/bin/env bash
64+
set -euo pipefail
65+
NS="bookinfo"
66+
LABEL="gevals.kiali.io/test=gevals-testing"
67+
kubectl delete virtualservice -n "$NS" -l "$LABEL" --ignore-not-found
68+
kubectl delete destinationrule -n "$NS" -l "$LABEL" --ignore-not-found
69+
prompt:
70+
inline: Fix my namespace bookinfo to remove the fault injection.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
kind: Task
2+
metadata:
3+
name: "List all VS in bookinfo namespace"
4+
category: "Istio Configuration & Management"
5+
difficulty: easy
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
set -euo pipefail
11+
cat <<'EOF' | kubectl apply -f -
12+
apiVersion: networking.istio.io/v1alpha3
13+
kind: VirtualService
14+
metadata:
15+
name: productpage-forced-failure
16+
namespace: bookinfo
17+
labels:
18+
gevals.kiali.io/test: delete-fault-injection
19+
spec:
20+
hosts:
21+
- "productpage"
22+
- "productpage-bookinfo.apps-crc.testing" # <--- TU URL EXACTA
23+
gateways:
24+
- bookinfo-gateway
25+
- mesh # Para que afecte también si un microservicio llama a otro internamente
26+
http:
27+
- fault:
28+
abort:
29+
httpStatus: 500
30+
percentage:
31+
value: 100
32+
route:
33+
- destination:
34+
host: productpage
35+
subset: v1
36+
EOF
37+
verify:
38+
inline: |-
39+
#!/usr/bin/env bash
40+
cleanup:
41+
inline: |-
42+
#!/usr/bin/env bash
43+
set -euo pipefail
44+
NS="bookinfo"
45+
LABEL="gevals.kiali.io/test=gevals-testing"
46+
kubectl delete virtualservice -n "$NS" -l "$LABEL" --ignore-not-found
47+
prompt:
48+
inline: List all VirtualServices in the bookinfo namespace and check if they have any validation errors
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
kind: Task
2+
metadata:
3+
name: "Patch my traffic"
4+
category: "Istio Configuration & Management"
5+
difficulty: medium
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
set -euo pipefail
11+
cat <<'EOF' | kubectl apply -f -
12+
kind: DestinationRule
13+
apiVersion: networking.istio.io/v1
14+
metadata:
15+
namespace: bookinfo
16+
name: reviews
17+
labels:
18+
gevals.kiali.io/test: gevals-testing
19+
annotations: ~
20+
spec:
21+
host: reviews.bookinfo.svc.cluster.local
22+
subsets:
23+
- name: v1
24+
labels:
25+
version: v1
26+
- name: v2
27+
labels:
28+
version: v2
29+
- name: v3
30+
labels:
31+
version: v3
32+
trafficPolicy: ~
33+
34+
---
35+
36+
kind: VirtualService
37+
apiVersion: networking.istio.io/v1
38+
metadata:
39+
namespace: bookinfo
40+
name: reviews
41+
labels:
42+
gevals.kiali.io/test: gevals-testing
43+
spec:
44+
http:
45+
- route:
46+
- destination:
47+
host: reviews.bookinfo.svc.cluster.local
48+
subset: v1
49+
weight: 0
50+
- destination:
51+
host: reviews.bookinfo.svc.cluster.local
52+
subset: v2
53+
weight: 0
54+
- destination:
55+
host: reviews.bookinfo.svc.cluster.local
56+
subset: v3
57+
weight: 100
58+
hosts:
59+
- reviews.bookinfo.svc.cluster.local
60+
gateways: ~
61+
EOF
62+
verify:
63+
inline: |-
64+
#!/usr/bin/env bash
65+
set -euo pipefail
66+
NS="bookinfo"
67+
LABEL="gevals.kiali.io/test=gevals-testing"
68+
NAME="reviews"
69+
70+
if ! command -v jq >/dev/null 2>&1; then
71+
echo "jq is required for verification"
72+
exit 1
73+
fi
74+
75+
# Fetch the VirtualService by label and name
76+
vs_json="$(kubectl get virtualservice -n "$NS" -l "$LABEL" -o json)"
77+
found="$(echo "$vs_json" | jq -r --arg name "$NAME" '.items[]? | select(.metadata.name==$name) | .metadata.name' | head -n1)"
78+
if [[ "$found" != "$NAME" ]]; then
79+
echo "VirtualService '$NAME' with label '$LABEL' not found in namespace '$NS'"
80+
exit 1
81+
fi
82+
83+
# Verify there is a route to subset v2 with weight 50
84+
ok="$(echo "$vs_json" | jq -e --arg name "$NAME" '
85+
.items[]? | select(.metadata.name==$name)
86+
| any(.spec.http[]?.route[]?; (.destination.subset=="v2") and ((.weight // 0) == 50))
87+
' >/dev/null && echo yes || echo no)"
88+
89+
if [[ "$ok" != "yes" ]]; then
90+
echo "VirtualService '$NAME' does not route subset v2 with weight 50"
91+
echo "Current routes:"
92+
echo "$vs_json" | jq -r --arg name "$NAME" '
93+
.items[]? | select(.metadata.name==$name)
94+
| .spec.http[]?.route[]? | {subset: .destination.subset, weight: .weight}
95+
'
96+
exit 1
97+
fi
98+
echo "Verified: VirtualService '$NAME' routes subset v2 with weight 50."
99+
cleanup:
100+
inline: |-
101+
#!/usr/bin/env bash
102+
set -euo pipefail
103+
NS="bookinfo"
104+
LABEL="gevals.kiali.io/test=gevals-testing"
105+
kubectl delete virtualservice -n "$NS" -l "$LABEL" --ignore-not-found
106+
kubectl delete destinationrule -n "$NS" -l "$LABEL" --ignore-not-found
107+
prompt:
108+
inline: I need to shift 50% of traffic to v2 of the reviews service. Apply a patch to the existing VirtualService.
109+
110+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: Task
2+
metadata:
3+
name: "Unhealthy Namespaces"
4+
category: "High-Level Observability & Health"
5+
difficulty: easy
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
verify:
11+
inline: |-
12+
#!/usr/bin/env bash
13+
cleanup:
14+
inline: |-
15+
#!/usr/bin/env bash
16+
prompt:
17+
inline: Are there any unhealthy namespaces in my mesh right now?
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: Task
2+
metadata:
3+
name: "Get mesh namespaces"
4+
category: "Resource Inspection"
5+
difficulty: easy
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
verify:
11+
inline: |-
12+
#!/usr/bin/env bash
13+
cleanup:
14+
inline: |-
15+
#!/usr/bin/env bash
16+
prompt:
17+
inline: Check namespaces in my mesh.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
kind: Task
2+
metadata:
3+
name: "Get service detail"
4+
category: "Resource Inspection"
5+
difficulty: easy
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
verify:
11+
inline: |-
12+
#!/usr/bin/env bash
13+
cleanup:
14+
inline: |-
15+
#!/usr/bin/env bash
16+
prompt:
17+
inline: Get the full details and health status for the details service
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
kind: Task
2+
metadata:
3+
name: "List workloads without sidecar"
4+
category: "Resource Inspection"
5+
difficulty: easy
6+
steps:
7+
setup:
8+
inline: |-
9+
#!/usr/bin/env bash
10+
oc patch deployment details-v1 -n bookinfo -p '{"spec": {"template": {"metadata": {"annotations": {"sidecar.istio.io/inject": "false"}}}}}'
11+
verify:
12+
inline: |-
13+
#!/usr/bin/env bash
14+
cleanup:
15+
inline: |-
16+
#!/usr/bin/env bash
17+
oc patch deployment details-v1 -n bookinfo -p '{"spec": {"template": {"metadata": {"annotations": {"sidecar.istio.io/inject": "true"}}}}}'
18+
prompt:
19+
inline: List all workloads in the bookinfo namespace that have missing sidecars.

0 commit comments

Comments
 (0)