Skip to content
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
2 changes: 2 additions & 0 deletions .scripts/test-score-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ do
cd $feature
if [[ "$category" = "samples/" ]]; then
make compose-test
make compose-down
make k8s-test
make k8s-down
else
score-compose init --no-sample
score-compose generate score.yaml
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
- [Specification](./specification/)
- [Resources](./resources/)
- [Samples](./samples/)
- [OnlineBoutique](./samples/onlineboutique/)
- [OnlineBoutique](./samples/onlineboutique/)
- [AKS Store Demo](./samples/aks-store-demo/)
91 changes: 91 additions & 0 deletions samples/aks-store-demo/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Disable all the default make stuff
MAKEFLAGS += --no-builtin-rules
.SUFFIXES:

## Display a list of the documented make targets
.PHONY: help
help:
@echo Documented Make targets:
@perl -e 'undef $$/; while (<>) { while ($$_ =~ /## (.*?)(?:\n# .*)*\n.PHONY:\s+(\S+).*/mg) { printf "\033[36m%-30s\033[0m %s\n", $$2, $$1 } }' $(MAKEFILE_LIST) | sort

.PHONY: .FORCE
.FORCE:

.score-compose/state.yaml:
score-compose init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml

compose.yaml: order/score.yaml product/score.yaml store-front/score.yaml store-admin/score.yaml makeline/score.yaml .score-compose/state.yaml Makefile
score-compose generate \
order/score.yaml \
product/score.yaml \
store-front/score.yaml \
store-admin/score.yaml \
makeline/score.yaml

## Generate a compose.yaml file from the score specs and launch it.
.PHONY: compose-up
compose-up: compose.yaml
docker compose up --build -d --remove-orphans
sleep 5

## Generate a compose.yaml file from the score spec, launch it and test (curl) the exposed container.
.PHONY: compose-test
compose-test: compose-up
curl $$(score-compose resources get-outputs 'dns.default#store-front.dns' --format '{{ .host }}:8080')

## Delete the containers running via compose down.
.PHONY: compose-down
compose-down:
docker compose down -v --remove-orphans || true

.score-k8s/state.yaml:
score-k8s init \
--no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml

manifests.yaml: makeline/score.yaml order/score.yaml product/score.yaml store-admin/score.yaml store-front/score.yaml .score-k8s/state.yaml Makefile
score-k8s generate \
makeline/score.yaml \
order/score.yaml \
product/score.yaml \
store-admin/score.yaml \
store-front/score.yaml

## Create a local Kind cluster.
.PHONY: kind-create-cluster
kind-create-cluster:
./scripts/setup-kind-cluster.sh

NAMESPACE ?= default
## Generate a manifests.yaml file from the score spec and apply it in Kubernetes.
.PHONY: k8s-up
k8s-up: manifests.yaml
kubectl apply \
-f manifests.yaml \
-n ${NAMESPACE}
kubectl wait deployments/store-front \
-n ${NAMESPACE} \
--for condition=Available \
--timeout=90s
kubectl wait pods \
-n ${NAMESPACE} \
-l app.kubernetes.io/name=store-front \
--for condition=Ready \
--timeout=90s
sleep 5
kubectl get pods -n ${NAMESPACE}

