From a1034feabe78b038273616318b5eacf1c3506e90 Mon Sep 17 00:00:00 2001 From: Cesar De la Torre Date: Thu, 17 May 2018 18:39:05 -0700 Subject: [PATCH] Updated 10. Setting the solution up in AKS (Azure Kubernetes Service) (markdown) --- ...on-up-in-AKS-(Azure-Kubernetes-Service).md | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/10.-Setting-the-solution-up-in-AKS-(Azure-Kubernetes-Service).md b/10.-Setting-the-solution-up-in-AKS-(Azure-Kubernetes-Service).md index 724a445..9964d8e 100644 --- a/10.-Setting-the-solution-up-in-AKS-(Azure-Kubernetes-Service).md +++ b/10.-Setting-the-solution-up-in-AKS-(Azure-Kubernetes-Service).md @@ -242,7 +242,7 @@ The parameter `configFile` is important (and mandatory) because it contains the If the configuration file name you provide is `conf_local.yaml`, in addition to the application containers, it will deploy the infrastructure containers (that is, SQL Server container, RabbitMQ container, Redis container and MongoDB container will also be deployed into the Kubernetes cluster). -If the configuration file name you provide is `conf_cloud.yml` it will just deploy the application containers. All the infrastructure should be deployed as Azure PaaS services such as Azure SQL Database, Azure Redis, Azure CosmosDB and Azure Service Bus instead of the dev/test infrastructure containers). +If the configuration file name you provide is `conf_cloud.yml` it will just deploy the application containers. All the infrastructure should be deployed as Azure PaaS services such as Azure SQL Database, Azure Redis, Azure CosmosDB and Azure Service Bus instead of the dev/test infrastructure containers). This file is, however, provided just as a reference file because it doesn't have valid values for Azure resources. You'd need to provide your Azure configuration if you want to use infrastructure resources which are external to the Kubernetes cluster. The execution will start like the following: @@ -250,58 +250,47 @@ The execution will start like the following: The script will build the .NET code (microservices and ASP.NET web apps) and build their corresponding Docker images, push the later to your ACR registry, and deploy the containers from ACR into your Kubernetes cluster. -You can watch the deployment unfold from the Kubernetes web interface: -run `kubectl proxy` and open a browser to [localhost:8001/#!/deployment](localhost:8001/#!/deployment) +Notice that the first time you build the Docker images it'll take quite some time. + +Once the Docker images are built (wait a few minutes), you can watch the deployment unfold from the Kubernetes web interface: + +run `kubectl proxy` and open a browser to [http://localhost:8001/#!/deployment](http://localhost:8001/#!/deployment) -### Pods configuration file +### Possible parameters for the deploy.ps1 script -When deploying to k8s the script needs the `configFile` parameter with the location of the YAML configuration file. This file contains the configuration of the pods. The file is a .YAML file. For reference another configuration file (conf_cloud.yaml) is provided but without valid values. +The script accepts the following parameters: -If you deploy the infrastructure containers use `conf_local.yaml` as a value for `configFile` parameter. If you don't deploy the infrastructure containers use your own configuration file with the correct values. - -### Parameters of the deploy.ps1 script - -The script accepts following parameters: - -+ `registry`: Name of the Docker registry to use. If not passed DockerHub is assumed ++ `registry`: Fully qualified name of the Docker registry to use, like your ACR registry such as `youreshopacrregistry.azurecr.io`. If not provided, DockerHub registry is assumed. + `dockerUser`: Login to use for the Docker registry (if needed) + `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 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. ++ `execPath`: Location of `kubectl` (if not in the path env-var). If provided, it must finish with the '/' 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 in your local PC. ++ `configFile`: Location of the Yaml file (such as `conf_local.yaml`) 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 Kuberentes. If not provided, the name of the current branch in Git is used. + `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** -+ `buildBits`: means that the source code of eShopOnContainers will be built. If you have built your code (and have all projects published in `obj/Docker/publish`) do not pass this parameter. Default value is `false` + `buildImages`: If `true` (default value) Docker images are built and pushed in the Docker registry. If you set this parameter to `false`, Docker images won't be built nor pushed in the Docker registry (but k8s' deployments and services will be redeployed). + `deployInfrastructure`: If `true` infrastructure containers (rabbitmq, mongo, redis, sql) will be deployed in k8s. If `false` those containers (and its related deployments and services in k8s) won't be deployed. + `dockerOrg`: Name of the organization in the registry where the images are (or will be pushed). Default value is `eshop` (which has images provided by Microsoft) -**Important:** If you **don't pass the `-buildBits $true` the script won't build and publish the projects** to their `obj/Docker/publish` folder. If any project is not published, you'll be receiving errors like: - -``` -ERROR: Service 'xxxxxxx' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder123456789/obj/Docker/publish: no such file or directory -``` - ### 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 `conf_local.yml` file: +* Build all the images, push the images in a organization called `foo` in DOCKER HUB (instead of ACR). Images will be tagged with my current git branch and containers will use the configuration set in `conf_local.yml` file when deployed all the containers in Kuberentes, including infrastructure containers: ``` -./deploy.ps1 -buildBits $true -dockerOrg foo -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile conf_local.yml +./deploy.ps1 -buildImages $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 `conf_cloud` file. +* Do not build Docker images. Create Kubernetes deployments that will pull images from my private repository such as in ACR registry, in the `foo` organization, using the tag `latest`. Containers will use the configuration set in `conf_cloud.yml` file. ``` -./deploy.ps1 -buildImages $false -dockerOrg foo -registry MY_REGISTRY_FQDN -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile conf_cloud.yml -imageTag master +./deploy.ps1 -buildImages $false -dockerOrg foo -registry MY_REGISTRY_FQDN -dockerUser MY_USER -dockerPassword MY_PASSWORD -configFile conf_cloud.yml -imageTag latest ``` -Deploy k8s using public images that Microsoft provides: +* Deploy all containers (including infrastructure containers) into Kuberentes using the public eShopOnContainers images that Microsoft provides at Docker Hub, using the tag `dev`: ``` -./deploy.ps1 -buildImages $false -configFile conf_local.yml -imageTag master +./deploy.ps1 -buildImages $false -configFile conf_local.yml -imageTag dev ```