Skip to content

Commit 0e81d0d

Browse files
authored
Merge pull request #10 from vany0114/gke
GKE
2 parents 69e46d1 + 594a963 commit 0e81d0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+768
-39
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.1.0
2+
**Support to deploy on Cloud K8s cluter:**
3+
* Adjust manifests to deploy in a cloud cluster as a cloud native solution
4+
* Deployed, ran and tested on Google Kubernetes Engine (GKE)
5+
16
## 2.0.4
27
**Health checks implementation & ConfigMap set up:**
38
* Add health checks to all microservices
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"dotnet-ef": {
6+
"version": "3.1.2",
7+
"commands": [
8+
"dotnet-ef"
9+
]
10+
}
11+
}
12+
}

ExternalSystem/PaymentService/PaymentService.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<Folder Include="Properties\PublishProfiles\" />
910
<Folder Include="wwwroot\" />
1011
</ItemGroup>
1112

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,26 @@ by editing this MSBuild file. In order to learn more about this please visit htt
66
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
77
<PropertyGroup>
88
<WebPublishMethod>MSDeploy</WebPublishMethod>
9-
<ResourceId>/subscriptions/508e9034-6149-4cab-aded-3e97f650ae2a/resourcegroups/Default/providers/Microsoft.Web/sites/DuberPaymentExternalService</ResourceId>
10-
<ResourceGroup>Default</ResourceGroup>
9+
<ResourceId>/subscriptions/b9fa199b-d651-4969-a504-266371834927/resourcegroups/duber/providers/Microsoft.Web/sites/PaymentServiceExternal</ResourceId>
10+
<ResourceGroup>duber</ResourceGroup>
1111
<PublishProvider>AzureWebSite</PublishProvider>
1212
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
1313
<LastUsedPlatform>Any CPU</LastUsedPlatform>
14-
<SiteUrlToLaunchAfterPublish>http://duberpaymentexternalservice.azurewebsites.net</SiteUrlToLaunchAfterPublish>
14+
<SiteUrlToLaunchAfterPublish>https://paymentserviceexternal.azurewebsites.net</SiteUrlToLaunchAfterPublish>
1515
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
1616
<ExcludeApp_Data>False</ExcludeApp_Data>
17+
<TargetFramework>netcoreapp3.1</TargetFramework>
1718
<ProjectGuid>8504d9b8-c4e8-4172-8da3-cbd9971e3207</ProjectGuid>
18-
<MSDeployServiceURL>duberpaymentexternalservice.scm.azurewebsites.net:443</MSDeployServiceURL>
19-
<DeployIisAppPath>DuberPaymentExternalService</DeployIisAppPath>
19+
<SelfContained>false</SelfContained>
20+
<MSDeployServiceURL>paymentserviceexternal.scm.azurewebsites.net:443</MSDeployServiceURL>
21+
<DeployIisAppPath>PaymentServiceExternal</DeployIisAppPath>
2022
<RemoteSitePhysicalPath />
2123
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
2224
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
2325
<EnableMSDeployBackup>True</EnableMSDeployBackup>
24-
<UserName>$DuberPaymentExternalService</UserName>
26+
<UserName>$PaymentServiceExternal</UserName>
2527
<_SavePWD>True</_SavePWD>
2628
<_DestinationType>AzureWebSite</_DestinationType>
29+
<InstallAspNetCoreSiteExtension>False</InstallAspNetCoreSiteExtension>
2730
</PropertyGroup>
2831
</Project>

deploy/k8s/gke/default-ingress.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: extensions/v1beta1
2+
kind: Ingress
3+
metadata:
4+
name: default-ingress
5+
annotations:
6+
kubernetes.io/ingress.class: "nginx"
7+
nginx.ingress.kubernetes.io/rewrite-target: /$1
8+
spec:
9+
rules:
10+
- http:
11+
paths:
12+
- backend:
13+
serviceName: trip
14+
servicePort: 80
15+
path: /services/trip/(.*)
16+
- backend:
17+
serviceName: invoice
18+
servicePort: 80
19+
path: /services/invoice/(.*)
20+
- backend:
21+
serviceName: frontend
22+
servicePort: 80
23+
path: /(.*)

deploy/k8s/gke/delete-resources.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# configmap
2+
kubectl delete cm env-config
3+
4+
# common ingress
5+
kubectl delete ing default-ingress
6+
7+
# invoice
8+
kubectl delete deploy invoice
9+
kubectl delete svc invoice
10+
kubectl delete hpa invoice
11+
12+
# trip
13+
kubectl delete deploy trip
14+
kubectl delete hpa trip
15+
kubectl delete svc trip
16+
17+
# website
18+
kubectl delete deploy frontend
19+
kubectl delete hpa frontend
20+
kubectl delete svc frontend
21+
22+
#notificatiosn
23+
kubectl delete deploy notifications
24+
kubectl delete hpa notifications
25+
kubectl delete ing notifications
26+
kubectl delete svc notifications

