Skip to content

Commit 27e4041

Browse files
committed
#15 add k8s and dockerfile
1 parent 9cc1c07 commit 27e4041

28 files changed

+322
-40
lines changed

samples/Contracts/Project.cs

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// <auto-generated>
22
// Generated by the protocol buffer compiler. DO NOT EDIT!
3-
// source: protos/project.proto
3+
// source: samples/Contracts/protos/project.proto
44
// </auto-generated>
55
#pragma warning disable 1591, 0612, 3021
66
#region Designer generated code
@@ -11,11 +11,11 @@
1111
using scg = global::System.Collections.Generic;
1212
namespace Project.Proto {
1313

14-
/// <summary>Holder for reflection information generated from protos/project.proto</summary>
14+
/// <summary>Holder for reflection information generated from samples/Contracts/protos/project.proto</summary>
1515
public static partial class ProjectReflection {
1616

1717
#region Descriptor
18-
/// <summary>File descriptor for protos/project.proto</summary>
18+
/// <summary>File descriptor for samples/Contracts/protos/project.proto</summary>
1919
public static pbr::FileDescriptor Descriptor {
2020
get { return descriptor; }
2121
}
@@ -24,12 +24,14 @@ public static partial class ProjectReflection {
2424
static ProjectReflection() {
2525
byte[] descriptorData = global::System.Convert.FromBase64String(
2626
string.Concat(
27-
"ChRwcm90b3MvcHJvamVjdC5wcm90bxINcHJvamVjdC5wcm90byIhChFQcm9q",
28-
"ZWN0Q3JlYXRlZE1zZxIMCgROYW1lGAEgASgJYgZwcm90bzM="));
27+
"CiZzYW1wbGVzL0NvbnRyYWN0cy9wcm90b3MvcHJvamVjdC5wcm90bxINcHJv",
28+
"amVjdC5wcm90bxofZ29vZ2xlL3Byb3RvYnVmL3RpbWVzdGFtcC5wcm90byJR",
29+
"ChFQcm9qZWN0Q3JlYXRlZE1zZxIMCgROYW1lGAEgASgJEi4KCk9jY3VycmVk",
30+
"T24YAiABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wYgZwcm90bzM="));
2931
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
30-
new pbr::FileDescriptor[] { },
32+
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
3133
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
32-
new pbr::GeneratedClrTypeInfo(typeof(global::Project.Proto.ProjectCreatedMsg), global::Project.Proto.ProjectCreatedMsg.Parser, new[]{ "Name" }, null, null, null)
34+
new pbr::GeneratedClrTypeInfo(typeof(global::Project.Proto.ProjectCreatedMsg), global::Project.Proto.ProjectCreatedMsg.Parser, new[]{ "Name", "OccurredOn" }, null, null, null)
3335
}));
3436
}
3537
#endregion
@@ -62,6 +64,7 @@ public ProjectCreatedMsg() {
6264
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
6365
public ProjectCreatedMsg(ProjectCreatedMsg other) : this() {
6466
name_ = other.name_;
67+
occurredOn_ = other.occurredOn_ != null ? other.occurredOn_.Clone() : null;
6568
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
6669
}
6770

@@ -81,6 +84,17 @@ public string Name {
8184
}
8285
}
8386

87+
/// <summary>Field number for the "OccurredOn" field.</summary>
88+
public const int OccurredOnFieldNumber = 2;
89+
private global::Google.Protobuf.WellKnownTypes.Timestamp occurredOn_;
90+
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
91+
public global::Google.Protobuf.WellKnownTypes.Timestamp OccurredOn {
92+
get { return occurredOn_; }
93+
set {
94+
occurredOn_ = value;
95+
}
96+
}
97+
8498
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
8599
public override bool Equals(object other) {
86100
return Equals(other as ProjectCreatedMsg);
@@ -95,13 +109,15 @@ public bool Equals(ProjectCreatedMsg other) {
95109
return true;
96110
}
97111
if (Name != other.Name) return false;
112+
if (!object.Equals(OccurredOn, other.OccurredOn)) return false;
98113
return Equals(_unknownFields, other._unknownFields);
99114
}
100115

