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

Update eShop to use Recipes #590

Merged
merged 31 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
694afa1
Replace eShop with eShop on recipes
willdavsmith Oct 11, 2023
ce9af56
PR
willdavsmith Oct 11, 2023
cb8f912
Fix
willdavsmith Oct 11, 2023
a46c7a1
Test
willdavsmith Oct 11, 2023
9d3ddf8
PR
willdavsmith Oct 11, 2023
685ba81
Merge branch 'edge' into willdavsmith/3-eshop-recipes
willdavsmith Oct 11, 2023
2627f2b
oops
willdavsmith Oct 11, 2023
595d512
Merge remote-tracking branch 'origin/willdavsmith/3-eshop-recipes' in…
willdavsmith Oct 11, 2023
e3905b5
Updates
willdavsmith Oct 11, 2023
2abeac2
PR
willdavsmith Oct 12, 2023
127c20d
PR
willdavsmith Oct 12, 2023
8707935
PR
willdavsmith Oct 12, 2023
e39b8d6
PR comments
willdavsmith Oct 12, 2023
6443a8d
PR comments
willdavsmith Oct 12, 2023
a97dc9a
fixing
willdavsmith Oct 12, 2023
dedd399
again
willdavsmith Oct 12, 2023
aff0800
fix
willdavsmith Oct 13, 2023
e5ec418
rewind
willdavsmith Oct 13, 2023
b07866c
PR
willdavsmith Oct 13, 2023
8b00637
PR
willdavsmith Oct 13, 2023
f48a0ad
Merge branch 'edge' into willdavsmith/3-eshop-recipes
AaronCrawfis Nov 8, 2023
69dfcc1
Simplify env registration
AaronCrawfis Nov 8, 2023
dba4ebb
Make registry a parameter
AaronCrawfis Nov 8, 2023
8f7d4a0
Update test
AaronCrawfis Nov 8, 2023
08e1ce1
Update namespaces
AaronCrawfis Nov 8, 2023
67121b8
Merge branch 'edge' into willdavsmith/3-eshop-recipes
AaronCrawfis Nov 8, 2023
05b3e11
Merge branch 'edge' into willdavsmith/3-eshop-recipes
AaronCrawfis Nov 8, 2023
c8480ae
Fix tag
AaronCrawfis Nov 9, 2023
10dccb6
Update env names
AaronCrawfis Nov 9, 2023
dbdadf5
Fix namespaces
AaronCrawfis Nov 9, 2023
e1af6b2
Fix recipe
AaronCrawfis Nov 9, 2023
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
52 changes: 34 additions & 18 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
- name: demo
runOnPullRequest: true
app: demo
env: default
path: ./samples/demo/app.bicep
args: --application demo
uiTestFile: tests/demo/demo.app.spec.ts
Expand All @@ -44,33 +45,36 @@ jobs:
- name: dapr
runOnPullRequest: true
app: dapr
env: default
path: ./samples/dapr/dapr.bicep
enableDapr: true
- name: volumes
runOnPullRequest: true
app: myapp
env: default
path: ./samples/volumes/app.bicep
enableDapr: false
- name: eshop
- name: eshop-containers
runOnPullRequest: true
app: eshop
path: ./samples/eshop/iac/eshop.bicep
uiTestFile: tests/eshop/container.app.spec.ts
env: default
path: ./samples/eshop/eshop.bicep
uiTestFile: tests/eshop/eshop.app.spec.ts
enableDapr: false
- name: eshop-azure
runOnPullRequest: false
app: eshop-azure
path: ./samples/eshop/iac/eshop.bicep
args: -p platform=azure -p appName=eshop-azure
uiTestFile: tests/eshop/container.app.spec.ts
app: eshop
env: azure
path: ./samples/eshop/eshop.bicep
uiTestFile: tests/eshop/eshop.app.spec.ts
credential: azure
enableDapr: false
- name: eshop-aws
runOnPullRequest: false
app: eshop-aws-${{ github.run_id }}-${{ github.run_attempt }}
path: ./samples/eshop/iac/eshop.bicep
args: -p platform=aws -p eksClusterName=eks-samplestest-${{ github.run_id }}-${{ github.run_attempt }}-eshop-aws -p appName=eshop-aws-${{ github.run_id }}-${{ github.run_attempt }}
uiTestFile: tests/eshop/container.app.spec.ts
app: eshop
env: aws
path: ./samples/eshop/eshop.bicep
uiTestFile: tests/eshop/eshop.app.spec.ts
credential: aws
enableDapr: false
env:
Expand Down Expand Up @@ -161,12 +165,9 @@ jobs:
echo "Waiting for EKS cluster to be created..."
sleep 60
done
aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}
timeout-minutes: 60
continue-on-error: false
- name: Install k3d
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential == 'aws'
run: |
aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name ${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}
- name: Download k3d
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.credential != 'aws'
run: wget -q -O - https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash
Expand All @@ -186,7 +187,7 @@ jobs:
RADIUS_VERSION=edge
fi
./.github/scripts/install-radius.sh $RADIUS_VERSION
- name: Initialize local environment
- name: Initialize default environment
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
if [[ "${{ matrix.credential }}" == "aws" ]]; then
Expand All @@ -201,6 +202,11 @@ jobs:
rad env switch default
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rediscaches:latest --resource-type Applications.Datastores/redisCaches
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/mongodatabases:latest --resource-type Applications.Datastores/mongoDatabases
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/sqldatabases:latest --resource-type Applications.Datastores/sqlDatabases
rad recipe register default -e default -w default --template-kind bicep --template-path ghcr.io/radius-project/recipes/local-dev/rabbitmqqueues:latest --resource-type Applications.Messaging/rabbitMQQueues
- name: Configure cloud credentials
if: steps.gen-id.outputs.RUN_TEST == 'true' && ( matrix.credential == 'azure' || matrix.credential == 'aws')
run: |
if [[ "${{ matrix.credential }}" == "azure" ]]; then
rad env update default --azure-subscription-id ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} --azure-resource-group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }}
rad credential register azure --client-id ${{ secrets.AZURE_SP_TESTS_APPID }} --client-secret ${{ secrets.AZURE_SP_TESTS_PASSWORD }} --tenant-id ${{ secrets.AZURE_SP_TESTS_TENANTID }}
Expand All @@ -209,6 +215,16 @@ jobs:
rad env update default --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.AWS_ACCOUNT_ID }}
rad credential register aws --access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
fi
## This step is temporary until we have Recipe Packs for Azure & AWS and update the eShop sample
- name: Initialize eShop environments
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.app == 'eshop'
run: |
if [[ "${{ matrix.credential }}" == "azure" ]]; then
rad deploy ./samples/eshop/environments/azure.bicep -p azureResourceGroup=${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }} -p azureSubscriptionId=${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }}
elif [[ "${{ matrix.credential }}" == "aws" ]]; then
rad deploy ./samples/eshop/environments/aws.bicep -p awsAccountId=${{ secrets.AWS_ACCOUNT_ID }} -p awsRegion=${{ env.AWS_REGION }} -p eksClusterName=${{ steps.gen-id.outputs.TEST_EKS_CLUSTER_NAME }}
fi
rad env switch ${{ matrix.env }}
# Deploy application and run tests
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
Expand All @@ -217,7 +233,7 @@ jobs:
if: steps.gen-id.outputs.RUN_TEST == 'true'
id: wait-for-pods
run: |
namespace="default-${{ matrix.app }}"
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radapp.io/application=${{ matrix.app }}"
kubectl wait --for=condition=Ready pod -l $label -n $namespace --timeout=5m
- name: Run Playwright Test
Expand Down Expand Up @@ -275,7 +291,7 @@ jobs:
- name: Delete app
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: |
rad app delete ${{ matrix.app }} -y
rad app delete ${{ matrix.app }} -y
- name: Delete Azure resource group
if: always() && steps.gen-id.outputs.RUN_TEST == 'true' && steps.create-azure-resource-group.outcome == 'success'
run: |
Expand Down
61 changes: 38 additions & 23 deletions samples/eshop/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# eShop on Radius reference application

