You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
6.9 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. # Deploying a Service Fabric cluster based on Linux nodes
  2. ## A. Unsecured cluster (SF Linux cluster)
  3. For a secured cluster, see option B. below.
  4. You can always deploy a SF cluster through the Azure portal, as explained in this article: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-get-started-azure-cluster
  5. However, when creating a cluster, there are quite a few configurations to take into account, like enabling the internal DNS service or Reverse Proxy service, choosing between Linux/Windows, open/publish your application ports in the load-balancer and most of all (the most complex setup) how to create a secure cluster.
  6. Because of those reasons, we have created a set of ARM templates and scripts so you can create, re-create and configure the SF clusters much faster, as explained below:
  7. Within eShopOnContainers root folder, at the folder [..\deploy\az\servicefabric\LinuxContainers](https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/az/servicefabric/LinuxContainers), you can find the ARM template `servicefabricdeploy.json` and its parameters file (`servicefabricdeploy.parameters.json`) to create a Service Fabric cluster environment for Linux Containers.
  8. ## Edit the servicefabricdeploy.parameters.json file
  9. Edit the following params in `servicefabricdeploy.parameters.json` file to set your values:
  10. - clusterName: Name of your SF cluster
  11. - clusterLocation: Datacenter location, like westus or westeurope
  12. - computeLocation: Datacenter location, like westus or westeurope
  13. - adminUserName: user-name for VMs administration
  14. - adminPassword: user-password for VMs administration
  15. - dnsName: Name assigned to your SF dns
  16. Optionally, you could modify which ports are opened in the LoadBalancer for the multiple eShopOnContainer apps and API services.
  17. By default, they are setup as:
  18. - webMvcHttpPort: 5100
  19. - webSpaHttpPort: 5104
  20. - webStatusHttpPort: 5107
  21. - IdSrvHttpRule: 5105
  22. - BasketApiHttpRule: 5103
  23. - CatalogApiHttpRule: 5101
  24. - OrderingApiHttpRule: 5102
  25. - MarketingApiHttpRule: 5110
  26. - LocationsApiHttpRule: 5109
  27. ## Deploy the Service Fabric cluster using the script and ARM templates
  28. Once parameter file is edited you can deploy it using [create-resources script](../readme.md).
  29. For example, to deploy the cluster to a new resourcegroup located in westus, go to `deploy\az` folder and type:
  30. ```
  31. create-resources.cmd servicefabric\LinuxContainers\servicefabricdeploy qa-eshop-sflinux-resgrp -c westus
  32. ```
  33. You should see a similar execution to the following:
  34. ![image](https://user-images.githubusercontent.com/1712635/31638180-15da9f84-b287-11e7-9d4e-604f33690198.png)
  35. Now, if you go to your subscription in Azure, you should be able to see the SF cluster already created and available, like in the following image:
  36. ![image](https://user-images.githubusercontent.com/1712635/31638398-3fc08ad8-b288-11e7-879b-fc4df0daad2b.png)
  37. In this case, this is an unsecured SF cluster with a single Linux node, good for initial tests and getting started with SF.
  38. ## B. Secured cluster (SF Linux cluster)
  39. Within eShopOnContainers root folder, at the folder [..\deploy\az\servicefabric\LinuxContainers](https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/az/servicefabric/LinuxContainers), you can find the ARM template `servicefabricdeploysecured.json` and its parameter file (`servicefabricdeploysecured.parameters.json`) to create a secured Service Fabric cluster environment for Linux Containers (IN THIS CASE, IT IS A SECURED CLUSTER USING A CERTIFICATE).
  40. The ARM template `servicefabricdeploysecured.json` and its parameter file (`servicefabricdeploysecured.parameters.json`) are used to create a service fabric cluster environment for linux containers secured with a certificate.
  41. ## Create Azure Keyvault service
  42. Go to PortalAzure and create a Keyvault service. Make sure Enable access for deployment checkboxes are selected.
  43. ![image](https://user-images.githubusercontent.com/1712635/31638848-9b266530-b28a-11e7-953b-1e3ec1a54f77.png)
  44. ## Generate a certificate in Azure Keyvault
  45. In a POWER-SHELL window, move to the folder [..\deploy\az\servicefabric\LinuxContainers](https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/az/servicefabric/LinuxContainers).
  46. **Select your Azure subscription** You might have [several Azure subscriptions](https://docs.microsoft.com/en-us/cli/azure/account#set) as shown if you type the following.
  47. >```
  48. >az account list
  49. >```
  50. If you have multiple subscription accounts, you first need to select the Azure subscription account you want to target. Type the following:
  51. >```
  52. >az account set --subscription "Your Azure Subscription Name or ID"
  53. >```
  54. Execute the gen-keyvaultcert.ps1 script to generate and download a certificate from Keyvault.
  55. ```
  56. .\gen-keyvaultcert.ps1 -vaultName <your_keyvault_service> -certName <your_cert_name> -certPwd <your_cert_pwd> -subjectName CN=<your_sf_dns_name>.westeurope.cloudapp.azure.com -saveDir C:\Users\<user>\Downloads
  57. ```
  58. You should see a similar execution to the following:
  59. ![image](https://user-images.githubusercontent.com/1712635/31640172-93efcca0-b291-11e7-970e-5b5e6bf07042.png)
  60. IMPORTANT: At this point, copy/cut the .PFX certifiacte file saved in the downloads forlder and save it in a secure place.
  61. ## Install the certificate
  62. Install the certificate (by double-clicking on the .PFX file) under 'Current User' store location (by default location) and check it as exportable.
  63. <img src="https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/img/sf/install-cert.PNG">
  64. ## Editing servicefabricdeploysecured.parameters.json file
  65. Edit the following params in `servicefabricdeploysecured.parameters.json` file to set your values:
  66. - clusterName: Name of your SF cluster
  67. - dnsName: Name assigned to your SF dns
  68. - adminUserName: user name for administration
  69. - adminPassword: user password for administration
  70. - sourceVaultValue: keyvault resource id (check azure keyvault properties)
  71. - certificateUrlValue: certificate url (check azure Keyvault certificate properties)
  72. - certificateThumbprint: certificate thumbprint (check azure Keyvault certificate properties)
  73. Optionally, you can modify which ports are opened in the LoadBalancer for accessing externally to the apps:
  74. - webMvcHttpPort: port externally exposed for the WebMVC app
  75. - webSpaHttpPort: port externally exposed for the WebSPA app
  76. - webStatusHttpPort: port externally exposed for the WebStatus app
  77. - IdSrvHttpRule: port externally exposed for the Identity app
  78. ## Deploy the template
  79. Once parameter file is edited you can deploy it using [create-resources script](../readme.md).
  80. ```
  81. create-resources.cmd servicefabric\LinuxContainers\servicefabricdeploysecured newResourceGroup -c westus
  82. ```
  83. ## Deploy eShopOnServiceFabric with Visual Studio.
  84. Modify the cloud.xml file of each Service Fabric application in PublishProfile directory and set your certificate settings to be able to deploy eshopOnContainers in the secured cluster:
  85. <img src="../../../../img/sf/cloud_publishProfile.png">