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 12 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
49 changes: 32 additions & 17 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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 @@ -45,33 +46,37 @@ 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: containers-eshop
path: ./samples/eshop/eshop.bicep
args: -p adminLogin=sa
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-eshop
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 }}
app: eshop
env: aws-eshop
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
uiTestFile: tests/eshop/eshop.app.spec.ts
credential: aws
enableDapr: false
env:
Expand Down Expand Up @@ -162,12 +167,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 Down Expand Up @@ -230,13 +232,26 @@ jobs:
rad credential register aws --access-key-id ${{ secrets.AWS_ACCESS_KEY_ID }} --secret-access-key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
fi
# Deploy application and run tests
- name: Create and use eShop environment
if: steps.gen-id.outputs.RUN_TEST == 'true' && matrix.app == 'eshop'
run: |
if [[ "${{ matrix.credential }}" == "azure" ]]; then
rad deploy ./samples/eshop/environments/azure.bicep
rad env update ${{ matrix.env }} --azure-subscription-id ${{ secrets.AZURE_SUBSCRIPTIONID_TESTS }} --azure-resource-group ${{ steps.gen-id.outputs.TEST_AZURE_RESOURCE_GROUP }}
elif [[ "${{ matrix.credential }}" == "aws" ]]; then
rad deploy ./samples/eshop/environments/aws.bicep
rad env update ${{ matrix.env }} --aws-region ${{ env.AWS_REGION }} --aws-account-id ${{ secrets.AWS_ACCOUNT_ID }}
else
rad deploy ./samples/eshop/environments/containers.bicep
fi
rad env switch ${{ matrix.env }}
- name: Deploy app
if: steps.gen-id.outputs.RUN_TEST == 'true'
run: rad deploy ${{ matrix.path }} ${{ matrix.args }}
- name: Wait for all pods to be ready
if: steps.gen-id.outputs.RUN_TEST == 'true'
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 @@ -270,7 +285,7 @@ jobs:
# Create pod-logs directory
mkdir -p playwright/pod-logs/${{ matrix.name }}
# Get pod logs and save to file
namespace="default-${{ matrix.app }}"
namespace="${{ matrix.env }}-${{ matrix.app }}"
label="radius.dev/application=${{ matrix.app }}"
pod_names=($(kubectl get pods -l $label -n $namespace -o jsonpath='{.items[*].metadata.name}'))
for pod_name in "${pod_names[@]}"; do
Expand All @@ -294,7 +309,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
51 changes: 33 additions & 18 deletions samples/eshop/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# eShop on Radius reference application

Visit the [Project Radius docs](https://radapp.dev/getting-started/reference-apps/eshop/) to learn more and try it out.
# eShop on Recipes reference application

## Source

Expand All @@ -17,23 +15,40 @@ This reference app is a "radified" version of the [eShop on containers](https://
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):
1. Deploy the environment (choose which type of hosting infrastructure you wish to use):
```bash
# Containers
rad deploy environments/containers.bicep

### Containerized infrastructure

```bash
rad deploy iac/eshop.bicep
```
# Azure
rad deploy environments/azure.bicep

### Azure infrastructure

```bash
rad deploy iac/eshop.bicep -p platform=azure
```
# 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 containers-eshop-env

# Azure
rad env switch azure-eshop-env

### AWS infrastructure

# AWS
rad env switch aws-eshop-env
```
1. Set credentials:
```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. Deploy the application:
```bash
rad deploy iac/eshop.bicep -p platform=aws -p eksClusterName=<YOUR_EKS_CLUSTER_NAME>
rad deploy eshop.bicep

# Containers (requires SQL admin username to be "SA"
rad deploy eshop.bicep -p adminLogin=sa
```

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 awsEshopEnv 'Applications.Core/environments@2023-10-01-preview' = {
name: 'aws-eshop'
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: 'radius.azurecr.io/recipes/aws/sqldatabases:edge'
parameters: {
eksClusterName: eksClusterName
}
}
}
'Applications.Datastores/redisCaches': {
rediscache: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/aws/rediscaches:edge'
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': {
rabbitmqmessagequeue: {
templateKind: 'bicep'
templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge'
}
}
}
}
}
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('Azure ResourceGroup name')
param azureResourceGroup string = resourceGroup().name

@description('Azure SubscriptionId')
param azureSubscription string = subscription().subscriptionId
AaronCrawfis marked this conversation as resolved.
Show resolved Hide resolved

resource azureEShopEnv 'Applications.Core/environments@2023-10-01-preview' = {
name: 'azure-eshop'
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 samples/eshop/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@2023-10-01-preview' = {
name: 'containers-eshop'
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'containers-eshop'
}
recipes: {
'Applications.Datastores/sqlDatabases': {
sqldatabase: {
AaronCrawfis marked this conversation as resolved.
Show resolved Hide resolved
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
Loading