Skip to content

Commit f170486

Browse files
CopilotLuizMacedo
andcommitted
Add validation scripts and deployment guide, update provider version
Co-authored-by: LuizMacedo <45747223+LuizMacedo@users.noreply.github.com>
1 parent 3c5a57c commit f170486

6 files changed

Lines changed: 461 additions & 3 deletions

File tree

deploy/DEPLOYMENT_GUIDE.md

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
# eShopOnWeb Deployment Guide
2+
3+
This guide provides an overview of the available deployment options for eShopOnWeb.
4+
5+
## Available Deployment Options
6+
7+
### 1. Kubernetes (Container Orchestration)
8+
- **Location**: `/deploy/k8s/`
9+
- **Use Case**: Production-grade container orchestration across multiple cloud providers
10+
- **Features**:
11+
- Multiple deployment manifests (Web, PublicAPI)
12+
- ConfigMaps and Secrets for configuration
13+
- Service definitions (LoadBalancer, ClusterIP)
14+
- Ingress configuration for external access
15+
- Kustomize support for environment-specific overrides
16+
- Support for AKS, EKS, GKE, and on-premises clusters
17+
18+
**Quick Start**:
19+
```bash
20+
cd deploy/k8s
21+
kubectl apply -k .
22+
```
23+
24+
📖 [Full Kubernetes Documentation](k8s/README.md)
25+
26+
---
27+
28+
### 2. Terraform (Infrastructure as Code)
29+
- **Location**: `/deploy/terraform/`
30+
- **Use Case**: Automated infrastructure provisioning on Azure
31+
- **Features**:
32+
- Azure Kubernetes Service (AKS) cluster provisioning
33+
- Azure Container Registry (ACR) setup
34+
- Virtual Network and networking components
35+
- Storage Account provisioning
36+
- Modular design (aks, networking, storage)
37+
- Environment-specific configurations (dev, staging, production)
38+
39+
**Quick Start**:
40+
```bash
41+
cd deploy/terraform
42+
terraform init
43+
terraform apply
44+
```
45+
46+
📖 [Full Terraform Documentation](terraform/README.md)
47+
48+
---
49+
50+
### 3. Azure Bicep (Azure-Specific IaC)
51+
- **Location**: `/infra/`
52+
- **Use Case**: Azure-specific infrastructure deployment
53+
- **Features**:
54+
- Azure App Service deployment
55+
- Azure Container Instances (ACI)
56+
- Azure SQL Database
57+
- Key Vault integration
58+
- Azure Developer CLI (azd) support
59+
60+
**Quick Start**:
61+
```bash
62+
azd init
63+
azd up
64+
```
65+
66+
📖 See main [README.md](../README.md) for Bicep/azd documentation
67+
68+
---
69+
70+
### 4. Docker Compose (Local Development)
71+
- **Location**: Repository root (`docker-compose.yml`)
72+
- **Use Case**: Local development and testing
73+
- **Features**:
74+
- Multi-container setup (Web, PublicAPI, SQL Server)
75+
- Quick local environment setup
76+
- Easy debugging
77+
78+
**Quick Start**:
79+
```bash
80+
docker-compose build
81+
docker-compose up
82+
```
83+
84+
📖 See main [README.md](../README.md) for Docker documentation
85+
86+
---
87+
88+
## Deployment Decision Matrix
89+
90+
| Criteria | Kubernetes | Terraform | Bicep/azd | Docker Compose |
91+
|----------|-----------|-----------|-----------|----------------|
92+
| **Complexity** | Medium-High | Medium | Low-Medium | Low |
93+
| **Cloud Agnostic** | ✅ Yes | ⚠️ Azure-focused | ❌ Azure only | ✅ Yes |
94+
| **Production Ready** | ✅ Yes | ✅ Yes | ✅ Yes | ❌ Dev only |
95+
| **Auto-scaling** | ✅ Built-in | ✅ Via AKS | ✅ Via App Service | ❌ No |
96+
| **Best For** | Multi-cloud, K8s expertise | Azure infra automation | Quick Azure deploy | Local dev/test |
97+
98+
---
99+
100+
## Recommended Deployment Paths
101+
102+
### Path 1: Quick Azure Deployment (Fastest)
103+
1. Use **azd** with Bicep templates
104+
2. Deploy to Azure App Service or ACI
105+
3. Best for: Demos, POCs, simple deployments
106+
107+
### Path 2: Production Kubernetes (Most Flexible)
108+
1. Use **Terraform** to provision AKS cluster and infrastructure
109+
2. Use **Kubernetes manifests** to deploy applications
110+
3. Best for: Production workloads, multi-cloud, scaling needs
111+
112+
### Path 3: Azure Kubernetes (Balanced)
113+
1. Use **Terraform** to provision complete Azure infrastructure
114+
2. Automatically connects AKS with ACR
115+
3. Deploy apps using **Kubernetes manifests**
116+
4. Best for: Azure-centric production deployments
117+
118+
### Path 4: Local Development (Simplest)
119+
1. Use **Docker Compose** for local environment
120+
2. Fast iteration and debugging
121+
3. Best for: Development and testing
122+
123+
---
124+
125+
## Prerequisites by Deployment Type
126+
127+
### Kubernetes Deployment
128+
- [ ] Kubernetes cluster (AKS, EKS, GKE, etc.)
129+
- [ ] `kubectl` CLI installed
130+
- [ ] Container registry access
131+
- [ ] Docker for building images
132+
133+
### Terraform Deployment
134+
- [ ] Azure subscription
135+
- [ ] Terraform CLI (>= 1.0)
136+
- [ ] Azure CLI
137+
- [ ] Appropriate Azure permissions
138+
139+
### Bicep/azd Deployment
140+
- [ ] Azure subscription
141+
- [ ] Azure Developer CLI (`azd`)
142+
- [ ] Azure CLI (optional)
143+
144+
### Docker Compose
145+
- [ ] Docker Engine
146+
- [ ] Docker Compose
147+
- [ ] Sufficient local resources
148+
149+
---
150+
151+
## Environment Configuration
152+
153+
### Development
154+
- Lower resource allocation
155+
- In-memory database option
156+
- Single replica deployments
157+
- Basic SKU services
158+
159+
### Staging
160+
- Production-like configuration
161+
- Persistent storage
162+
- Auto-scaling enabled
163+
- Standard SKU services
164+
165+
### Production
166+
- High availability setup
167+
- Multi-replica deployments
168+
- Auto-scaling configured
169+
- Premium SKU services
170+
- Monitoring and logging
171+
- Backup and disaster recovery
172+
173+
---
174+
175+
## Security Considerations
176+
177+
### All Deployments
178+
- ✅ Use secrets management (Key Vault, K8s Secrets)
179+
- ✅ Never commit credentials to source control
180+
- ✅ Use managed identities where possible
181+
- ✅ Enable HTTPS/TLS
182+
- ✅ Implement network policies
183+
- ✅ Regular security updates
184+
185+
### Kubernetes Specific
186+
- Use Network Policies
187+
- Implement Pod Security Standards
188+
- Use RBAC for access control
189+
- Scan container images
190+
- Use private container registries
191+
192+
### Terraform Specific
193+
- Use remote state with encryption
194+
- Implement state locking
195+
- Use workspaces for environments
196+
- Validate configurations before apply
197+
198+
---
199+
200+
## Monitoring and Observability
201+
202+
### Kubernetes
203+
- Prometheus + Grafana
204+
- Azure Monitor for AKS
205+
- Application Insights
206+
- Kubernetes Dashboard
207+
208+
### Azure (Bicep/Terraform)
209+
- Azure Monitor
210+
- Application Insights
211+
- Log Analytics
212+
- Azure Advisor
213+
214+
---
215+
216+
## Cost Optimization
217+
218+
### Development
219+
- Use smaller VM sizes (B-series)
220+
- Stop resources when not in use
221+
- Use Azure Dev/Test subscriptions
222+
- Disable auto-scaling
223+
224+
### Production
225+
- Right-size VMs based on load
226+
- Use reserved instances
227+
- Implement auto-scaling
228+
- Use Azure Cost Management
229+
- Set up budget alerts
230+
231+
---
232+
233+
## Troubleshooting
234+
235+
### Common Issues
236+
237+
1. **Container Image Pull Errors**
238+
- Verify registry credentials
239+
- Check image name and tag
240+
- Ensure network connectivity
241+
242+
2. **Database Connection Issues**
243+
- Verify connection strings
244+
- Check firewall rules
245+
- Validate credentials
246+
247+
3. **Terraform State Conflicts**
248+
- Use remote state with locking
249+
- Coordinate team deployments
250+
- Use workspaces
251+
252+
4. **Kubernetes Pod Crashes**
253+
- Check pod logs: `kubectl logs <pod-name>`
254+
- Verify resource limits
255+
- Check health probe configurations
256+
257+
---
258+
259+
## Next Steps
260+
261+
1. Choose your deployment path based on requirements
262+
2. Review the specific documentation for your chosen method
263+
3. Set up prerequisites
264+
4. Follow the deployment guide
265+
5. Configure monitoring and alerting
266+
6. Document your deployment specifics
267+
268+
---
269+
270+
## Support and Resources
271+
272+
- **Documentation**: See individual README files in each directory
273+
- **Issues**: [GitHub Issues](https://github.com/MicrosoftLearning/eShopOnWeb/issues)
274+
- **Kubernetes Docs**: https://kubernetes.io/docs/
275+
- **Terraform Docs**: https://www.terraform.io/docs
276+
- **Azure Docs**: https://docs.microsoft.com/azure/
277+
278+
---
279+
280+
## Contributing
281+
282+
To add new deployment options:
283+
1. Create a new directory under `/deploy/`
284+
2. Include comprehensive README.md
285+
3. Provide example configurations
286+
4. Update this guide
287+
5. Submit a pull request

deploy/k8s/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@ kubectl autoscale deployment eshop-web --cpu-percent=70 --min=2 --max=10 -n esho
175175
Validate manifests before applying:
176176

177177
```bash
178-
# Dry-run validation
178+
# Run the validation script (checks YAML syntax and kubectl dry-run if available)
179+
./validate.sh
180+
181+
# Or manually validate with kubectl
179182
kubectl apply -k . --dry-run=client
180183

181184
# Server-side dry-run

deploy/k8s/validate.sh

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/bin/bash
2+
# Kubernetes manifest validation script
3+
# This script validates YAML syntax for all Kubernetes manifests
4+
5+
set -e
6+
7+
echo "🔍 Validating Kubernetes manifests..."
8+
echo ""
9+
10+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
11+
cd "$SCRIPT_DIR"
12+
13+
# Colors for output
14+
GREEN='\033[0;32m'
15+
RED='\033[0;31m'
16+
NC='\033[0m' # No Color
17+
18+
ALL_VALID=true
19+
20+
# List of files to validate
21+
FILES=(
22+
"namespace.yaml"
23+
"configmap.yaml"
24+
"secret.yaml"
25+
"web-deployment.yaml"
26+
"web-service.yaml"
27+
"publicapi-deployment.yaml"
28+
"publicapi-service.yaml"
29+
"ingress.yaml"
30+
"kustomization.yaml"
31+
"overlays/dev/kustomization.yaml"
32+
"overlays/staging/kustomization.yaml"
33+
"overlays/production/kustomization.yaml"
34+
)
35+
36+
# Validate YAML syntax
37+
for file in "${FILES[@]}"; do
38+
if [ -f "$file" ]; then
39+
if python3 -c "import yaml; yaml.safe_load(open('$file'))" 2>/dev/null; then
40+
echo -e "${GREEN}${NC} $file - Valid YAML syntax"
41+
else
42+
echo -e "${RED}${NC} $file - Invalid YAML syntax"
43+
ALL_VALID=false
44+
fi
45+
else
46+
echo -e "${RED}${NC} $file - File not found"
47+
ALL_VALID=false
48+
fi
49+
done
50+
51+
echo ""
52+
53+
# Try kubectl validation if available and cluster is accessible
54+
if command -v kubectl &> /dev/null; then
55+
echo "📋 kubectl is available, attempting dry-run validation..."
56+
if kubectl cluster-info &> /dev/null; then
57+
echo "✓ Connected to Kubernetes cluster"
58+
echo ""
59+
echo "Running kubectl dry-run validation..."
60+
61+
# Validate with kubectl
62+
if kubectl apply --dry-run=client -f namespace.yaml &> /dev/null; then
63+
echo -e "${GREEN}${NC} kubectl validation passed"
64+
else
65+
echo -e "${RED}${NC} kubectl validation failed"
66+
ALL_VALID=false
67+
fi
68+
else
69+
echo "ℹ️ No Kubernetes cluster available for kubectl validation"
70+
echo " YAML syntax validation completed successfully"
71+
fi
72+
else
73+
echo "ℹ️ kubectl not found, skipping cluster validation"
74+
echo " YAML syntax validation completed successfully"
75+
fi
76+
77+
echo ""
78+
79+
if [ "$ALL_VALID" = true ]; then
80+
echo -e "${GREEN}✅ All validations passed!${NC}"
81+
exit 0
82+
else
83+
echo -e "${RED}❌ Some validations failed!${NC}"
84+
exit 1
85+
fi

deploy/terraform/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,10 @@ terraform init -upgrade
457457
Validate configuration before applying:
458458
459459
```bash
460-
# Validate syntax
460+
# Run the validation script (comprehensive check)
461+
./validate.sh
462+
463+
# Or manually validate
461464
terraform validate
462465

463466
# Format code

0 commit comments

Comments
 (0)