Open Closed

Deploying microservice template to Azure Kubernetes #4788


User avatar
0
jordanchen98 created

If you're creating a bug/problem report, please include the followings:

  • ABP Framework version: v7.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes, microservice template
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi, I am currently using the microservice template generated by abp commercial. I can run all the services without a hitch on my local dev machine. I've switched the database to PostgreSQL and the entire solution runs well on tye.

Currently, I'm in the progress of deploying this solution to Azure Kubernetes using Azure Container Registry as my repository.

What I have set up on Azure Cloud:

  1. All instances of PostgreSQL for each microservice.
  2. Container instances for Kibana, Grafana, Redis, Prometheus, ElasticSearch, and RabbitMQ.
  3. Azure Kubernetes Service
  4. Azure Container Registry
  5. Linked ACR to AKS
  6. Deployed Web Gateway to AKS (Currently hitting CORS origin error when opening into Swagger) (1)
  7. Deployed Auth Server to AKS (Connection Timeout) (2)

Is there any help/guide/documentation regarding this deployment? I am also planning to use Azure CI/CD in the future.

My current deployment procedure is:

  1. Publish to ACR using Visual Studio 2022
  2. Create Deployment yaml in AKS in Azure Portal for the published image
  3. Create Service yaml in AKS in Azure Portal using the deployment (using Load Balancer).

For some reason, when I deploy the Auth Server, the deployment, 'Ready' status is an error. But when running in localhost it runs fine. (3)

(1)

(2)

(3)

Below is my appsettings.json for AuthServer

{
  "App": {
    //"SelfUrl": "https://localhost:44322",
    "SelfUrl": "http://20.92.102.114:4322",
    "CorsOrigins": "https://*.KMS4.com,http://localhost:4200,https://localhost:44307,https://localhost:44325,https://localhost:44353,https://localhost:44367,https://localhost:44388,https://localhost:44381,https://localhost:44361,http://20.92.102.114:4322",
    "RedirectAllowedUrls": "http://localhost:4200,https://localhost:44307,https://localhost:44321",
    "DisablePII": "false"
  },
  "AuthServer": {
    //"Authority": "https://localhost:44322",
    "Authority": "http://20.92.102.114:4322",
    "RequireHttpsMetadata": "true",
    "SwaggerClientId": "WebGateway_Swagger"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "ConnectionStrings": {
    "IdentityService": "User ID=[username];Password=[password];Host=aldankms4.postgres.database.azure.com;Port=5432;Database=KMS4_Identity;Pooling=false",
    "AdministrationService": "User ID=[username];Password=[password];Host=aldankms4.postgres.database.azure.com;Port=5432;Database=KMS4_Administration;Pooling=false",
    "SaasService": "User ID=[username];Password=[password];Host=aldankms4.postgres.database.azure.com;Port=5432;Database=KMS4_Saas;Pooling=false"
  },
  "StringEncryption": {
    "DefaultPassPhrase": "Zk0TJPzHzDaBB6Wa"
  },
  "Redis": {
    //"Configuration": "localhost:6379"
    "Configuration": "kms4.redis.cache.windows.net,abortConnect=false,ssl=true,allowAdmin=true,password=[password]"
  },
  "RabbitMQ": {
    "Connections": {
      "Default": {
        //"HostName": "localhost"
        "HostName": "20.92.102.114"
      }
    },
    "EventBus": {
      "ClientName": "AuthServer",
      "ExchangeName": "KMS4"
    }
  },
  "ElasticSearch": {
    //"Url": "http://localhost:9200"
    "Url": "https://kms4elasticsearch.azurewebsites.net"
  }
}

Below is my appsettings.json for WebGateway

{
  "App": {
    "SelfUrl": "https://localhost:44325",
    "CorsOrigins": "https://*.KMS4.com,http://localhost:4200,https://localhost:44307,http://20.227.27.217:4325"
  },
  "AuthServer": {
    "Authority": "https://localhost:44322",
    "RequireHttpsMetadata": "true",
    "SwaggerClientId": "WebGateway_Swagger"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "AllowedHosts": "*",
  "Redis": {
    //"Configuration": "localhost:6379"
    "Configuration": "kms4.redis.cache.windows.net,abortConnect=false,ssl=true,allowAdmin=true,password=[password]"
  },
  "ElasticSearch": {
    //"Url": "http://localhost:9200"
    "Url": "https://kms4elasticsearch.azurewebsites.net"
  }
}

Thank you!


3 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    You can check https://github.com/abpframework/abp/issues/15601 for swagger ui authorization issue.

    However your problem seems that gateway is still trying to redirect to localhost for AccountService, maybe you have missed overriding the configmap of gateways for production.

    You can also check the Azure deployment scripts and values for eShopOnAbp sample https://github.com/abpframework/eShopOnAbp/tree/main/etc/k8s that i can provide for a sample.

  • User Avatar
    0
    jordanchen98 created

    I've checked the eShopOnAbp sample, its seems that the appsettings.json file is preserved using localhost. I noticed that there is an appsettings.Docker.json for some projects such as webgateway. Is this what docker uses when building the image? Should I implement this as well when I am pushing the image to the ACR?

    I've checked my ocelot.json file, might it be something to do with the ocelot.json file when it is trying to redirect to AccountService?

    Thanks

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    It is using Helm charts for deployment. Maybe you missed https://github.com/abpframework/eShopOnAbp/blob/main/etc/k8s/eshoponabp/charts/gateway-web/templates/gateway-web-configmap.yaml

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09