Skip to content

Commit

Permalink
Merge pull request #10 from vany0114/gke
Browse files Browse the repository at this point in the history
GKE
  • Loading branch information
vany0114 committed Apr 2, 2020
2 parents 69e46d1 + 594a963 commit 0e81d0d
Show file tree
Hide file tree
Showing 41 changed files with 768 additions and 39 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.1.0
**Support to deploy on Cloud K8s cluter:**
* Adjust manifests to deploy in a cloud cluster as a cloud native solution
* Deployed, ran and tested on Google Kubernetes Engine (GKE)

## 2.0.4
**Health checks implementation & ConfigMap set up:**
* Add health checks to all microservices
Expand Down
12 changes: 12 additions & 0 deletions ExternalSystem/PaymentService/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.2",
"commands": [
"dotnet-ef"
]
}
}
}
1 change: 1 addition & 0 deletions ExternalSystem/PaymentService/PaymentService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<Folder Include="Properties\PublishProfiles\" />
<Folder Include="wwwroot\" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,26 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<ResourceId>/subscriptions/508e9034-6149-4cab-aded-3e97f650ae2a/resourcegroups/Default/providers/Microsoft.Web/sites/DuberPaymentExternalService</ResourceId>
<ResourceGroup>Default</ResourceGroup>
<ResourceId>/subscriptions/b9fa199b-d651-4969-a504-266371834927/resourcegroups/duber/providers/Microsoft.Web/sites/PaymentServiceExternal</ResourceId>
<ResourceGroup>duber</ResourceGroup>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://duberpaymentexternalservice.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<SiteUrlToLaunchAfterPublish>https://paymentserviceexternal.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>8504d9b8-c4e8-4172-8da3-cbd9971e3207</ProjectGuid>
<MSDeployServiceURL>duberpaymentexternalservice.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>DuberPaymentExternalService</DeployIisAppPath>
<SelfContained>false</SelfContained>
<MSDeployServiceURL>paymentserviceexternal.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>PaymentServiceExternal</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$DuberPaymentExternalService</UserName>
<UserName>$PaymentServiceExternal</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<InstallAspNetCoreSiteExtension>False</InstallAspNetCoreSiteExtension>
</PropertyGroup>
</Project>
23 changes: 23 additions & 0 deletions deploy/k8s/gke/default-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: default-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- backend:
serviceName: trip
servicePort: 80
path: /services/trip/(.*)
- backend:
serviceName: invoice
servicePort: 80
path: /services/invoice/(.*)
- backend:
serviceName: frontend
servicePort: 80
path: /(.*)
26 changes: 26 additions & 0 deletions deploy/k8s/gke/delete-resources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# configmap
kubectl delete cm env-config

# common ingress
kubectl delete ing default-ingress

# invoice
kubectl delete deploy invoice
kubectl delete svc invoice
kubectl delete hpa invoice

# trip
kubectl delete deploy trip
kubectl delete hpa trip
kubectl delete svc trip

# website
kubectl delete deploy frontend
kubectl delete hpa frontend
kubectl delete svc frontend

#notificatiosn
kubectl delete deploy notifications
kubectl delete hpa notifications
kubectl delete ing notifications
kubectl delete svc notifications
26 changes: 26 additions & 0 deletions deploy/k8s/gke/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# configmap
kubectl apply -f env-config.yaml

# common ingress
kubectl apply -f default-ingress.yaml

# invoice
kubectl apply -f invoice\invoice-deployment.yaml
kubectl apply -f invoice\invoice-service.yaml
kubectl apply -f invoice\invoice-hpa.yaml

# trip
kubectl apply -f trip\trip-deployment.yaml
kubectl apply -f trip\trip-hpa.yaml
kubectl apply -f trip\trip-service.yaml

# website
kubectl apply -f website\website-deployment.yaml
kubectl apply -f website\website-hpa.yaml
kubectl apply -f website\website-service.yaml

