Skip to content

Commit 0b303e4

Browse files
committed
add kafka-manager #15
1 parent d2e6ee9 commit 0b303e4

File tree

19 files changed

+115
-29
lines changed

19 files changed

+115
-29
lines changed

samples/Notifier/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"EventBus": {
3-
"Brokers": "127.0.0.1:9092"
3+
"Brokers": "kafka-server:9092"
44
},
55
"Logging": {
66
"LogLevel": {

samples/SignalRNotifier/Services/Hubs/ProjectHub.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,19 @@ public async Task Handle(Notifications.TaskCreated notification, CancellationTok
4040
await Clients.All.SendAsync("taskAddedToProjectNotify", notification, cancellationToken);
4141
}
4242

43-
protected override Task ExecuteAsync(CancellationToken cancellationToken)
43+
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
4444
{
45-
Task.Run(() =>
45+
await Task.Run(() =>
4646
{
4747
_logger.LogInformation("[NCK] Start to subscribe to project-created...");
4848
return _eventBus.Subscribe<ProjectCreatedMsg>("project-created");
4949
}, cancellationToken);
5050

51-
Task.Run(() =>
51+
await Task.Run(() =>
5252
{
5353
_logger.LogInformation("[NCK] Start to subscribe to task-created...");
5454
return _eventBus.Subscribe<TaskCreatedMsg>("task-created");
5555
}, cancellationToken);
56-
57-
return Task.CompletedTask;
5856
}
5957
}
6058
}

samples/SignalRNotifier/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"BasePath": "/"
44
},
55
"EventBus": {
6-
"Brokers": "PLAINTEXT://kafka-cp-kafka:9092"
6+
"Brokers": "kafka-server:9092"
77
},
88
"Logging": {
99
"IncludeScopes": false,

samples/SignalRNotifier/k8s/signalrnotifier-dep.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: signalrnotifier-v1
5-
namespace: default
5+
namespace: kafka
66
spec:
77
replicas: 1
88
template:
@@ -19,7 +19,7 @@ spec:
1919
- name: Hosts__BasePath
2020
value: /
2121
- name: EventBus__Brokers
22-
value: PLAINTEXT://kafka-cp-kafka:9092
22+
value: kafka-server:9092
2323
ports:
2424
- containerPort: 5002
2525
resources:

samples/SignalRNotifier/k8s/signalrnotifier-svc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: signalrnotifier
5-
namespace: default
5+
namespace: kafka
66
labels:
77
app: signalrnotifier
88
spec:

samples/TodoApi/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@
4444
"Microsoft": "Information"
4545
}
4646
}
47-
}
47+
},
48+
"AllowedHosts": "*"
4849
}

samples/TodoApi/k8s/todolist-dep.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: todolist-v1
5-
namespace: default
5+
namespace: kafka
66
spec:
77
replicas: 1
88
template:
@@ -19,15 +19,15 @@ spec:
1919
- name: Hosts__BasePath
2020
value: /
2121
- name: EventBus__Brokers
22-
value: PLAINTEXT://kafka-cp-kafka:9092
22+
value: kafka-server:9092
2323
ports:
2424
- containerPort: 5001
25-
#livenessProbe:
26-
# httpGet:
27-
# path: /healthz
28-
# port: 5001
29-
# initialDelaySeconds: 10
30-
# periodSeconds: 5
25+
livenessProbe:
26+
httpGet:
27+
path: /healthz
28+
port: 5001
29+
initialDelaySeconds: 10
30+
periodSeconds: 5
3131
resources:
3232
requests:
3333
memory: "64Mi"

samples/TodoApi/k8s/todolist-svc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: todolist
5-
namespace: default
5+
namespace: kafka
66
labels:
77
app: todolist
88
spec:

samples/WebNotifier/k8s/webnotifier-dep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: extensions/v1beta1
22
kind: Deployment
33
metadata:
44
name: webnotifier-v1
5-
namespace: default
5+
namespace: kafka
66
spec:
77
replicas: 1
88
template:

