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

Store optimizations #96

Merged
merged 9 commits into from
Feb 1, 2024
Merged
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ __pycache__/
.vscode
**/.vscode
.azure
.terraform
41 changes: 29 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ git clone https://github.com/Azure-Samples/aks-store-demo.git
cd aks-store-demo
```

Configure your Azure OpenAI or OpenAI API keys in [`docker-compose.yml`](./docker-compose.yml) using the environment variables in the `aiservice` section:
Configure your Azure OpenAI or OpenAI API keys in [`docker-compose.yml`](./docker-compose.yml) using the environment variables in the `ai-service` section:

```yaml
aiservice:
ai-service:
build: src/ai-service
container_name: 'aiservice'
container_name: 'ai-service'
...
environment:
- USE_AZURE_OPENAI=True # set to False if you are not using Azure OpenAI
Expand All @@ -82,12 +82,12 @@ Configure your Azure OpenAI or OpenAI API keys in [`docker-compose.yml`](./docke
...
```

Alternatively, if you do not have access to Azure OpenAI or OpenAI API keys, you can run the app without the `ai-service` by commenting out the `aiservice` section in [`docker-compose.yml`](./docker-compose.yml). For example:
Alternatively, if you do not have access to Azure OpenAI or OpenAI API keys, you can run the app without the `ai-service` by commenting out the `ai-service` section in [`docker-compose.yml`](./docker-compose.yml). For example:

```yaml
# aiservice:
# ai-service:
# build: src/ai-service
# container_name: 'aiservice'
# container_name: 'ai-service'
...
# networks:
# - backend_services
Expand Down Expand Up @@ -119,7 +119,29 @@ azd auth login
az login
```

Deploy the app with a single command.
The `makeline-service` supports both MongoDB and SQL API for accessing data in Azure CosmosDB. The default API is `MongoDB`, but you can use SQL API. To use the SQL API for Azure CosmosDB, you must provision the service using the `GlobalDocumentDB` account kind. You can set the Azure CosmosDB account kind by running the following command prior to running `azd up`:

```bash
azd env set AZURE_COSMOSDB_ACCOUNT_KIND GlobalDocumentDB
```

By default, all application containers will be sourced from the [GitHub Container Registry](https://github.com/orgs/Azure-Samples/packages?repo_name=aks-store-demo). If you want to deploy apps from an Azure Container registry instead, you can do so by setting the following environment variable.

```bash
azd env set DEPLOY_AZURE_CONTAINER_REGISTRY true
```

This will instruct the Terraform templates to provision an Azure Container Registry and enable authentication from the AKS cluster.

When you choose to deploy containers from Azure Container Registry, you will have the option to import containers from GitHub Container Registry using the `az acr import` command or build containers from source using the `az acr build` command.

To build containers from source, run the following command.

```bash
azd env set BUILD_CONTAINERS true
```

Provision and deploy the app with a single command.

```bash
azd up
Expand All @@ -131,11 +153,6 @@ Once the deployment is complete, you can verify all the services are running and

- In the Azure portal, navigate to your Azure Service Bus resource and use Azure Service Bus explorer to check for order messages
- In the Azure portal, navigate to your Azure Cosmos DB resource and use the database explorer to check for order records
- Port-forward the store-admin service (using the command below) then open http://localhost:8081 in your browser and ensure you can add product descriptions using the AI service

```bash
kubectl port-forward svc/store-admin 8081:80
```

## Additional Resources

Expand Down
13 changes: 7 additions & 6 deletions aks-store-all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,16 @@ spec:
image: ghcr.io/azure-samples/aks-store-demo/product-service:latest
ports:
- containerPort: 3002
env:
- name: AI_SERVICE_URL
value: "http://ai-service:5001/"
resources:
requests:
cpu: 1m
memory: 1Mi
limits:
cpu: 1m
memory: 7Mi
cpu: 2m
memory: 10Mi
readinessProbe:
httpGet:
path: /health
Expand Down Expand Up @@ -374,7 +377,7 @@ spec:
path: /health
port: 8080
failureThreshold: 3
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
Expand Down Expand Up @@ -430,8 +433,6 @@ spec:
value: "http://product-service:3002/"
- name: VUE_APP_MAKELINE_SERVICE_URL
value: "http://makeline-service:3001/"
- name: VUE_APP_AI_SERVICE_URL
value: "http://ai-service:5001/"
resources:
requests:
cpu: 1m
Expand All @@ -444,7 +445,7 @@ spec:
path: /health
port: 8081
failureThreshold: 3
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
Expand Down
9 changes: 6 additions & 3 deletions aks-store-quickstart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,16 @@ spec:
image: ghcr.io/azure-samples/aks-store-demo/product-service:latest
ports:
- containerPort: 3002
env:
- name: AI_SERVICE_URL
value: "http://ai-service:5001/"
resources:
requests:
cpu: 1m
memory: 1Mi
limits:
cpu: 1m
memory: 7Mi
cpu: 2m
memory: 10Mi
readinessProbe:
httpGet:
path: /health
Expand Down Expand Up @@ -253,7 +256,7 @@ spec:
path: /health
port: 8080
failureThreshold: 3
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
Expand Down
7 changes: 6 additions & 1 deletion azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

name: aks-store-demo
metadata:
template: aks-store-dmeo@1.0.0
template: aks-store-demo@1.0.0
hooks:
preprovision:
shell: sh
Expand All @@ -14,5 +14,10 @@ hooks:
continueOnError: false
interactive: false
run: infra/azd-hooks/postprovision.sh
predeploy:
shell: sh
continueOnError: false
interactive: false
run: infra/azd-hooks/predeploy.sh
infra:
provider: terraform
2 changes: 1 addition & 1 deletion charts/aks-store-demo/templates/ai-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: order-service
image: ghcr.io/azure-samples/aks-store-demo/ai-service:1.0.0
image: {{ .Values.aiService.image.repository }}:{{ .Values.aiService.image.tag }}
ports:
- containerPort: 5001
envFrom:
Expand Down
9 changes: 8 additions & 1 deletion charts/aks-store-demo/templates/makeline-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ data:
ORDER_QUEUE_NAME: "{{ .Values.makelineService.orderQueueName }}"
ORDER_DB_URI: "{{ .Values.makelineService.orderDBUri }}"
ORDER_DB_NAME: "{{ .Values.makelineService.orderDBName }}"
{{- if eq .Values.makelineService.useSqlApi true }}
ORDER_DB_API: cosmosdbsql
ORDER_DB_CONTAINER_NAME: "{{ .Values.makelineService.orderDBContainerName }}"
ORDER_DB_PARTITION_KEY: "storeId"
ORDER_DB_PARTITION_VALUE: "pets"
{{- else }}
ORDER_DB_COLLECTION_NAME: "{{ .Values.makelineService.orderDBCollectionName }}"
{{- end }}
---
{{- if and .Values.makelineService.orderDBUsername .Values.makelineService.orderDBPassword }}
apiVersion: v1
Expand Down Expand Up @@ -39,7 +46,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: makeline-service
image: ghcr.io/azure-samples/aks-store-demo/makeline-service:1.0.0
image: {{ .Values.makelineService.image.repository }}:{{ .Values.makelineService.image.tag }}
ports:
- containerPort: 3001
envFrom:
Expand Down
2 changes: 1 addition & 1 deletion charts/aks-store-demo/templates/order-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: order-service
image: ghcr.io/azure-samples/aks-store-demo/order-service:1.0.0
image: {{ .Values.orderService.image.repository }}:{{ .Values.orderService.image.tag }}
ports:
- containerPort: 3000
envFrom:
Expand Down
9 changes: 6 additions & 3 deletions charts/aks-store-demo/templates/product-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ spec:
"kubernetes.io/os": linux
containers:
- name: product-service
image: ghcr.io/azure-samples/aks-store-demo/product-service:1.0.0
image: {{ .Values.productService.image.repository }}:{{ .Values.productService.image.tag }}
ports:
- containerPort: 3002
env:
- name: AI_SERVICE_URL
value: "http://ai-service:5001/"
resources:
requests:
cpu: 1m
memory: 1Mi
limits:
cpu: 1m
memory: 6Mi
cpu: 2m
memory: 10Mi
readinessProbe:
httpGet:
path: /health
Expand Down
8 changes: 4 additions & 4 deletions charts/aks-store-demo/templates/store-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: store-admin
image: ghcr.io/azure-samples/aks-store-demo/store-admin:1.0.0
image: {{ .Values.storeAdmin.image.repository }}:{{ .Values.storeAdmin.image.tag }}
ports:
- containerPort: 8081
name: store-admin
Expand All @@ -25,8 +25,8 @@ spec:
value: "http://product-service:3002/"
- name: VUE_APP_MAKELINE_SERVICE_URL
value: "http://makeline-service:3001/"
- name: VUE_APP_AI_SERVICE_URL
value: "http://ai-service:5001/"
- name: VUE_APP_AI_SERVICE_URL # this key/value pair is to support previous versions of store-admin <= 1.1.0
value: "http://ai-service:5001/" # container images hosted on ghcr.io and will be removed in future releases
resources:
requests:
cpu: 1m
Expand All @@ -39,7 +39,7 @@ spec:
path: /health
port: 8081
failureThreshold: 3
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
Expand Down
4 changes: 2 additions & 2 deletions charts/aks-store-demo/templates/store-front.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: store-front
image: ghcr.io/azure-samples/aks-store-demo/store-front:1.0.0
image: {{ .Values.storeFront.image.repository }}:{{ .Values.storeFront.image.tag }}
ports:
- containerPort: 8080
name: store-front
Expand All @@ -37,7 +37,7 @@ spec:
path: /health
port: 8080
failureThreshold: 3
initialDelaySeconds: 15
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion charts/aks-store-demo/templates/virtual-customer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: virtual-customer
image: ghcr.io/azure-samples/aks-store-demo/virtual-customer:1.0.0
image: {{ .Values.virtualCustomer.image.repository }}:{{ .Values.virtualCustomer.image.tag }}
env:
- name: ORDER_SERVICE_URL
value: http://order-service:3000/
Expand Down
2 changes: 1 addition & 1 deletion charts/aks-store-demo/templates/virtual-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
"kubernetes.io/os": linux
containers:
- name: virtual-worker
image: ghcr.io/azure-samples/aks-store-demo/virtual-worker:1.0.0
image: {{ .Values.virtualWorker.image.repository }}:{{ .Values.virtualWorker.image.tag }}
env:
- name: MAKELINE_SERVICE_URL
value: http://makeline-service:3001
Expand Down
36 changes: 34 additions & 2 deletions charts/aks-store-demo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ aiService:
managedIdentityClientId: ""
useAzureOpenAi: true
useAzureAd: true
image:
repository: "ghcr.io/azure-samples/aks-store-demo/ai-service"
tag: "latest"

orderService:
useAzureServiceBus: false # when false, local rabbitmq will be used
Expand All @@ -25,25 +28,54 @@ orderService:
queuePassword: "password"
queueName: "orders"
queueTransport: ""
image:
repository: "ghcr.io/azure-samples/aks-store-demo/order-service"
tag: "latest"

makelineService:
useAzureCosmosDB: false # when false, local mongodb will be used
useSqlApi: false # when false, mongodb api for azure cosmosdb will be used
orderQueueUri: "amqp://rabbitmq:5672"
orderQueueUsername: "username"
orderQueuePassword: "password"
orderQueueName: "orders"
orderDBUri: "mongodb://mongodb:27017"
orderDBName: "orderdb"
orderDBCollectionName: "orders"
orderDBContainerName: "orders"
orderDBUsername: ""
orderDBPassword: ""
image:
repository: "ghcr.io/azure-samples/aks-store-demo/makeline-service"
tag: "latest"

storeFront:
serviceType: LoadBalancer
productService:
image:
repository: "ghcr.io/azure-samples/aks-store-demo/product-service"
tag: "latest"

storeAdmin:
image:
repository: "ghcr.io/azure-samples/aks-store-demo/store-admin"
tag: "latest"
serviceType: LoadBalancer

storeFront:
image:
repository: "ghcr.io/azure-samples/aks-store-demo/store-front"
tag: "latest"
serviceType: LoadBalancer

virtualCustomer:
image:
repository: "ghcr.io/azure-samples/aks-store-demo/virtual-customer"
tag: "latest"

virtualWorker:
image:
repository: "ghcr.io/azure-samples/aks-store-demo/virtual-worker"
tag: "latest"

podAnnotations: {}

podSecurityContext: {}
Expand Down
Loading
Loading