#notificatiosn
kubectl apply -f notifications\notifications-deployment.yaml
kubectl apply -f notifications\notifications-hpa.yaml
kubectl apply -f notifications\notifications-ingress.yaml
kubectl apply -f notifications\notifications-service.yaml
20 changes: 20 additions & 0 deletions deploy/k8s/gke/env-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
data:
ASPNETCORE_ENVIRONMENT: Production
ConnectionStrings__InvoiceDB: {your invoice db connection string}
ConnectionStrings__WebsiteDB: {your website db connection string}
ConnectionStrings__SignalrBackPlane: {your redis connection string}
EventStoreConfiguration__ConnectionString: {your mongo db connection string}
EventBusConnection: {your service bus connection string}
EventBusUserName: {your rabbitmq user}
EventBusPassword: {your rabbitmq password}
PaymentServiceBaseUrl: {your payment service url}
InvoiceApiSettings__BaseUrl: http://invoice
TripApiSettings__BaseUrl: http://trip
TripApiSettings__NotificationsClientUrl: http://{your load balancer ip}/notifications
TripApiSettings__NotificationsServerUrl: http://notifications
AzureServiceBusEnabled: "false"
IsDeployedOnCluster: "true"
62 changes: 62 additions & 0 deletions deploy/k8s/gke/invoice/invoice-deployment-with-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: invoice
spec:
selector:
matchLabels:
app: invoice
replicas: 1
template:
metadata:
labels:
app: invoice
spec:
containers:
- name: invoice
image: vany0114/duber.invoice.api
imagePullPolicy: Always
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
envFrom:
- configMapRef:
name: env-config
env:
- name: ReverseProxyPrefix
value: "services/invoice"
livenessProbe:
httpGet:
port: 80
path: /liveness
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /readiness
port: 80
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 5
ports:
- containerPort: 80
- name: cloudsql-proxy
image: gcr.io/cloudsql-docker/gce-proxy:1.16
command: ["/cloud_sql_proxy",
"-instances=<replace for your GC instance SQL name>=tcp:3306",
"-credential_file=/secrets/cloudsql/creadentials.json"]
securityContext:
runAsUser: 2 # non-root user
allowPrivilegeEscalation: false
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
volumes:
- name: cloudsql-instance-credentials
secret:
secretName: cloudsql-instance-credentials
46 changes: 46 additions & 0 deletions deploy/k8s/gke/invoice/invoice-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: invoice
spec:
selector:
matchLabels:
app: invoice
replicas: 1
template:
metadata:
labels:
app: invoice
spec:
containers:
- name: invoice
image: vany0114/duber.invoice.api
imagePullPolicy: Always
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
cpu: "500m"
envFrom:
- configMapRef:
name: env-config
env:
- name: ReverseProxyPrefix
value: "services/invoice"
livenessProbe:
httpGet:
port: 80
path: /liveness
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /readiness
port: 80
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 5
ports:
- containerPort: 80
12 changes: 12 additions & 0 deletions deploy/k8s/gke/invoice/invoice-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: invoice
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: invoice
minReplicas: 2
maxReplicas: 4
targetCPUUtilizationPercentage: 50
12 changes: 12 additions & 0 deletions deploy/k8s/gke/invoice/invoice-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: invoice
spec:
selector:
app: invoice
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
43 changes: 43 additions & 0 deletions deploy/k8s/gke/notifications/notifications-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: notifications
spec:
selector:
matchLabels:
app: notifications
replicas: 1
template:
metadata:
labels:
app: notifications
spec:
containers:
- name: notifications
image: vany0114/duber.trip.notifications
imagePullPolicy: Always
resources:
requests:
memory: "128Mi"
cpu: "200m"
limits:
memory: "256Mi"
cpu: "600m"
envFrom:
- configMapRef:
name: env-config
livenessProbe:
httpGet:
port: 80
path: /liveness
initialDelaySeconds: 10
periodSeconds: 10
readinessProbe:
httpGet:
path: /readiness
port: 80
initialDelaySeconds: 30
periodSeconds: 60
timeoutSeconds: 5
ports:
- containerPort: 80
12 changes: 12 additions & 0 deletions deploy/k8s/gke/notifications/notifications-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: notifications
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: notifications
minReplicas: 4
maxReplicas: 5
targetCPUUtilizationPercentage: 50
17 changes: 17 additions & 0 deletions deploy/k8s/gke/notifications/notifications-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: notifications
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/affinity: cookie
nginx.ingress.kubernetes.io/session-cookie-path: /notifications/
nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
rules:
- http:
paths:
- backend:
serviceName: notifications
servicePort: 80
path: /notifications/(.*)
12 changes: 12 additions & 0 deletions deploy/k8s/gke/notifications/notifications-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: notifications
spec:
selector:
app: notifications
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
Loading

0 comments on commit 0e81d0d

Please sign in to comment.