Skip to content

Resolve Minor Issue - Add Windows Commands #22

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 52 additions & 17 deletions 04_daca_agent_native_dev/03_dapr_intro/01_dapr_helm/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ Dapr’s **control plane** includes services (operator, placement, scheduler, se
helm repo add dapr https://dapr.github.io/helm-charts/
helm repo update
```

2. **Install Dapr Control Plane**:

**For MacOS**
```bash
helm upgrade --install dapr dapr/dapr \
--version=1.15 \
Expand All @@ -33,7 +35,13 @@ Dapr’s **control plane** includes services (operator, placement, scheduler, se
--wait
```

3. **Verify Dapr Pods**:
**For Windows**
```bash
helm upgrade --install dapr dapr/dapr --version 1.15 --namespace dapr-system --create-namespace --wait
```


4. **Verify Dapr Pods**:
```bash
kubectl get pods -n dapr-system
```
Expand Down Expand Up @@ -157,9 +165,9 @@ We’ll deploy Redis as the backend for state and pub/sub, and configure Dapr co
```
- Expected:
```bash
NAME AGE
pubsub 112s
statestore 2m25s
NAME AGE
pubsub 112s
statestore 2m25s
```

Open http://localhost:8080/components and see the components there.
Expand Down Expand Up @@ -225,10 +233,26 @@ Dapr’s sidecar exposes HTTP APIs on port 3500 for state (saving/retrieving dat


3. **Port-Forward to Sidecar**:

**For MacOS**

```bash
kubectl get pods | grep dapr-test-app
```

```bash
kubectl port-forward pod/dapr-test-app-<pod-suffix> 3500:3500 -n default
```

**For Windows**
```bash
kubectl get pods
```

```bash
kubectl port-forward pod/dapr-test-app-<pod-suffix> 3500:3500 -n default
```

- Example:
```bash
kubectl port-forward pod/dapr-test-app-79469c967b-stlgj 3500:3500 -n default
Expand All @@ -239,7 +263,7 @@ Dapr’s sidecar exposes HTTP APIs on port 3500 for state (saving/retrieving dat
Forwarding from [::1]:3500 -> 3500
```

4. **Test State Store**:
5. **Test State Store**:
- Save State:
```bash
curl -X POST http://localhost:3500/v1.0/state/statestore \
Expand All @@ -256,40 +280,51 @@ Dapr’s sidecar exposes HTTP APIs on port 3500 for state (saving/retrieving dat
{"user_id": "user123", "message": "Hello, Dapr!"}
```

5. **Test Pub/Sub**:
6. **Test Pub/Sub**:
```bash
curl -X POST http://localhost:3500/v1.0/publish/pubsub/message-updated \
-H "Content-Type: application/json" \
-d '{"user_id": "user123", "message": "Hello, Dapr!"}'
```
- Expected: No output (200 OK).

6. **Stop Port-Forwarding**:
7. **Stop Port-Forwarding**:
- Press `Ctrl+C`.

## 5: Verify Redis Data
### What’s Happening?
We saved a state key (`test-key`) in Redis via Dapr’s `statestore`. Let’s confirm the data is stored in Redis.

1. **Run Redis Client Pod**:

**For MacOS**
```bash
kubectl run redis-client --namespace default --restart='Never' --image docker.io/bitnami/redis:7.4.2-debian-12-r11 --command -- sleep infinity
```
**For Windows**
```bash
kubectl run redis-client --namespace default --restart="Never" --image=docker.io/bitnami/redis:7.4.2-debian-12-r11 --command -- sleep infinity
```

Wait for the container to start

```bash
mjs@Muhammads-MacBook-Pro-3 learn-agentic-ai % kubectl get pods
NAME READY STATUS RESTARTS AGE
redis-client 0/1 ContainerCreating 0 48s
kubectl get pods
```

2. **Connect to Redis**:
- Expeted Output:

```bash
NAME READY STATUS RESTARTS AGE
redis-client 0/1 ContainerCreating 0 48s
```

3. **Connect to Redis**:
```bash
kubectl exec -it redis-client --namespace default -- redis-cli -h redis-master
```

3. **Check Keys**:
4. **Check Keys**:
```
KEYS *
```
Expand All @@ -299,7 +334,7 @@ We saved a state key (`test-key`) in Redis via Dapr’s `statestore`. Let’s co
2) "dapr-test-app||test-key"
```

4. **Retrieve Value**:
5. **Retrieve Value**:
```
HGETALL dapr-test-app||test-key
```
Expand All @@ -312,7 +347,7 @@ We saved a state key (`test-key`) in Redis via Dapr’s `statestore`. Let’s co
```


5. **Inspect the type of a key in Redis**:
6. **Inspect the type of a key in Redis**:
```bash
redis-master:6379> TYPE dapr-test-app||test-key
hash
Expand Down Expand Up @@ -381,4 +416,4 @@ kubectl delete namespace dapr-system
- Dapr Helm Chart: https://github.com/dapr/dapr/tree/master/charts/dapr
- Dapr Dashboard: https://docs.dapr.io/operations/monitoring/dashboard/
- FastAPI: https://fastapi.tiangolo.com/
- UV: https://docs.astral.sh/uv/
- UV: https://docs.astral.sh/uv/
49 changes: 25 additions & 24 deletions 04_daca_agent_native_dev/03_dapr_intro/02_fastapi_dapr/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,33 @@ Here we are using same endpoints that we tried with CURL before.

- `kubernetes/deployment.yaml`:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: dapr-fastapi-hello
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: dapr-fastapi-hello
template:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: dapr-fastapi-hello
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "dapr-fastapi-hello"
dapr.io/app-port: "8000"
dapr.io/enable-api-logging: "true"
name: dapr-fastapi-hello
namespace: default
spec:
containers:
- name: app
image: dapr-fastapi-hello:latest
ports:
- containerPort: 8000
imagePullPolicy: Never
replicas: 1
selector:
matchLabels:
app: dapr-fastapi-hello
template:
metadata:
labels:
app: dapr-fastapi-hello
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "dapr-fastapi-hello"
dapr.io/app-port: "8000"
dapr.io/enable-api-logging: "true"
spec:
containers:
- name: app
image: dapr-fastapi-hello:latest
ports:
- containerPort: 8000
imagePullPolicy: Never

```

- `kubernetes/service.yaml`:
Expand Down