k8s deployment
config moved from custom json to standard k8s yaml
This commit is contained in:
parent
c997fe0881
commit
4fe02d9b44
@ -45,7 +45,7 @@ The script accepts following parameters:
|
||||
+ `dockerPassword`: Password to use for the Docker registry (if needed)
|
||||
+ `execPath`: Location of `kubectl` (if not in the path). If passed must finish with the path character.
|
||||
+ `kubeconfigPath`: Location of the `kubectl` configuration file. **This parameter is used only in the CI pipeline**, so you don't need to pass it when invoking the script using the CLI.
|
||||
+ `configFile`: Location of the JSON file with the configuration of the pods. **This parameter is mandatory**
|
||||
+ `configFile`: Location of the Yaml file with the `externalcfg` configmap to be deployed. This configmap is used to configure the Pod's environment **This parameter is mandatory**
|
||||
+ `imageTag`: Tag of the images to deploy to k8s. If not passed the name of the current branch is used.
|
||||
+ `externalDns`: External DNS name of the k8s. This is only needed if you have configured a DNS that points to your k8s external IP. If you don't have any DNS configured do not pass this parameter.
|
||||
+ `deployCI`: If `true` means that script is running under the context of a VSTS Hosted Build Agent. **You should never use this parameter from CLI**
|
||||
@ -56,20 +56,20 @@ The script accepts following parameters:
|
||||
|
||||
### Typical usages of the script:
|
||||
|
||||
Build all projects, and deploy all them in k8s including infrastructure containers in a organization called `foo` in Docker Hub. Images will be tagged with my current git branch and containers will use the configuration set in `local.json` file:
|
||||
Build all projects, and deploy all them in k8s including infrastructure containers in a organization called `foo` in Docker Hub. Images will be tagged with my current git branch and containers will use the configuration set in `conf_local.yml` file:
|
||||
|
||||
```
|
||||
./deploy.ps1 -buildBits $true -dockerOrg foo -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile local.json
|
||||
./deploy.ps1 -buildBits $true -dockerOrg foo -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile conf_local.yml
|
||||
```
|
||||
|
||||
Do not build any project and don't rebuild docker images. Create k8s deployments that will pull images from my private repository, in the `foo` organization, using the tag `latest`. Containers will use the configuration set in `cloud.json` file.
|
||||
Do not build any project and don't rebuild docker images. Create k8s deployments that will pull images from my private repository, in the `foo` organization, using the tag `latest`. Containers will use the configuration set in `conf_cloud` file.
|
||||
|
||||
```
|
||||
./deploy.ps1 -buildImages false -dockerOrg foo -registry MY_REGISTRY_FQDN -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile cloud.json -imageTag master
|
||||
./deploy.ps1 -buildImages $false -dockerOrg foo -registry MY_REGISTRY_FQDN -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile conf_cloud.yml -imageTag master
|
||||
```
|
||||
|
||||
Deploy k8s using public images that Microsoft provides:
|
||||
|
||||
```
|
||||
./deploy.ps1 -buildImages false --configFile local.json -imageTag master
|
||||
./deploy.ps1 -buildImages $false -configFile conf_local.yml -imageTag master
|
||||
```
|
@ -1,31 +0,0 @@
|
||||
{
|
||||
"sql": {
|
||||
"catalog": "Catalog SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)",
|
||||
"identity":"Identity SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)",
|
||||
"ordering":"Ordering SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)",
|
||||
"marketing":"Marketing SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)"
|
||||
},
|
||||
"nosql": {
|
||||
"locations": {
|
||||
"constr": "Locations MongoDb ConnectionString",
|
||||
"db": "LocationsDb"
|
||||
},
|
||||
"marketing": {
|
||||
"constr": "Marketing MongoDb ConnectionString",
|
||||
"db": "MarketingDb"
|
||||
}
|
||||
},
|
||||
"redis": {
|
||||
"basket" : "REDIS CONNECTION STRING FOR BASKET",
|
||||
"keystore": "REDIS CONNECTION STRING FOR KEYSTORE"
|
||||
},
|
||||
"servicebus": {
|
||||
"use_azure": "TRUE IF USE AZURE SB (FALSE FOR USING RABBITMQ)",
|
||||
"ordering": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)",
|
||||
"marketing": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)",
|
||||
"locations": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)",
|
||||
"payment": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)",
|
||||
"basket": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)",
|
||||
"catalog": "CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)"
|
||||
}
|
||||
}
|
35
k8s/conf_cloud.yml
Normal file
35
k8s/conf_cloud.yml
Normal file
@ -0,0 +1,35 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: externalcfg
|
||||
labels:
|
||||
app: eshop
|
||||
data:
|
||||
# Basket.API entries
|
||||
BasketBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
BasketRedisConStr: REDIS CONNECTION STRING FOR BASKET
|
||||
# Catalog.API entries
|
||||
CatalogBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
CatalogSqlDb: Catalog SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)
|
||||
# Identity.API entries
|
||||
IdentitySqlDb: Identity SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)
|
||||
# Locations.API entries
|
||||
LocationsBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
LocationsNoSqlDb: Locations MongoDb ConnectionString
|
||||
LocationsNoSqlDbName: Locations MongoDb database (LocationsDb)
|
||||
# Marketing.API entries
|
||||
MarketingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
MarketingNoSqlDb: Marketing MongoDb ConnectionString
|
||||
MarketingNoSqlDbName: Marketing MongoDb database (MarketingDb)
|
||||
MarketingSqlDb: Marketing SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)
|
||||
# Ordering.API entries
|
||||
OrderingBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
OrderingSqlDb: Ordering SQL SERVER CONNECTION STRING (Server=xxxx;Intial Catalog=yyy;....)
|
||||
# Payment.API entries
|
||||
PaymentBus: CONNECTION_STRING (NAME OF RABBITMQ CONTAINER OR Endpoint=sb://XXXX in case of using Azure)
|
||||
# GracePeriodManager entries
|
||||
GracePeriodTime: "5" # Grace period duration (time when you can cancel order) in minutes
|
||||
GracePeriodCheckUpdateTime: "60000" # Interval time to check new Order status (in milliseconds)
|
||||
# Global entries
|
||||
UseAzureServiceBus: "TRUE" IF USE AZURE SB ("FALSE" FOR USING RABBITMQ)
|
||||
keystore: REDIS CONNECTION STRING FOR KEYSTORE
|
26
k8s/conf_local.yml
Normal file
26
k8s/conf_local.yml
Normal file
@ -0,0 +1,26 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: externalcfg
|
||||
labels:
|
||||
app: eshop
|
||||
data:
|
||||
BasketBus: rabbitmq
|
||||
BasketRedisConStr: basket-data
|
||||
CatalogBus: rabbitmq
|
||||
CatalogSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word;
|
||||
IdentitySqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word;
|
||||
LocationsBus: rabbitmq
|
||||
LocationsNoSqlDb: mongodb://nosql-data
|
||||
LocationsNoSqlDbName: LocationsDb
|
||||
MarketingBus: rabbitmq
|
||||
MarketingNoSqlDb: mongodb://nosql-data
|
||||
MarketingNoSqlDbName: MarketingDb
|
||||
MarketingSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word;
|
||||
OrderingBus: rabbitmq
|
||||
OrderingSqlDb: Server=sql-data;Initial Catalog=Microsoft.eShopOnContainers.Services.OrderingDb;User Id=sa;Password=Pass@word;
|
||||
PaymentBus: rabbitmq
|
||||
GracePeriodTime: "1"
|
||||
GracePeriodCheckUpdateTime: "60000"
|
||||
UseAzureServiceBus: "False"
|
||||
keystore: keystore-data
|
@ -51,18 +51,6 @@ if ([string]::IsNullOrEmpty($imageTag)) {
|
||||
}
|
||||
Write-Host "Docker image Tag: $imageTag" -ForegroundColor Yellow
|
||||
|
||||
# Read config to use
|
||||
$config = Get-Content -Raw -Path $configFile | ConvertFrom-Json
|
||||
if ($debugMode) {
|
||||
Write-Host "[DEBUG]: Using following JSON config: " -ForegroundColor Yellow
|
||||
$json = ConvertTo-Json $config -Depth 5
|
||||
Write-Host $json
|
||||
if (-not $deployCI) {
|
||||
Write-Host "[DEBUG]: Press a key " -ForegroundColor Yellow
|
||||
[System.Console]::Read()
|
||||
}
|
||||
}
|
||||
|
||||
# building and publishing docker images if needed
|
||||
if($buildBits) {
|
||||
Write-Host "Building and publishing eShopOnContainers..." -ForegroundColor Yellow
|
||||
@ -166,27 +154,9 @@ ExecKube -cmd 'create configmap urls `
|
||||
|
||||
ExecKube -cmd 'label configmap urls app=eshop'
|
||||
|
||||
Write-Host "Applying external configuration from json" -ForegroundColor Yellow
|
||||
Write-Host "Deploying configuration from $configFile" -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=MarketingNoSqlDb=$($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=CatalogBus=$($config.servicebus.catalog) `
|
||||
--from-literal=PaymentBus=$($config.servicebus.payment) `
|
||||
--from-literal=UseAzureServiceBus=$($config.servicebus.use_azure) `
|
||||
--from-literal=keystore=$($config.redis.keystore) '
|
||||
ExecKube -cmd 'label configmap externalcfg app=eshop'
|
||||
ExecKube -cmd "create -f $configFile"
|
||||
|
||||
Write-Host "Creating deployments..." -ForegroundColor Yellow
|
||||
ExecKube -cmd 'create -f deployments.yaml'
|
||||
|
@ -173,6 +173,53 @@ spec:
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: graceperiodmanager
|
||||
spec:
|
||||
paused: true
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: graceperiodmanager
|
||||
component: ordering
|
||||
spec:
|
||||
containers:
|
||||
- name: graceperiodmanager
|
||||
image: eshop/graceperiodmanager
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: ConnectionString
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: externalcfg
|
||||
key: OrderingSqlDb
|
||||
- name: EventBusConnection
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: externalcfg
|
||||
key: GracePeriodManagerBus
|
||||
- name: GracePeriodTime
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: externalcfg
|
||||
key: GracePeriodTime
|
||||
- name: CheckUpdateTime
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: externalcfg
|
||||
key: GracePeriodCheckUpdateTime
|
||||
- name: AzureServiceBusEnabled
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: externalcfg
|
||||
key: UseAzureServiceBus
|
||||
ports:
|
||||
- containerPort: 80
|
||||
imagePullSecrets:
|
||||
- name: registry-key
|
||||
---
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: locations
|
||||
spec:
|
||||
|
@ -1,31 +0,0 @@
|
||||
{
|
||||
"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",
|
||||
"keystore": "keystore-data"
|
||||
},
|
||||
"servicebus": {
|
||||
"use_azure": false,
|
||||
"ordering": "rabbitmq",
|
||||
"marketing": "rabbitmq",
|
||||
"locations": "rabbitmq",
|
||||
"payment": "rabbitmq",
|
||||
"basket": "rabbitmq",
|
||||
"catalog": "rabbitmq"
|
||||
}
|
||||
}
|
@ -56,6 +56,20 @@ spec:
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: eshop
|
||||
component: graceperiodmanager
|
||||
name: graceperiodmanager
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
selector:
|
||||
app: eshop
|
||||
component: graceperiodmanager
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: eshop
|
||||
|
Loading…
x
Reference in New Issue
Block a user