Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cloud native observability #15

Merged
merged 9 commits into from
Aug 8, 2024
17 changes: 17 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/burn-cpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
namespace: 12-factor-app
name: burn-cpu-100
spec:
selector:
namespaces:
- 12-factor-app
labelSelectors:
app.kubernetes.io/instance: 12-factor-app
mode: all
stressors:
cpu:
workers: 1
load: 100
duration: 30s
39 changes: 39 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/chaos-on-the-rise.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: Workflow
metadata:
name: chaos-on-the-rise
namespace: 12-factor-app
spec:
entry: entry
templates:
- name: entry
templateType: Serial
deadline: 2m
children:
- stress-test
- pod-killer
- name: stress-test
templateType: StressChaos
deadline: 10s
stressChaos:
selector:
namespaces:
- 12-factor-app
labelSelectors:
app: controller
mode: all
stressors:
cpu:
workers: 1
load: 100
- name: pod-killer
templateType: PodChaos
deadline: 60s
podChaos:
selector:
namespaces:
- 12-factor-app
labelSelectors:
app: controller
mode: all
action: pod-kill
14 changes: 14 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: chaos-ingress
namespace: chaos-testing
spec:
entryPoints:
- web
routes:
- match: Host(`chaos.<ENV-NAME>-<ENV-USER-ID>-01.<ENV-ANIMAL>.<ENV-DOMAIN>`) && PathPrefix(`/`)
kind: Rule
services:
- name: chaos-dashboard
port: 2333
20 changes: 20 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/network-bandwith.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: NetworkChaos
metadata:
name: network-bandwidth-100kbps
namespace: 12-factor-app
spec:
action: bandwidth
mode: all
selector:
namespaces:
- 12-factor-app
labelSelectors:
app.kubernetes.io/instance: 12-factor-app
bandwidth:
rate: 100kbps
limit: 100
buffer: 10000
peakrate: 1000000
minburst: 1000000
duration: "10s"
17 changes: 17 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/network-corrupt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: NetworkChaos
metadata:
name: network-corrupt-example
namespace: 12-factor-app
spec:
action: corrupt
mode: all
selector:
namespaces:
- 12-factor-app
labelSelectors:
app.kubernetes.io/instance: 12-factor-app
corrupt:
corrupt: "40"
correlation: "25"
duration: "10s"
14 changes: 14 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/pod-failure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
namespace: 12-factor-app
name: pod-failure-example
spec:
selector:
namespaces:
- 12-factor-app # the namespace of the system under test (SUT) you've deployed
labelSelectors:
app.kubernetes.io/instance: 12-factor-app # the label of the pod for chaos injection
mode: all # the mode to run chaos action; supported modes are one/all/fixed/fixed-percent/random-max-percent
action: pod-failure # the specific chaos action to inject; supported actions: pod-kill/pod-failure/container-kill
duration: 60s # duration for the injected chaos experiment
21 changes: 21 additions & 0 deletions dapr-distributed-calendar/chaos-engineering/schedule-chaos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: Schedule
metadata:
namespace: 12-factor-app
name: scheduled-pod-failure
spec:
schedule: 5 * * * *
startingDeadlineSeconds: null
concurrencyPolicy: Forbid
historyLimit: 2
type: PodChaos
podChaos:
selector:
namespaces:
- 12-factor-app
labelSelectors:
app: controller
mode: one
action: pod-failure
duration: 1m
gracePeriod: 0
147 changes: 147 additions & 0 deletions dapr-distributed-calendar/error.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash

ENDPOINT="${ENDPOINT:-localhost}"
PORT="${PORT:-3000}"

echo Endpoint: $ENDPOINT
echo Port: $PORT

# Update event 1
echo 'Update event 1'
curl --location --request PUT 'http://'$ENDPOINT':'$PORT'/updateevent/1' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Updated Event",
"date": "TBD"
}
}' | jq

# Update event 1
echo 'Update event 1'
curl --location --request PUT 'http://'$ENDPOINT':'$PORT'/updateevent/1' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Updated Event",
"date": "TBD"
}
}' | jq

# Update event 1
echo 'Update event 1'
curl --location --request PUT 'http://'$ENDPOINT':'$PORT'/updateevent/1' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Updated Event",
"date": "TBD"
}
}' | jq

# Update event 1
echo 'Update event 1'
curl --location --request PUT 'http://'$ENDPOINT':'$PORT'/updateevent/1' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Updated Event",
"date": "TBD"
}
}' | jq

# Get event 1 (should fail)
echo 'Get event 1 (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Get event 1 (should fail)
echo 'Get event 1 (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Get event 1 (should fail)
echo 'Get event 1 (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Get event 1 (should fail)
echo 'Get event 1 (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Create event 1
echo 'Create event 1'
curl --location 'http://'$ENDPOINT':'$PORT'/newevent' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Uninstall Event",
"date": "TBD",
"id": "1"
}
}' |jq

# Create event 1 again (should fail)
echo 'Create event 1 again (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/newevent' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Uninstall Event",
"date": "TBD",
"id": "1"
}
}' | jq

# Create event 1 again (should fail)
echo 'Create event 1 again (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/newevent' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Uninstall Event",
"date": "TBD",
"id": "1"
}
}' | jq

# Create event 1 again (should fail)
echo 'Create event 1 again (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/newevent' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Uninstall Event",
"date": "TBD",
"id": "1"
}
}' | jq

# Create event 1 again (should fail)
echo 'Create event 1 again (should fail)'
curl --location 'http://'$ENDPOINT':'$PORT'/newevent' \
--header 'Content-Type: application/json' \
--data '{
"data": {
"name": "Uninstall Event",
"date": "TBD",
"id": "1"
}
}' | jq

# Delete event 1
echo 'Delete event 1'
curl --location --request DELETE 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Delete event 1 again (should fail)
echo 'Delete event 1 again (should fail)'
curl --location --request DELETE 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Delete event 1 again (should fail)
echo 'Delete event 1 again (should fail)'
curl --location --request DELETE 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Delete event 1 again (should fail)
echo 'Delete event 1 again (should fail)'
curl --location --request DELETE 'http://'$ENDPOINT':'$PORT'/event/1' | jq

# Delete event 1 again (should fail)
echo 'Delete event 1 again (should fail)'
curl --location --request DELETE 'http://'$ENDPOINT':'$PORT'/event/1' | jq
2 changes: 1 addition & 1 deletion dapr-distributed-calendar/fluent/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: traefik.containo.us/v1alpha1
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: kibana-ingress
Expand Down
Loading
Loading