Skip to content

Commit

Permalink
fix: deployment, locust file and added ingress for grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
mati007thm committed Jan 18, 2024
1 parent bd0901f commit 6e9791f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
1 change: 1 addition & 0 deletions dapr-distributed-calendar/kubernetes-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ helm install redis bitnami/redis --namespace 12-factor-app --wait

# deploy the 12-factor-app
kubectl apply -f kubernetes/.
kubectl wait --for=condition=ready pod --all --timeout=200s -n 12-factor-app

# setup locust for loadgeneration OPTIONAL
kubectl create configmap my-loadtest-locustfile --from-file locust/main.py -n 12-factor-app
Expand Down
24 changes: 20 additions & 4 deletions dapr-distributed-calendar/locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
default_headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'}

class EventsUser(HttpUser):
wait_time = between(5, 10) # Adjust the wait time between tasks as needed
wait_time = between(3, 5) # Adjust the wait time between tasks as needed

@task
def event_lifecycle(self):
Expand All @@ -22,7 +22,7 @@ def event_lifecycle(self):
}

# Send the POST request to create an event
response = self.client.post('/newevent', json=data, headers=headers)
response = self.client.post(f'/newevent', json=data, headers=headers)

# Check if the request was successful
if response.status_code == 200:
Expand All @@ -31,16 +31,32 @@ def event_lifecycle(self):
print(f"Failed to create event {event_id}. Status code: {response.status_code}")

# Get the event
response = self.client.get('/event/{event_id}')
response = self.client.get(f'/event/{event_id}')

# Check if the request was successful
if response.status_code == 200:
print(f"Event {event_id} retrieved successfully")
else:
print(f"Failed to retrieve event {event_id}. Status code: {response.status_code}")

# Update the event
updated_data = {
"data": {
"name": f"Updated Event {event_id}",
"date": "2020-10-10",
"id": str(event_id)
}
}
response = self.client.put(f'/updateevent', json=updated_data, headers=headers)

# Check if the update was successful
if response.status_code == 200:
print(f"Event {event_id} updated successfully")
else:
print(f"Failed to update event {event_id}. Status code: {response.status_code}")

# Delete the event
response = self.client.delete('/event/{event_id}')
response = self.client.delete(f'/event/{event_id}')

# Check if the request was successful
if response.status_code == 200:
Expand Down
17 changes: 16 additions & 1 deletion dapr-distributed-calendar/prometheus/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@ spec:
kind: Rule
services:
- name: prometheus-kube-prometheus-prometheus
port: 9090
port: 9090
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: grafana-ingress
namespace: observability
spec:
entryPoints:
- web
routes:
- match: Host(`grafana.<ENV-NAME>-<ENV-USER-ID>-01.<ENV-ANIMAL>.<ENV-DOMAIN>`) && PathPrefix(`/`)
kind: Rule
services:
- name: prometheus-grafana
port: 80

0 comments on commit 6e9791f

Please sign in to comment.