101116
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
102117
public override int GetHashCode() {
103118
int hash = 1;
104119
if (Name.Length != 0) hash ^= Name.GetHashCode();
120+
if (occurredOn_ != null) hash ^= OccurredOn.GetHashCode();
105121
if (_unknownFields != null) {
106122
hash ^= _unknownFields.GetHashCode();
107123
}
@@ -119,6 +135,10 @@ public void WriteTo(pb::CodedOutputStream output) {
119135
output.WriteRawTag(10);
120136
output.WriteString(Name);
121137
}
138+
if (occurredOn_ != null) {
139+
output.WriteRawTag(18);
140+
output.WriteMessage(OccurredOn);
141+
}
122142
if (_unknownFields != null) {
123143
_unknownFields.WriteTo(output);
124144
}
@@ -130,6 +150,9 @@ public int CalculateSize() {
130150
if (Name.Length != 0) {
131151
size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
132152
}
153+
if (occurredOn_ != null) {
154+
size += 1 + pb::CodedOutputStream.ComputeMessageSize(OccurredOn);
155+
}
133156
if (_unknownFields != null) {
134157
size += _unknownFields.CalculateSize();
135158
}
@@ -144,6 +167,12 @@ public void MergeFrom(ProjectCreatedMsg other) {
144167
if (other.Name.Length != 0) {
145168
Name = other.Name;
146169
}
170+
if (other.occurredOn_ != null) {
171+
if (occurredOn_ == null) {
172+
occurredOn_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
173+
}
174+
OccurredOn.MergeFrom(other.OccurredOn);
175+
}
147176
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
148177
}
149178

@@ -159,6 +188,13 @@ public void MergeFrom(pb::CodedInputStream input) {
159188
Name = input.ReadString();
160189
break;
161190
}
191+
case 18: {
192+
if (occurredOn_ == null) {
193+
occurredOn_ = new global::Google.Protobuf.WellKnownTypes.Timestamp();
194+
}
195+
input.ReadMessage(occurredOn_);
196+
break;
197+
}
162198
}
163199
}
164200
}

samples/Contracts/protos/project.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ syntax = "proto3";
22

33
package project.proto;
44