## Expose the container deployed in Kubernetes via port-forward.
.PHONY: k8s-test
k8s-test: k8s-up
curl $$(score-k8s resources get-outputs dns.default#store-front.dns --format '{{ .host }}')

## Delete the deployment of the local container in Kubernetes.
.PHONY: k8s-down
k8s-down:
kubectl delete \
-f manifests.yaml \
-n ${NAMESPACE}
sleep 5
8 changes: 8 additions & 0 deletions samples/aks-store-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# AKS Store demo

![](https://github.com/Azure-Samples/aks-store-demo/raw/main/assets/demo-arch.png)

Deploy the [Azure-Samples/aks-store-demo](https://github.com/Azure-Samples/aks-store-demo) with Score:

- [`score-compose`](./score-compose.md)
- [`score-k8s`](./score-k8s.md)
42 changes: 42 additions & 0 deletions samples/aks-store-demo/makeline/score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: score.dev/v1b1
metadata:
name: makeline-service
annotations:
tags: "golang,backend"
containers:
makeline-service:
image: ghcr.io/azure-samples/aks-store-demo/makeline-service:2.1.0
variables:
ORDER_QUEUE_URI: "amqp://${resources.orders-queue.host}:${resources.orders-queue.port}"
ORDER_QUEUE_USERNAME: "${resources.orders-queue.username}"
ORDER_QUEUE_PASSWORD: "${resources.orders-queue.password}"
ORDER_QUEUE_NAME: "orders"
ORDER_DB_URI: "${resources.orders-database.connection}"
ORDER_DB_NAME: "orderdb"
ORDER_DB_COLLECTION_NAME: "orders"
livenessProbe:
httpGet:
path: /health
port: 3001
readinessProbe:
httpGet:
path: /health
port: 3001
resources:
limits:
memory: "20Mi"
cpu: "5m"
requests:
memory: "6Mi"
cpu: "1m"
service:
ports:
http:
port: 3001
targetPort: 3001
resources:
orders-queue:
type: amqp
id: orders-queue
orders-database:
type: mongodb
39 changes: 39 additions & 0 deletions samples/aks-store-demo/order/score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: score.dev/v1b1
metadata:
name: order-service
annotations:
tags: "javascript,backend"
containers:
order-service:
image: ghcr.io/azure-samples/aks-store-demo/order-service:2.1.0
variables:
ORDER_QUEUE_HOSTNAME: "${resources.orders-queue.host}"
ORDER_QUEUE_PORT: "${resources.orders-queue.port}"
ORDER_QUEUE_USERNAME: "${resources.orders-queue.username}"
ORDER_QUEUE_PASSWORD: "${resources.orders-queue.password}"
ORDER_QUEUE_NAME: "orders"
FASTIFY_ADDRESS: "0.0.0.0"
livenessProbe:
httpGet:
path: /health
port: 3000
readinessProbe:
httpGet:
path: /health
port: 3000
resources:
limits:
memory: "128Mi"
cpu: "75m"
requests:
memory: "50Mi"
cpu: "1m"
service:
ports:
http:
port: 3000
targetPort: 3000
resources:
orders-queue:
type: amqp
id: orders-queue
28 changes: 28 additions & 0 deletions samples/aks-store-demo/product/score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: score.dev/v1b1
metadata:
name: product-service
annotations:
tags: "rust,backend"
containers:
product-service:
image: ghcr.io/azure-samples/aks-store-demo/product-service:2.1.0
livenessProbe:
httpGet:
path: /health
port: 3002
readinessProbe:
httpGet:
path: /health
port: 3002
resources:
limits:
memory: "10Mi"
cpu: "2m"
requests:
memory: "1Mi"
cpu: "1m"
service:
ports:
http:
port: 3002
targetPort: 3002
21 changes: 21 additions & 0 deletions samples/aks-store-demo/score-compose.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```bash
score-compose init --no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml
```

```bash
score-compose generate \
order/score.yaml \
product/score.yaml \
store-front/score.yaml \
store-admin/score.yaml \
makeline/score.yaml
```

```bash
docker compose up --build -d --remove-orphans
```

```bash
curl $(score-compose resources get-outputs dns.default#store-front.dns --format '{{ .host }}:8080')
```
21 changes: 21 additions & 0 deletions samples/aks-store-demo/score-k8s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```bash
score-k8s init --no-sample \
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml
```

```bash
score-k8s generate \
order/score.yaml \
product/score.yaml \
store-front/score.yaml \
store-admin/score.yaml \
makeline/score.yaml
```

```bash
kubectl apply -f manifests.yaml
```

```bash
curl $(score-k8s resources get-outputs dns.default#store-front.dns --format '{{ .host }}:80')
```
41 changes: 41 additions & 0 deletions samples/aks-store-demo/store-admin/score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: score.dev/v1b1
metadata:
name: store-admin
annotations:
tags: "javascript,website"
containers:
store-admin:
image: ghcr.io/azure-samples/aks-store-demo/store-admin:2.1.0
livenessProbe:
httpGet:
path: /health
port: 8081
readinessProbe:
httpGet:
path: /health
port: 8081
resources:
limits:
memory: "512Mi"
cpu: "1000m"
requests:
memory: "200Mi"
cpu: "1m"
service:
ports:
http:
port: 8081
targetPort: 8081
resources:
dns:
type: dns
route:
type: route
params:
host: ${resources.dns.host}
path: /
port: 8081
makeline-service:
type: service
product-service:
type: service
41 changes: 41 additions & 0 deletions samples/aks-store-demo/store-front/score.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: score.dev/v1b1
metadata:
name: store-front
annotations:
tags: "javascript,website"
containers:
store-front:
image: ghcr.io/azure-samples/aks-store-demo/store-front:2.1.0
livenessProbe:
httpGet:
path: /health
port: 8080
readinessProbe:
httpGet:
path: /health
port: 8080
resources:
limits:
memory: "512Mi"
cpu: "1000m"
requests:
memory: "200Mi"
cpu: "1m"
service:
ports:
http:
port: 8080
targetPort: 8080
resources:
dns:
type: dns
route:
type: route
params:
host: ${resources.dns.host}
path: /
port: 8080
order-service:
type: service
product-service:
type: service
5 changes: 4 additions & 1 deletion samples/onlineboutique/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ k8s-up: manifests.yaml
-l app.kubernetes.io/name=frontend \
--for condition=Ready \
--timeout=90s
sleep 5
kubectl get pods -n ${NAMESPACE}

## Test the expose frontend app
.PHONY: k8s-test
Expand All @@ -110,4 +112,5 @@ k8s-test: k8s-up
k8s-down:
kubectl delete \
-f manifests.yaml \
-n ${NAMESPACE}
-n ${NAMESPACE}
sleep 5
Loading