Skip to content

Commit

Permalink
Added demo-actor.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
m3nax committed Jun 17, 2024
1 parent 05a8bab commit f8ac740
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/Actor/DemoActor/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Copyright 2021 The Dapr Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
50 changes: 50 additions & 0 deletions examples/Actor/DemoActor/demo-actor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
kind: Service
apiVersion: v1
metadata:
name: demoactor
labels:
app: demoactor
spec:
selector:
app: demoactor
ports:
- protocol: TCP
port: 5010
targetPort: app-port
type: LoadBalancer
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: demoactor
labels:
app: demoactor
spec:
replicas: 1
selector:
matchLabels:
app: demoactor
template:
metadata:
labels:
app: demoactor
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "demoactor"
dapr.io/app-port: "5010"
dapr.io/enable-api-logging: "true"
spec:
containers:
- name: demoactor
# image: <your-docker-registry>/demo-actor:latest
image: demo-actor:latest
# if you are using docker desktop, you can use imagePullPolicy: Never to use local image
imagePullPolicy: Never
env:
- name: APP_PORT
value: "5010"
- name: ASPNETCORE_URLS
value: "http://+:5010"
ports:
- name: app-port
containerPort: 5010
40 changes: 40 additions & 0 deletions examples/Actor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,44 @@ docket tag demo-actor:latest <your-docker-registry>/demo-actor:latest

# Push the image to your Docker registry
docker push <your-docker-registry>/demo-actor:latest
```

### Deploy the Actor service to Kubernetes
#### Prerequisites
- A Kubernetes cluster with `kubectl` configured to access it.
- Dapr v1.13+ installed on the Kubernetes cluster. Follow the instructions [here](https://docs.dapr.io/getting-started/install-dapr-kubernetes/).
- A Docker registry where you pushed the `DemoActor` image.

#### Deploy the Actor service
To deploy the `DemoActor` service to Kubernetes, you can use the provided Kubernetes manifest file `demo-actor.yaml` in the `DemoActor` project directory.
Before applying the manifest file, replace the image name in the manifest file with the image name you pushed to your Docker registry.

Part to update in `demo-actor.yaml`:
``` YAML
image: <your-docker-registry>/demoactor:latest
```
To install the application in `default` namespace, run the following command:

``` Bash
kubectl apply -f demo-actor.yaml
```

This will deploy the `DemoActor` service to Kubernetes. You can check the status of the deployment by running:

``` Bash
kubectl get pods -n default
```

The manifest create 2 services:

- `demoactor` service: The service that hosts the `DemoActor` actor.
- `demoactor-dapr` service: The service that hosts the Dapr sidecar for the `DemoActor` actor.

### Make client calls to the deployed Actor service
To make client calls to the deployed `DemoActor` service, you can use the `ActorClient` project.
Before running the client, update the `DAPR_HTTP_PORT` environment variable in the `ActorClient` project directory to the port on which Dapr is running in the Kubernetes cluster.

``` Bash
export DAPR_HTTP_PORT=<dapr-http-port>
```

0 comments on commit f8ac740

Please sign in to comment.