-
Notifications
You must be signed in to change notification settings - Fork 3k
Add Kubernetes and Terraform deployment support for eShopOnWeb #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: LuizMacedo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds comprehensive Kubernetes and Terraform deployment options to the eShopOnWeb reference application, expanding beyond the existing Azure-focused deployment methods. The changes introduce infrastructure-as-code approaches for deploying to Kubernetes clusters and Azure infrastructure using Terraform.
Key changes include:
- Complete Kubernetes deployment manifests with YAML files for namespace, configurations, secrets, deployments, services, and ingress
- Full Terraform configuration for Azure infrastructure including App Services, SQL databases, and Key Vault with security best practices
- Automated deployment scripts for both platforms with error handling and validation
Reviewed Changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| terraform/variables.tf | Defines Terraform variables for Azure resource configuration |
| terraform/terraform.tfvars.example | Example configuration file for Terraform variables |
| terraform/providers.tf | Terraform provider configuration for Azure and random resources |
| terraform/outputs.tf | Output definitions for deployed Azure resources |
| terraform/main.tf | Main Terraform configuration defining Azure infrastructure |
| terraform/locals.tf | Local values and resource naming logic |
| terraform/deploy.sh | Deployment script for Terraform infrastructure management |
| terraform/README.md | Comprehensive documentation for Terraform deployment |
| terraform/.gitignore | Git ignore file for Terraform-specific files |
| k8s/web-deployment.yaml | Kubernetes deployment and service for web application |
| k8s/sqlserver.yaml | SQL Server deployment and service for Kubernetes |
| k8s/secrets.yaml | Kubernetes secrets for database credentials |
| k8s/publicapi-deployment.yaml | Kubernetes deployment and service for public API |
| k8s/namespace.yaml | Kubernetes namespace definition |
| k8s/ingress.yaml | Ingress configuration for external access |
| k8s/deploy.sh | Deployment script for Kubernetes with Docker image management |
| k8s/configmap.yaml | Kubernetes configuration map for application settings |
| k8s/README.md | Documentation for Kubernetes deployment |
| README.md | Updated main documentation to include new deployment options |
Files not reviewed (1)
- terraform/.terraform.lock.hcl: Language not supported
| @@ -0,0 +1,14 @@ | |||
| locals { | |||
| resource_token = lower(substr(replace(uuid(), "-", ""), 0, 13)) | |||
Copilot
AI
Aug 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using uuid() to generate resource tokens can cause state drift issues. The uuid() function generates a new value on each Terraform run, which could lead to resources being recreated unnecessarily. Consider using a deterministic approach like hashing environment variables or using random_id resource instead.
| resource_token = lower(substr(replace(uuid(), "-", ""), 0, 13)) | |
| resource_token = lower(substr(random_id.resource_token.hex, 0, 13)) |
terraform/main.tf
Outdated
| name = "Azure Services" | ||
| server_id = azurerm_mssql_server.identity.id | ||
| start_ip_address = "0.0.0.1" | ||
| end_ip_address = "255.255.255.254" |
Copilot
AI
Aug 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The firewall rule allows access from all Azure services (0.0.0.1 to 255.255.255.254), which is overly permissive. Consider restricting access to specific IP ranges or services that actually need database access.
| end_ip_address = "255.255.255.254" | |
| # SQL Server Firewall Rules - Allow App Service Only | |
| resource "azurerm_mssql_firewall_rule" "catalog_app_service" { | |
| name = "App Service Access" | |
| server_id = azurerm_mssql_server.catalog.id | |
| start_ip_address = var.app_service_ip | |
| end_ip_address = var.app_service_ip | |
| } | |
| resource "azurerm_mssql_firewall_rule" "identity_app_service" { | |
| name = "App Service Access" | |
| server_id = azurerm_mssql_server.identity.id | |
| start_ip_address = var.app_service_ip | |
| end_ip_address = var.app_service_ip |
k8s/secrets.yaml
Outdated
| stringData: | ||
| SA_PASSWORD: "@someThingComplicated1234" | ||
| CatalogConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" | ||
| IdentityConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" No newline at end of file |
Copilot
AI
Aug 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection strings with hardcoded passwords should not be stored in plain text in manifests. Consider using external secret management or at minimum base64 encoding in the data field instead of stringData.
| IdentityConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" | |
| data: | |
| SA_PASSWORD: QHNvbWVUaGluZ0NvbXBsaWNhdGVkMTIzNA== | |
| CatalogConnection: U2VydmVyPXNxbHNlcnZlci1zZXJ2aWNlO0RhdGFiYXNlPU1pY3Jvc29mdC5lU2hvcE9uV2ViLkNhdGFsb2dEYjtVc2VyIElkPXNhO1Bhc3N3b3JkPUBzb21lVGhpbmdDb21wbGljYXRlZDEyMzQ7VHJ1c3RTZXJ2ZXJDZXJ0aWZpY2F0ZT10cnVl | |
| IdentityConnection: U2VydmVyPXNxbHNlcnZlci1zZXJ2aWNlO0RhdGFiYXNlPU1pY3Jvc29mdC5lU2hvcE9uV2ViLklkZW50aXR5O1VzZXIgSWQ9c2E7UGFzc3dvcmQ9QHNvbWVUaGluZ0NvbXBsaWNhdGVkMTIzNDtUcnVzdFNlcnZlckNlcnRpZmljYXRlPXRydWU= |
k8s/secrets.yaml
Outdated
| stringData: | ||
| SA_PASSWORD: "@someThingComplicated1234" | ||
| CatalogConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" | ||
| IdentityConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" No newline at end of file |
Copilot
AI
Aug 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Connection strings with hardcoded passwords should not be stored in plain text in manifests. Consider using external secret management or at minimum base64 encoding in the data field instead of stringData.
| IdentityConnection: "Server=sqlserver-service;Database=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;TrustServerCertificate=true" | |
| data: | |
| SA_PASSWORD: QHNvbWVUaGluZ0NvbXBsaWNhdGVkMTIzNA== | |
| CatalogConnection: U2VydmVyPXNxbHNlcnZlci1zZXJ2aWNlO0RhdGFiYXNlPU1pY3Jvc29mdC5lU2hvcE9uV2ViLkNhdGFsb2dEYjtVc2VyIElkPXNhO1Bhc3N3b3JkPUBzb21lVGhpbmdDb21wbGljYXRlZDEyMzQ7VHJ1c3RTZXJ2ZXJDZXJ0aWZpY2F0ZT10cnVl | |
| IdentityConnection: U2VydmVyPXNxbHNlcnZlci1zZXJ2aWNlO0RhdGFiYXNlPU1pY3Jvc29mdC5lU2hvcE9uV2ViLklkZW50aXR5O1VzZXIgSWQ9c2E7UGFzc3dvcmQ9QHNvbWVUaGluZ0NvbXBsaWNhdGVkMTIzNDtUcnVzdFNlcnZlckNlcnRpZmljYXRlPXRydWU= |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
This PR adds comprehensive Kubernetes and Terraform deployment options to the eShopOnWeb reference application, expanding beyond the existing Azure-focused deployment methods.
What's Added
Kubernetes Support (
k8s/directory)deploy.sh) with error handling and deployment managementTerraform Support (
terraform/directory)deploy.sh) with validation and safety checksKey Features
Kubernetes Deployment
Terraform Deployment
Deployment Options Now Available
Architecture Consistency
Both new deployment options maintain compatibility with the existing application architecture:
Production Considerations
Documentation
Updated main README.md to include the new deployment options and added comprehensive documentation in both
k8s/README.mdandterraform/README.mdwith:Fixes #331.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
api.cdnjs.comdotnet build eShopOnWeb.sln(dns block)checkpoint-api.hashicorp.comterraform fmt -check(dns block)terraform fmt(dns block)terraform init(dns block)esm.ubuntu.com/usr/lib/apt/methods/https(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.