samples/WebNotifier/k8s/webnotifier-svc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: webnotifier
5-
namespace: default
5+
namespace: kafka
66
labels:
77
app: webnotifier
88
spec:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: kafka-manager
5+
namespace: kafka
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: kafka-manager
11+
template:
12+
metadata:
13+
labels:
14+
app: kafka-manager
15+
spec:
16+
containers:
17+
- name: kafka-manager
18+
image: solsson/kafka-manager@sha256:28b1a0b355f3972a9e3b5ac82abcbfee9a72b66a2bfe86094f6ea2caad9ce3a7
19+
ports:
20+
- containerPort: 80
21+
env:
22+
- name: ZK_HOSTS
23+
value: "kafka-server.kafka:2181"
24+
command:
25+
- ./bin/kafka-manager
26+
- -Dhttp.port=80
27+
---
28+
kind: Service
29+
apiVersion: v1
30+
metadata:
31+
name: kafka-manager
32+
namespace: kafka
33+
spec:
34+
selector:
35+
app: kafka-manager
36+
ports:
37+
- protocol: TCP
38+
port: 9000
39+
targetPort: 80
40+
type: LoadBalancer
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Deployment
3+
metadata:
4+
name: kafka-server
5+
namespace: kafka
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: kafka-server
11+
template:
12+
metadata:
13+
labels:
14+
app: kafka-server
15+
spec:
16+
containers:
17+
- name: kafka-server
18+
image: spotify/kafka
19+
ports:
20+
- name: kafka
21+
containerPort: 9092
22+
- name: zookeeper
23+
containerPort: 2181
24+
env:
25+
- name: ADVERTISED_HOST
26+
value: "kafka-server"
27+
- name: ADVERTISED_PORT
28+
value: "9092"
29+
---
30+
kind: Service
31+
apiVersion: v1
32+
metadata:
33+
name: kafka-server
34+
namespace: kafka
35+
spec:
36+
selector:
37+
app: kafka-server
38+
ports:
39+
- name: kafka
40+
protocol: TCP
41+
port: 9092
42+
targetPort: 9092
43+
- name: zookeeper
44+
protocol: TCP
45+
port: 2181
46+
targetPort: 2181
47+
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
TAG=${TAG:=$(git rev-parse --short HEAD)}
22
NAMESPACE=${NAMESPACE:="vndg"}
3-
Write-Host "${NAMESPACE} and ${TAG}"
3+
echo "${NAMESPACE} and ${TAG}"
44

5-
Write-Host "Build TODO API..."
5+
echo "Build TODO API..."
66
docker build -f samples/TodoApi/Dockerfile -t vndg/todoapi:$(git rev-parse --short HEAD) -t vndg/todoapi:latest .
77

8-
Write-Host "Build SignalR..."
8+
echo "Build SignalR..."
99
docker build -f samples/SignalRNotifier/Dockerfile -t vndg/signalrnotifier:$(git rev-parse --short HEAD) -t vndg/signalrnotifier:latest .
1010

11-
Write-Host "Build Web Notifier..."
11+
echo "Build Web Notifier..."
1212
docker build -f samples/WebNotifier/Dockerfile -t vndg/webnotifier:$(git rev-parse --short HEAD) -t vndg/webnotifier:latest .

src/NetCoreKit.Infrastructure.Bus.Kafka/DispatchedEventBus.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task Publish<TMessage>(TMessage @event, params string[] topics)
4242
if (topics.Length <= 0) throw new CoreException("[NCK] Publish - Topic to publish should be at least one.");
4343

4444
using (var producer = new Producer<Null, TMessage>(
45-
new Dictionary<string, object> {["bootstrap.servers"] = _brokerList},
45+
ConstructConfig(_brokerList, true),
4646
null,
4747
new ProtoSerializer<TMessage>()))
4848
{
@@ -180,7 +180,7 @@ private static IDictionary<string, object> ConstructConfig(string brokerList, bo
180180
//["debug"] = "all",
181181
["default.topic.config"] = new Dictionary<string, object>
182182
{
183-
["auto.offset.reset"] = "latest"
183+
["auto.offset.reset"] = "smallest"
184184
}
185185
};
186186
}

src/NetCoreKit.Infrastructure.Bus.Kafka/KafkaOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ namespace NetCoreKit.Infrastructure.Bus.Kafka
22
{
33
public class KafkaOptions
44
{
5-
public string Brokers { get; set; } = "127.0.0.1:9092";
5+
public string Brokers { get; set; } = "kafka-server:9092";
66
}
77
}

0 commit comments

Comments
 (0)