Browse Source

Config files for k8s deployment of all services updated

pull/223/head
Eduard Tomas 7 years ago
parent
commit
18393c9a6a
8 changed files with 319 additions and 12 deletions
  1. +1
    -1
      docker-compose.yml
  2. +5
    -0
      global.json
  3. +41
    -2
      k8s/deploy.ps1
  4. +156
    -8
      k8s/deployments.yaml
  5. +28
    -0
      k8s/eShopOnAzure.json
  6. +27
    -0
      k8s/local.json
  7. +18
    -0
      k8s/nginx.conf
  8. +43
    -1
      k8s/services.yaml

+ 1
- 1
docker-compose.yml View File

@ -108,7 +108,7 @@ services:
- rabbitmq
locations.api:
image: locations.api
image: eshop/locations.api
build:
context: ./src/Services/Location/Locations.API
dockerfile: Dockerfile


+ 5
- 0
global.json View File

@ -0,0 +1,5 @@
{
"sdk": {
"version":"1.0.4"
}
}

+ 41
- 2
k8s/deploy.ps1 View File

@ -5,9 +5,12 @@ Param(
[parameter(Mandatory=$false)][bool]$deployCI,
[parameter(Mandatory=$false)][bool]$useDockerHub,
[parameter(Mandatory=$false)][string]$execPath,
[parameter(Mandatory=$false)][string]$kubeconfigPath
[parameter(Mandatory=$false)][string]$kubeconfigPath,
[parameter(Mandatory=$true)][string]$configFile
)
$debugMode = $PSCmdlet.MyInvocation.BoundParameters["Debug"].IsPresent
function ExecKube($cmd) {
if($deployCI) {
$kubeconfig = $kubeconfigPath + 'config';
@ -20,6 +23,19 @@ function ExecKube($cmd) {
}
}
$config = Get-Content -Raw -Path $configFile | ConvertFrom-Json
if ($debugMode) {
Write-Host "Using following JSON config: "
$json = ConvertTo-Json $config -Depth 5
Write-Host $json
Write-Host "Press a key "
[System.Console]::Read()
}
# Not used when deploying through CI VSTS
if(-not $deployCI) {
$requiredCommands = ("docker", "docker-compose", "kubectl")
@ -54,11 +70,13 @@ ExecKube -cmd 'delete deployments --all'
ExecKube -cmd 'delete services --all'
ExecKube -cmd 'delete configmap config-files'
ExecKube -cmd 'delete configmap urls'
ExecKube -cmd 'delete configmap externalcfg'
# start sql, rabbitmq, frontend deploymentsExecKube -cmd 'delete configmap config-files'
ExecKube -cmd 'create configmap config-files --from-file=nginx-conf=nginx.conf'
ExecKube -cmd 'label configmap config-files app=eshop'
ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml'
# ExecKube -cmd 'create -f sql-data.yaml -f basket-data.yaml -f keystore-data.yaml -f rabbitmq.yaml -f services.yaml -f frontend.yaml'
ExecKube -cmd 'create -f services.yaml -f frontend.yaml'
# building and publishing docker images not necessary when deploying through CI VSTS
if(-not $deployCI) {
@ -109,6 +127,27 @@ ExecKube -cmd 'create configmap urls `
ExecKube -cmd 'label configmap urls app=eshop'
Write-Host "Applying external configuration from json" -ForegroundColor Yellow
ExecKube -cmd 'create configmap externalcfg `
--from-literal=CatalogSqlDb=$($config.sql.catalog) `
--from-literal=IdentitySqlDb=$($config.sql.identity) `
--from-literal=OrderingSqlDb=$($config.sql.ordering) `
--from-literal=MarketingSqlDb=$($config.sql.marketing) `
--from-literal=LocationsNoSqlDb=$($config.nosql.locations.constr) `
--from-literal=LocationsNoSqlDbName=$($config.nosql.locations.db) `
--from-literal=MarketingsNoSqlDb=$($config.nosql.marketing.constr) `
--from-literal=MarketingNoSqlDbName=$($config.nosql.marketing.db) `
--from-literal=BasketRedisConStr=$($config.redis.basket) `
--from-literal=LocationsBus=$($config.servicebus.locations) `
--from-literal=MarketingBus=$($config.servicebus.marketing) `
--from-literal=BasketBus=$($config.servicebus.basket) `
--from-literal=OrderingBus=$($config.servicebus.ordering) `
--from-literal=PaymentBus=$($config.servicebus.payment) '
ExecKube -cmd 'label configmap externalcfg app=eshop'
Write-Host "Creating deployments..." -ForegroundColor Yellow
ExecKube -cmd 'create -f deployments.yaml'


+ 156
- 8
k8s/deployments.yaml View File

@ -18,9 +18,17 @@ spec:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/basket-api
- name: ConnectionString
value: basket-data
valueFrom:
configMapKeyRef:
name: externalcfg
key: BasketRedisConStr
- name: EventBusConnection
value: rabbitmq
valueFrom:
configMapKeyRef:
name: externalcfg
key: BasketBus
- name: AzureServiceBusEnabled
value: "true"
- name: IdentityUrl
valueFrom:
configMapKeyRef:
@ -51,9 +59,10 @@ spec:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/catalog-api
- name: ConnectionString
value: "Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word"
- name: EventBusConnection
value: rabbitmq
valueFrom:
configMapKeyRef:
name: externalcfg
key: CatalogSqlDb
- name: ExternalCatalogBaseUrl
valueFrom:
configMapKeyRef:
@ -84,7 +93,10 @@ spec:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/identity
- name: ConnectionStrings__DefaultConnection
value: "Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word"
valueFrom:
configMapKeyRef:
name: externalcfg
key: IdentitySqlDb
- name: DPConnectionString
value: keystore-data
- name: IsClusterEnv
@ -124,9 +136,114 @@ spec:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/ordering-api
- name: ConnectionString
value: "Server=sql-data;Database=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;"
valueFrom:
configMapKeyRef:
name: externalcfg
key: OrderingSqlDb
- name: EventBusConnection
valueFrom:
configMapKeyRef:
name: externalcfg
key: OrderingBus
- name: AzureServiceBusEnabled
value: "true"
- name: IdentityUrl
valueFrom:
configMapKeyRef:
name: urls
key: IdentityUrl
ports:
- containerPort: 80
imagePullSecrets:
- name: registry-key
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: locations
spec:
paused: true
template:
metadata:
labels:
app: eshop
component: locations
spec:
containers:
- name: locations
image: eshop/locations.api
imagePullPolicy: Always
env:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/locations-api
- name: ConnectionString
valueFrom:
configMapKeyRef:
name: externalcfg
key: LocationsNoSqlDb
- name: Database
valueFrom:
configMapKeyRef:
name: externalcfg
key: LocationsNoSqlDbName
- name: AzureServiceBusEnabled
value: "true"
- name: EventBusConnection
valueFrom:
configMapKeyRef:
name: externalcfg
key: LocationsBus
- name: IdentityUrl
valueFrom:
configMapKeyRef:
name: urls
key: IdentityUrl
ports:
- containerPort: 80
imagePullSecrets:
- name: registry-key
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: marketing
spec:
paused: true
template:
metadata:
labels:
app: eshop
component: marketing
spec:
containers:
- name: marketing
image: eshop/marketing.api
imagePullPolicy: Always
env:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/marketing-api
- name: ConnectionString
valueFrom:
configMapKeyRef:
name: externalcfg
key: MarketingSqlDb
- name: MongoConnectionString
valueFrom:
configMapKeyRef:
name: externalcfg
key: MarketingNoSqlDb
- name: MongoDatabase
valueFrom:
configMapKeyRef:
name: externalcfg
key: MarketingNoSqlDbName
- name: AzureServiceBusEnabled
value: "true"
- name: EventBusConnection
value: rabbitmq
valueFrom:
configMapKeyRef:
name: externalcfg
key: MarketingBus
- name: IdentityUrl
valueFrom:
configMapKeyRef:
@ -139,6 +256,37 @@ spec:
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: payment
spec:
paused: true
template:
metadata:
labels:
app: eshop
component: payment
spec:
containers:
- name: payment
image: eshop/payment.api
imagePullPolicy: Always
env:
- name: ASPNETCORE_URLS
value: http://0.0.0.0:80/payment-api
- name: AzureServiceBusEnabled
value: ·true"
- name: EventBusConnection
valueFrom:
configMapKeyRef:
name: externalcfg
key: PaymentBus
ports:
- containerPort: 80
imagePullSecrets:
- name: registry-key
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: webmvc
spec:


+ 28
- 0
k8s/eShopOnAzure.json View File

@ -0,0 +1,28 @@
{
"sql": {
"catalog": "Server=tcp:eshopsql-ez55a72p6wm62.database.windows.net,1433;Initial Catalog=catalogdb;Persist Security Info=False;User ID=eshop;Password=Pass@word!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"identity":"Server=tcp:eshopsql-ez55a72p6wm62.database.windows.net,1433;Initial Catalog=identitydb;Persist Security Info=False;User ID=eshop;Password=Pass@word!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"ordering":"Server=tcp:eshopsql-ez55a72p6wm62.database.windows.net,1433;Initial Catalog=orderingdb;Persist Security Info=False;User ID=eshop;Password=Pass@word!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"marketing":"Server=tcp:eshopsql-ez55a72p6wm62.database.windows.net,1433;Initial Catalog=marketingdb;Persist Security Info=False;User ID=eshop;Password=Pass@word!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
},
"nosql": {
"locations": {
"constr": "mongodb://eshop-nosqlez55a72p6wm62:l8jMNoLHFXOijAvaVMjHeCwHK8gAR9SovuK86uCOvwfnMhuhwytPKByOPqrQrlsDz9RPFet2J6SzEbBQXLZokA==@eshop-nosqlez55a72p6wm62.documents.azure.com:10255/?ssl=true&replicaSet=globaldb",
"db": "LocationsDb"
},
"marketing": {
"constr": "mongodb://eshop-nosqlez55a72p6wm62:l8jMNoLHFXOijAvaVMjHeCwHK8gAR9SovuK86uCOvwfnMhuhwytPKByOPqrQrlsDz9RPFet2J6SzEbBQXLZokA==@eshop-nosqlez55a72p6wm62.documents.azure.com:10255/?ssl=true&replicaSet=globaldb",
"db": "MarketingDb"
}
},
"redis": {
"basket" : "eshopredisez55a72p6wm62.redis.cache.windows.net"
},
"servicebus": {
"ordering": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Iv+cC7Wgwc8SCrE5AXrguRW6kRMk6vR7crTVBom5nPU=;EntityPath=eshop_event_bus",
"marketing": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Iv+cC7Wgwc8SCrE5AXrguRW6kRMk6vR7crTVBom5nPU=;EntityPath=eshop_event_bus",
"locations": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Iv+cC7Wgwc8SCrE5AXrguRW6kRMk6vR7crTVBom5nPU=;EntityPath=eshop_event_bus",
"payment": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Iv+cC7Wgwc8SCrE5AXrguRW6kRMk6vR7crTVBom5nPU=;EntityPath=eshop_event_bus",
"basket": "Endpoint=sb://eshopsbez55a72p6wm62.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=Iv+cC7Wgwc8SCrE5AXrguRW6kRMk6vR7crTVBom5nPU=;EntityPath=eshop_event_bus"
}
}

+ 27
- 0
k8s/local.json View File

@ -0,0 +1,27 @@
{
"sql": {
"catalog": "Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word;",
"identity":"Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word;",
"ordering":"Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;",
"marketing":"Server=sql.data;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word;"
},
"nosql": {
"locations": {
"constr": "mongodb://nosql.data",
"db": "LocationsDb"
},
"marketing": {
"constr": "mongodb://nosql.data",
"db": "MarketingDb"
}
},
"redis": {
"basket" : "basket.data"
},
"servicebus": {
"ordering": "rabbitmq",
"marketing": "rabbitmq",
"locations": "rabbitmq",
"payment": "rabbitmq"
}
}

+ 18
- 0
k8s/nginx.conf View File

@ -71,6 +71,24 @@ http {
proxy_set_header Host $host;
}
location /marketing-api {
proxy_pass http://marketing;
proxy_redirect off;
proxy_set_header Host $host;
}
location /payment-api {
proxy_pass http://payment;
proxy_redirect off;
proxy_set_header Host $host;
}
location /location-api {
proxy_pass http://location;
proxy_redirect off;
proxy_set_header Host $host;
}
location / {
proxy_pass http://webspa;
proxy_redirect off;


+ 43
- 1
k8s/services.yaml View File

@ -56,6 +56,48 @@ spec:
---
apiVersion: v1
kind: Service
metadata:
labels:
app: eshop
component: locations
name: locations
spec:
ports:
- port: 80
selector:
app: eshop
component: locations
---
apiVersion: v1
kind: Service
metadata:
labels:
app: eshop
component: payment
name: payment
spec:
ports:
- port: 80
selector:
app: eshop
component: payment
---
apiVersion: v1
kind: Service
metadata:
labels:
app: eshop
component: marketing
name: marketing
spec:
ports:
- port: 80
selector:
app: eshop
component: marketing
---
apiVersion: v1
kind: Service
metadata:
labels:
app: eshop
@ -94,4 +136,4 @@ spec:
- port: 80
selector:
app: eshop
component: webspa
component: webspa

Loading…
Cancel
Save