Skip to content
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

Add eshop on recipes reference application #553

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions reference-apps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ Reference apps are templates that show a complete app. You are able to clone and
| Reference app | Description |
|---------------|-------------|
| [eShop](./eshop) | A full retail microservices application. |
| [eShop on Recipes](./eshop-recipes) | A full retail microservices application leveraging Radius recipes for infrastructure deployment and management |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making this a separate app let's just go ahead and have one version of eshop that's Recipes. No need to retain the old one.

| [eShop on Dapr](./eshop-dapr) | A full retail microservices application leveraging Dapr for full code + infrastructure portability |
| [Container App Store](./container-app-store) | A microservices application that uses Dapr. |
32 changes: 32 additions & 0 deletions reference-apps/eshop-recipes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# eShop on Recipes reference application

## Source

This reference app is a "radified" version of the [eShop on containers](https://github.com/dotnet-architecture/eShopOnContainers) .NET reference application.

## Deploy

1. Have a kubernetes cluster handy from the [supported clusters](https://docs.radapp.dev/operations/platforms/kubernetes/supported-clusters/).
- (AWS only) Make sure that each of the Subnets in your EKS cluster Subnet Group are within the list of [supported MemoryDB availability zones](https://docs.aws.amazon.com/memorydb/latest/devguide/subnetgroups.html)
1. [Install the rad CLI](https://radapp.dev/getting-started/)
1. [Initialize a new Radius environment](https://radapp.dev/getting-started/)
1. Clone the repository and switch to the app directory:
```bash
git clone https://github.com/project-radius/samples.git
cd samples/reference-apps/eshop
```
1. Deploy the environment (choose which type of hosting infrastructure you wish to use):
```bash
# AWS
rad deploy iac/environments/aws.bicep

# Azure
rad deploy iac/environments/azure.bicep

# Containers
rad deploy iac/environments/containers.bicep
```
1. Deploy the application:
```bash
rad deploy iac/eshop.bicep
```
3 changes: 3 additions & 0 deletions reference-apps/eshop-recipes/envoy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM envoyproxy/envoy:v1.11.1
COPY envoy.yaml /etc/envoy/envoy.yaml
CMD ["/usr/local/bin/envoy", "-c", "/etc/envoy/envoy.yaml"]
14 changes: 14 additions & 0 deletions reference-apps/eshop-recipes/envoy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Envoy for eshop

Eshop uses an internal gateway to route requests between different services. Today in Radius, we don't support private/internal gateways (see https://github.com/project-radius/radius/issues/4789), so we created a custom image of envoy with the routing rules necessary to make eshop work.

What this means is that if we need to update the names of routes in eshop, *we likely need to update the envoy image*.

The routing configuration is in [envoy.yaml](envoy.yaml). See the `route_config` section specifically.

To build the docker image, run `docker build . -t radius.azurecr.io/eshop-envoy:0.1.<NUMBER>`.

Where NUMBER is one greater than the latest version made. To view versions, see https://ms.portal.azure.com/#view/Microsoft_Azure_ContainerRegistries/RepositoryBlade/id/%2Fsubscriptions%2F66d1209e-1382-45d3-99bb-650e6bf63fc0%2FresourceGroups%2Fassets%2Fproviders%2FMicrosoft.ContainerRegistry%2Fregistries%2Fradius/repository/eshop-envoy.

To push the image, run `az acr login -n radius` and then `docker push radius.azurecr.io/eshop-envoy:0.1.<NUMBER>`.

143 changes: 143 additions & 0 deletions reference-apps/eshop-recipes/envoy/envoy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
admin:
access_log_path: "/dev/stdout"
address:
socket_address:
address: 0.0.0.0
port_value: 8001
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: eshop_backend_route
virtual_hosts:
- name: eshop_backend
domains:
- "*"
routes:
- name: "c-short"
match:
prefix: "/webshoppingapigw/c/"
route:
auto_host_rewrite: true
prefix_rewrite: "/catalog-api/"
cluster: catalog
- name: "c-long"
match:
prefix: "/webshoppingapigw/catalog-api/"
route:
auto_host_rewrite: true
cluster: catalog
- name: "o-short"
match:
prefix: "/webshoppingapigw/o/"
route:
auto_host_rewrite: true
prefix_rewrite: "/ordering-api/"
cluster: ordering
- name: "o-long"
match:
prefix: "/webshoppingapigw/ordering-api/"
route:
auto_host_rewrite: true
cluster: ordering
- name: "h-long"
match:
prefix: "/webshoppingapigw/hub/notificationhub"
route:
auto_host_rewrite: true
cluster: signalr-hub
timeout: 300s
upgrade_configs:
upgrade_type: "websocket"
enabled: true
- name: "b-short"
match:
prefix: "/webshoppingapigw/b/"
route:
auto_host_rewrite: true
prefix_rewrite: "/basket-api/"
cluster: basket
- name: "b-long"
match:
prefix: "/webshoppingapigw/basket-api/"
route:
auto_host_rewrite: true
cluster: basket
- name: "agg"
match:
prefix: "/webshoppingapigw/"
route:
auto_host_rewrite: true
prefix_rewrite: "/"
cluster: shoppingagg
http_filters:
- name: envoy.router
access_log:
- name: envoy.file_access_log
filter:
not_health_check_filter: {}
config:
json_format:
time: "%START_TIME%"
protocol: "%PROTOCOL%"
duration: "%DURATION%"
request_method: "%REQ(:METHOD)%"
request_host: "%REQ(HOST)%"
path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
response_flags: "%RESPONSE_FLAGS%"
route_name: "%ROUTE_NAME%"
upstream_host: "%UPSTREAM_HOST%"
upstream_cluster: "%UPSTREAM_CLUSTER%"
upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
path: "/tmp/access.log"
clusters:
- name: shoppingagg
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: webshoppingagg-http
port_value: 5121
- name: catalog
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: catalog-http
port_value: 5101
- name: basket
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: basket-http
port_value: 5103
- name: ordering
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: ordering-http
port_value: 5102
- name: signalr-hub
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
hosts:
- socket_address:
address: orderingsignalrhub-http
port_value: 5112

53 changes: 53 additions & 0 deletions reference-apps/eshop-recipes/iac/environments/aws.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import radius as rad

@description('Account ID of the AWS account resources should be deployed in')
param awsAccountId string

@description('AWS region that resources should be deployed in')
param awsRegion string

@description('Name of your EKS cluster')
param eksClusterName string

resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = {
name: 'aws-eshop-env'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'aws-eshop'
}
providers: {
aws: {
scope: '/planes/aws/aws/accounts/${awsAccountId}/regions/${awsRegion}'
}
}
recipes: {
'Applications.Datastores/sqlDatabases': {
sqldatabase: {
templateKind: 'bicep'
templatePath: 'radiusdev.azurecr.io/recipes/aws/sqldatabases:pr-29'
parameters: {
eksClusterName: eksClusterName
}
}
}
'Applications.Datastores/redisCaches': {
rediscache: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/aws/rediscaches:edge'
parameters: {
eksClusterName: eksClusterName
}
}
}
// Temporarily using containerized rabbitmq until we can use SQS or AmazonMQ
'Applications.Messaging/rabbitMQQueues': {
rabbitmqmessagequeue: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge'
}
}
}
}
}
43 changes: 43 additions & 0 deletions reference-apps/eshop-recipes/iac/environments/azure.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import radius as rad

@description('Azure ResourceGroup name')
param azureResourceGroup string = resourceGroup().name

@description('Azure SubscriptionId')
param azureSubscription string = subscription().subscriptionId

resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = {
name: 'azure-eshop-env'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'azure-eshop'
}
providers: {
azure: {
scope: '/subscriptions/${azureSubscription}/resourceGroups/${azureResourceGroup}'
}
}
recipes: {
'Applications.Datastores/sqlDatabases': {
sqldatabase: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/azure/sqldatabases:latest'
}
}
'Applications.Datastores/redisCaches': {
rediscache: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/azure/rediscaches:latest'
}
}
'Applications.Core/extenders': {
servicebus: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/azure/extender-servicebus:latest'
}
}
}
}
}
32 changes: 32 additions & 0 deletions reference-apps/eshop-recipes/iac/environments/containers.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import radius as rad

resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = {
name: 'containers-eshop-env'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'containers-eshop'
}
recipes: {
'Applications.Datastores/sqlDatabases': {
sqldatabase: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/local-dev/sqldatabases:edge'
}
}
'Applications.Datastores/redisCaches': {
rediscache: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/local-dev/rediscaches:edge'
}
}
'Applications.Messaging/rabbitMQQueues': {
rabbitmqmessagequeue: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge'
}
}
}
}
}
Loading