Visit the [Project Radius docs](https://docs.radapp.io/tutorials/eshop/) to learn more and try it out.

## Source

This reference app is a "radified" version of the [eShop on containers](https://github.com/dotnet-architecture/eShopOnContainers) .NET reference application.
Expand All @@ -11,29 +9,46 @@ This reference app is a "radified" version of the [eShop on containers](https://
1. Have a kubernetes cluster handy from the [supported clusters](https://docs.radapp.io/guides/operations/kubernetes/overview/#supported-kubernetes-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://docs.radapp.io/getting-started/)
1. [Initialize a new Radius environment](https://docs.radapp.io/getting-started/)
1. Install Radius:
```bash
rad install kubernetes
```
1. Set provider credentials to authenticate to your cloud provider (choose which type of hosting infrastructure you wish to use):
```bash
# AWS
rad credential register aws --aws-access-key-id <your-aws-access-key-id> --aws-secret-access-key <your-aws-secret-access-key>

# Azure
rad credential register azure --client-id <your-azure-service-principal-client-id> --client-secret <your-azure-service-principal-client-secret> --tenant-id <your-azure-service-principal-tenant-id>
```
1. Clone the repository and switch to the app directory:
```bash
git clone https://github.com/radius-project/samples.git
cd samples/reference-apps/eshop
```
1. Deploy the app (choose which type of hosting infrastructure you wish to use):

### Containerized infrastructure

```bash
rad deploy iac/eshop.bicep
```

### Azure infrastructure

```bash
rad deploy iac/eshop.bicep -p platform=azure
```

### AWS infrastructure

```bash
rad deploy iac/eshop.bicep -p platform=aws -p eksClusterName=<YOUR_EKS_CLUSTER_NAME>
```

1. Deploy an environment with the proper Recipes (choose which type of hosting infrastructure you wish to use):
```bash
# Containers - simply initialize a new local-dev environment
rad init

# Azure
rad deploy environments/azure.bicep -p azureSubscriptionId=<your-sub-id> -p azureResourceGroup=<your-resource-group-name>

# AWS
rad deploy environments/aws.bicep -p awsAccountId=<your-aws-account-id> -p awsRegion=<your-aws-region> -p eksClusterName=<your-eks-cluster-name>
```
1. Switch to your new environment (choose which type of hosting infrastructure you wish to use):
```bash
# Containers
rad env switch default

# Azure
rad env switch azure

# AWS
rad env switch aws
```
1. Deploy the application:
```bash
rad deploy eshop.bicep
```
54 changes: 54 additions & 0 deletions samples/eshop/environments/aws.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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 environment 'Applications.Core/environments@2023-10-01-preview' = {
name: 'aws'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'default'
}
providers: {
aws: {
scope: '/planes/aws/aws/accounts/${awsAccountId}/regions/${awsRegion}'
}
}
recipes: {
'Applications.Datastores/sqlDatabases': {
default: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/aws/sqldatabases:latest'
parameters: {
eksClusterName: eksClusterName
}
}
}
'Applications.Datastores/redisCaches': {
default: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/aws/rediscaches:latest'
parameters: {
eksClusterName: eksClusterName
}
}
}
// Use containerized RabbitMQ instead of Amazon SQS
// https://github.com/radius-project/bicep-types-aws/blob/main/docs/reference/limitations.md
Comment on lines +44 to +45
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a TODO?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly. This is more of a comment of why we're using the local-dev Recipe instead of the Azure service, which is non-idempotent and not supported by Radius. Once we add non-idempotent service support we could come back and update this later.

'Applications.Messaging/rabbitMQQueues': {
default: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/local-dev/rabbitmqmessagequeues:latest'
}
}
}
}
}
43 changes: 43 additions & 0 deletions samples/eshop/environments/azure.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import radius as rad

@description('The name of the Azure resource group where Azure resources will be deployed.')
param azureResourceGroup string

@description('The Azure subscription ID where Azure resources will be deployed.')
param azureSubscriptionId string

resource environment 'Applications.Core/environments@2023-10-01-preview' = {
name: 'azure'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'default'
}
providers: {
azure: {
scope: '/subscriptions/${azureSubscriptionId}/resourceGroups/${azureResourceGroup}'
}
}
recipes: {
'Applications.Datastores/sqlDatabases': {
default: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/azure/sqldatabases:latest'
}
}
'Applications.Datastores/redisCaches': {
default: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/azure/rediscaches:latest'
}
}
'Applications.Core/extenders': {
servicebus: {
templateKind: 'bicep'
templatePath: 'ghcr.io/radius-project/recipes/azure/extender-servicebus:latest'
}
}
}
}
}
Loading
Loading