deploy/k8s/gke/deploy.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# configmap
2+
kubectl apply -f env-config.yaml
3+
4+
# common ingress
5+
kubectl apply -f default-ingress.yaml
6+
7+
# invoice
8+
kubectl apply -f invoice\invoice-deployment.yaml
9+
kubectl apply -f invoice\invoice-service.yaml
10+
kubectl apply -f invoice\invoice-hpa.yaml
11+
12+
# trip
13+
kubectl apply -f trip\trip-deployment.yaml
14+
kubectl apply -f trip\trip-hpa.yaml
15+
kubectl apply -f trip\trip-service.yaml
16+
17+
# website
18+
kubectl apply -f website\website-deployment.yaml
19+
kubectl apply -f website\website-hpa.yaml
20+
kubectl apply -f website\website-service.yaml
21+
22+
#notificatiosn
23+
kubectl apply -f notifications\notifications-deployment.yaml
24+
kubectl apply -f notifications\notifications-hpa.yaml
25+
kubectl apply -f notifications\notifications-ingress.yaml
26+
kubectl apply -f notifications\notifications-service.yaml

deploy/k8s/gke/env-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: env-config
5+
data:
6+
ASPNETCORE_ENVIRONMENT: Production
7+
ConnectionStrings__InvoiceDB: {your invoice db connection string}
8+
ConnectionStrings__WebsiteDB: {your website db connection string}
9+
ConnectionStrings__SignalrBackPlane: {your redis connection string}
10+
EventStoreConfiguration__ConnectionString: {your mongo db connection string}
11+
EventBusConnection: {your service bus connection string}
12+
EventBusUserName: {your rabbitmq user}
13+
EventBusPassword: {your rabbitmq password}
14+
PaymentServiceBaseUrl: {your payment service url}
15+
InvoiceApiSettings__BaseUrl: http://invoice
16+
TripApiSettings__BaseUrl: http://trip
17+
TripApiSettings__NotificationsClientUrl: http://{your load balancer ip}/notifications
18+
TripApiSettings__NotificationsServerUrl: http://notifications
19+
AzureServiceBusEnabled: "false"
20+
IsDeployedOnCluster: "true"
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: invoice
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: invoice
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: invoice
14+
spec:
15+
containers:
16+
- name: invoice
17+
image: vany0114/duber.invoice.api
18+
imagePullPolicy: Always
19+
resources:
20+
requests:
21+
memory: "128Mi"
22+
cpu: "100m"
23+
limits:
24+
memory: "256Mi"
25+
cpu: "500m"
26+
envFrom:
27+
- configMapRef:
28+
name: env-config
29+
env:
30+
- name: ReverseProxyPrefix
31+
value: "services/invoice"
32+
livenessProbe:
33+
httpGet:
34+
port: 80
35+
path: /liveness
36+
initialDelaySeconds: 10
37+
periodSeconds: 10
38+
readinessProbe:
39+
httpGet:
40+
path: /readiness
41+
port: 80
42+
initialDelaySeconds: 30
43+
periodSeconds: 60
44+
timeoutSeconds: 5
45+
ports:
46+
- containerPort: 80
47+
- name: cloudsql-proxy
48+
image: gcr.io/cloudsql-docker/gce-proxy:1.16
49+
command: ["/cloud_sql_proxy",
50+
"-instances=<replace for your GC instance SQL name>=tcp:3306",
51+
"-credential_file=/secrets/cloudsql/creadentials.json"]
52+
securityContext:
53+
runAsUser: 2 # non-root user
54+
allowPrivilegeEscalation: false
55+
volumeMounts:
56+
- name: cloudsql-instance-credentials
57+
mountPath: /secrets/cloudsql
58+
readOnly: true
59+
volumes:
60+
- name: cloudsql-instance-credentials
61+
secret:
62+
secretName: cloudsql-instance-credentials
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: invoice
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: invoice
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: invoice
14+
spec:
15+
containers:
16+
- name: invoice
17+
image: vany0114/duber.invoice.api
18+
imagePullPolicy: Always
19+
resources:
20+
requests:
21+
memory: "128Mi"
22+
cpu: "100m"
23+
limits:
24+
memory: "256Mi"
25+
cpu: "500m"
26+
envFrom:
27+
- configMapRef:
28+
name: env-config
29+
env:
30+
- name: ReverseProxyPrefix
31+
value: "services/invoice"
32+
livenessProbe:
33+
httpGet:
34+
port: 80
35+
path: /liveness
36+
initialDelaySeconds: 10
37+
periodSeconds: 10
38+
readinessProbe:
39+
httpGet:
40+
path: /readiness
41+
port: 80
42+
initialDelaySeconds: 30
43+
periodSeconds: 60
44+
timeoutSeconds: 5
45+
ports:
46+
- containerPort: 80

0 commit comments

Comments
 (0)