5+
import "google/protobuf/timestamp.proto";
6+
57
message ProjectCreatedMsg {
68
string Name = 1;
9+
google.protobuf.Timestamp OccurredOn = 2;
710
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: kafka-connect-ui
5+
namespace: default
6+
spec:
7+
containers:
8+
- name: kafka-connect-ui
9+
image: landoop/kafka-connect-ui
10+
env:
11+
- name: CONNECT_URL
12+
value: kafka:9092
13+
resources:
14+
requests:
15+
memory: "64Mi"
16+
cpu: "250m"
17+
limits:
18+
memory: "128Mi"
19+
cpu: "500m"
20+
---
21+
apiVersion: v1
22+
kind: Service
23+
metadata:
24+
name: kafka-connect-ui
25+
namespace: default
26+
labels:
27+
app: kafka-connect-ui
28+
spec:
29+
ports:
30+
- port: 8000
31+
targetPort: 8000
32+
nodePort: 32767
33+
protocol: TCP
34+
name: http
35+
type: NodePort
36+
selector:
37+
app: kafka-connect-ui

samples/Kafka/k8s/kafka-dep.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
name: testclient
5+
namespace: default
6+
spec:
7+
containers:
8+
- name: kafka
9+
image: confluentinc/cp-kafka:4.1.2-2
10+
command:
11+
- sh
12+
- -c
13+
- "exec tail -f /dev/null"
14+
resources:
15+
requests:
16+
memory: "64Mi"
17+
cpu: "250m"
18+
limits:
19+
memory: "128Mi"
20+
cpu: "500m"

samples/Notifier/NetCoreKit.Samples.Notifier.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<LangVersion>latest</LangVersion>
55
<OutputType>Exe</OutputType>
66
<TargetFramework>netcoreapp2.1</TargetFramework>
7+
<TieredCompilation>true</TieredCompilation>
78
</PropertyGroup>
89

910
<ItemGroup>

samples/SignalRNotifier/Dockerfile

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
FROM microsoft/dotnet:2.1.3-aspnetcore-runtime-alpine AS base
22
WORKDIR /app
33

4-
ARG service_version
5-
ENV SERVICE_VERSION ${service_version:-0.0.1}
6-
7-
ARG api_version
8-
ENV API_VERSION ${api_version:-1.0}
9-
10-
ENV ASPNETCORE_URLS http://+:8080
11-
EXPOSE 8080
12-
EXPOSE 44300
4+
ENV ASPNETCORE_URLS http://+:5002
5+
EXPOSE 5002
136

147
FROM microsoft/dotnet:2.1.401-sdk-alpine AS build
158
WORKDIR .

samples/SignalRNotifier/NetCoreKit.Samples.SignalRNotifier.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TieredCompilation>true</TieredCompilation>
56
</PropertyGroup>
67

78
<ItemGroup>
@@ -13,6 +14,7 @@
1314

1415
<ItemGroup>
1516
<ProjectReference Include="..\..\src\NetCoreKit.Domain\NetCoreKit.Domain.csproj" />
17+
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.AspNetCore\NetCoreKit.Infrastructure.AspNetCore.csproj" />
1618
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure.Bus.Kafka\NetCoreKit.Infrastructure.Bus.Kafka.csproj" />
1719
<ProjectReference Include="..\..\src\NetCoreKit.Infrastructure\NetCoreKit.Infrastructure.csproj" />
1820
<ProjectReference Include="..\Contracts\NetCoreKit.Samples.Contracts.csproj" />

samples/SignalRNotifier/Startup.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using Microsoft.Extensions.Configuration;
77
using Microsoft.Extensions.DependencyInjection;
88
using Microsoft.Extensions.Hosting;
9+
using Microsoft.Extensions.Logging;
10+
using NetCoreKit.Infrastructure.AspNetCore.Extensions;
911
using NetCoreKit.Infrastructure.Bus;
1012
using NetCoreKit.Infrastructure.Bus.Kafka;
1113
using NetCoreKit.Samples.SignalRNotifier.Services.Hubs;
@@ -43,11 +45,26 @@ public IServiceProvider ConfigureServices(IServiceCollection services)
4345

4446
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
4547
{
48+
var config = app.ApplicationServices.GetRequiredService<IConfiguration>();
49+
var loggerFactory = app.ApplicationServices.GetRequiredService<ILoggerFactory>();
50+
51+
loggerFactory.AddConsole(config.GetSection("Logging"));
52+
loggerFactory.AddDebug();
53+
4654
if (env.IsDevelopment())
4755
{
4856
app.UseDeveloperExceptionPage();
4957
}
5058

59+
var basePath = config.GetBasePath();
60+
61+
if (!string.IsNullOrEmpty(basePath))
62+
{
63+
var logger = loggerFactory.CreateLogger("init");
64+
logger.LogInformation($"Using PATH BASE '{basePath}'");
65+
app.UsePathBase(basePath);
66+
}
67+
5168
app.UseCors("CorsPolicy");
5269

5370
app.UseSignalR(routes =>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"Hosts": {
3+
"BasePath": "/"
4+
}
5+
}

samples/SignalRNotifier/appsettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"EventBus": {
33
"Brokers": "127.0.0.1:9092"
44
},
5+
"Hosts": {
6+
"BasePath": "/api/"
7+
},
58
"Logging": {
69
"IncludeScopes": false,
710
"LogLevel": {

0 commit comments

Comments
 (0)