Skip to content

Commit 82e74f1

Browse files
Merge pull request #5 from score-spec/aks-store-demo
`samples/aks-store-demo`
2 parents 3b1d5a2 + 2dafc6e commit 82e74f1

15 files changed

Lines changed: 418 additions & 25 deletions

File tree

.scripts/test-score-files.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ do
1313
cd $feature
1414
if [[ "$category" = "samples/" ]]; then
1515
make compose-test
16+
make compose-down
1617
make k8s-test
18+
make k8s-down
1719
else
1820
score-compose init --no-sample
1921
score-compose generate score.yaml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
- [Specification](./specification/)
44
- [Resources](./resources/)
55
- [Samples](./samples/)
6-
- [OnlineBoutique](./samples/onlineboutique/)
6+
- [OnlineBoutique](./samples/onlineboutique/)
7+
- [AKS Store Demo](./samples/aks-store-demo/)

samples/aks-store-demo/Makefile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Disable all the default make stuff
2+
MAKEFLAGS += --no-builtin-rules
3+
.SUFFIXES:
4+
5+
## Display a list of the documented make targets
6+
.PHONY: help
7+
help:
8+
@echo Documented Make targets:
9+
@perl -e 'undef $$/; while (<>) { while ($$_ =~ /## (.*?)(?:\n# .*)*\n.PHONY:\s+(\S+).*/mg) { printf "\033[36m%-30s\033[0m %s\n", $$2, $$1 } }' $(MAKEFILE_LIST) | sort
10+
11+
.PHONY: .FORCE
12+
.FORCE:
13+
14+
.score-compose/state.yaml:
15+
score-compose init \
16+
--no-sample \
17+
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml
18+
19+
compose.yaml: order/score.yaml product/score.yaml store-front/score.yaml store-admin/score.yaml makeline/score.yaml .score-compose/state.yaml Makefile
20+
score-compose generate \
21+
order/score.yaml \
22+
product/score.yaml \
23+
store-front/score.yaml \
24+
store-admin/score.yaml \
25+
makeline/score.yaml
26+
27+
## Generate a compose.yaml file from the score specs and launch it.
28+
.PHONY: compose-up
29+
compose-up: compose.yaml
30+
docker compose up --build -d --remove-orphans
31+
sleep 5
32+
33+
## Generate a compose.yaml file from the score spec, launch it and test (curl) the exposed container.
34+
.PHONY: compose-test
35+
compose-test: compose-up
36+
curl $$(score-compose resources get-outputs 'dns.default#store-front.dns' --format '{{ .host }}:8080')
37+
38+
## Delete the containers running via compose down.
39+
.PHONY: compose-down
40+
compose-down:
41+
docker compose down -v --remove-orphans || true
42+
43+
.score-k8s/state.yaml:
44+
score-k8s init \
45+
--no-sample \
46+
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml
47+
48+
manifests.yaml: makeline/score.yaml order/score.yaml product/score.yaml store-admin/score.yaml store-front/score.yaml .score-k8s/state.yaml Makefile
49+
score-k8s generate \
50+
makeline/score.yaml \
51+
order/score.yaml \
52+
product/score.yaml \
53+
store-admin/score.yaml \
54+
store-front/score.yaml
55+
56+
## Create a local Kind cluster.
57+
.PHONY: kind-create-cluster
58+
kind-create-cluster:
59+
./scripts/setup-kind-cluster.sh
60+
61+
NAMESPACE ?= default
62+
## Generate a manifests.yaml file from the score spec and apply it in Kubernetes.
63+
.PHONY: k8s-up
64+
k8s-up: manifests.yaml
65+
kubectl apply \
66+
-f manifests.yaml \
67+
-n ${NAMESPACE}
68+
kubectl wait deployments/store-front \
69+
-n ${NAMESPACE} \
70+
--for condition=Available \
71+
--timeout=90s
72+
kubectl wait pods \
73+
-n ${NAMESPACE} \
74+
-l app.kubernetes.io/name=store-front \
75+
--for condition=Ready \
76+
--timeout=90s
77+
sleep 5
78+
kubectl get pods -n ${NAMESPACE}
79+
80+
## Expose the container deployed in Kubernetes via port-forward.
81+
.PHONY: k8s-test
82+
k8s-test: k8s-up
83+
curl $$(score-k8s resources get-outputs dns.default#store-front.dns --format '{{ .host }}')
84+
85+
## Delete the deployment of the local container in Kubernetes.
86+
.PHONY: k8s-down
87+
k8s-down:
88+
kubectl delete \
89+
-f manifests.yaml \
90+
-n ${NAMESPACE}
91+
sleep 5

samples/aks-store-demo/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# AKS Store demo
2+
3+
![](https://github.com/Azure-Samples/aks-store-demo/raw/main/assets/demo-arch.png)
4+
5+
Deploy the [Azure-Samples/aks-store-demo](https://github.com/Azure-Samples/aks-store-demo) with Score:
6+
7+
- [`score-compose`](./score-compose.md)
8+
- [`score-k8s`](./score-k8s.md)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: score.dev/v1b1
2+
metadata:
3+
name: makeline-service
4+
annotations:
5+
tags: "golang,backend"
6+
containers:
7+
makeline-service:
8+
image: ghcr.io/azure-samples/aks-store-demo/makeline-service:2.1.0
9+
variables:
10+
ORDER_QUEUE_URI: "amqp://${resources.orders-queue.host}:${resources.orders-queue.port}"
11+
ORDER_QUEUE_USERNAME: "${resources.orders-queue.username}"
12+
ORDER_QUEUE_PASSWORD: "${resources.orders-queue.password}"
13+
ORDER_QUEUE_NAME: "orders"
14+
ORDER_DB_URI: "${resources.orders-database.connection}"
15+
ORDER_DB_NAME: "orderdb"
16+
ORDER_DB_COLLECTION_NAME: "orders"
17+
livenessProbe:
18+
httpGet:
19+
path: /health
20+
port: 3001
21+
readinessProbe:
22+
httpGet:
23+
path: /health
24+
port: 3001
25+
resources:
26+
limits:
27+
memory: "20Mi"
28+
cpu: "5m"
29+
requests:
30+
memory: "6Mi"
31+
cpu: "1m"
32+
service:
33+
ports:
34+
http:
35+
port: 3001
36+
targetPort: 3001
37+
resources:
38+
orders-queue:
39+
type: amqp
40+
id: orders-queue
41+
orders-database:
42+
type: mongodb
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
apiVersion: score.dev/v1b1
2+
metadata:
3+
name: order-service
4+
annotations:
5+
tags: "javascript,backend"
6+
containers:
7+
order-service:
8+
image: ghcr.io/azure-samples/aks-store-demo/order-service:2.1.0
9+
variables:
10+
ORDER_QUEUE_HOSTNAME: "${resources.orders-queue.host}"
11+
ORDER_QUEUE_PORT: "${resources.orders-queue.port}"
12+
ORDER_QUEUE_USERNAME: "${resources.orders-queue.username}"
13+
ORDER_QUEUE_PASSWORD: "${resources.orders-queue.password}"
14+
ORDER_QUEUE_NAME: "orders"
15+
FASTIFY_ADDRESS: "0.0.0.0"
16+
livenessProbe:
17+
httpGet:
18+
path: /health
19+
port: 3000
20+
readinessProbe:
21+
httpGet:
22+
path: /health
23+
port: 3000
24+
resources:
25+
limits:
26+
memory: "128Mi"
27+
cpu: "75m"
28+
requests:
29+
memory: "50Mi"
30+
cpu: "1m"
31+
service:
32+
ports:
33+
http:
34+
port: 3000
35+
targetPort: 3000
36+
resources:
37+
orders-queue:
38+
type: amqp
39+
id: orders-queue
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
apiVersion: score.dev/v1b1
2+
metadata:
3+
name: product-service
4+
annotations:
5+
tags: "rust,backend"
6+
containers:
7+
product-service:
8+
image: ghcr.io/azure-samples/aks-store-demo/product-service:2.1.0
9+
livenessProbe:
10+
httpGet:
11+
path: /health
12+
port: 3002
13+
readinessProbe:
14+
httpGet:
15+
path: /health
16+
port: 3002
17+
resources:
18+
limits:
19+
memory: "10Mi"
20+
cpu: "2m"
21+
requests:
22+
memory: "1Mi"
23+
cpu: "1m"
24+
service:
25+
ports:
26+
http:
27+
port: 3002
28+
targetPort: 3002
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```bash
2+
score-compose init --no-sample \
3+
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-compose/10-service.provisioners.yaml
4+
```
5+
6+
```bash
7+
score-compose generate \
8+
order/score.yaml \
9+
product/score.yaml \
10+
store-front/score.yaml \
11+
store-admin/score.yaml \
12+
makeline/score.yaml
13+
```
14+
15+
```bash
16+
docker compose up --build -d --remove-orphans
17+
```
18+
19+
```bash
20+
curl $(score-compose resources get-outputs dns.default#store-front.dns --format '{{ .host }}:8080')
21+
```
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
```bash
2+
score-k8s init --no-sample \
3+
--provisioners https://raw.githubusercontent.com/score-spec/community-provisioners/refs/heads/main/service/score-k8s/10-service.provisioners.yaml
4+
```
5+
6+
```bash
7+
score-k8s generate \
8+
order/score.yaml \
9+
product/score.yaml \
10+
store-front/score.yaml \
11+
store-admin/score.yaml \
12+
makeline/score.yaml
13+
```
14+
15+
```bash
16+
kubectl apply -f manifests.yaml
17+
```
18+
19+
```bash
20+
curl $(score-k8s resources get-outputs dns.default#store-front.dns --format '{{ .host }}:80')
21+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
apiVersion: score.dev/v1b1
2+
metadata:
3+
name: store-admin
4+
annotations:
5+
tags: "javascript,website"
6+
containers:
7+
store-admin:
8+
image: ghcr.io/azure-samples/aks-store-demo/store-admin:2.1.0
9+
livenessProbe:
10+
httpGet:
11+
path: /health
12+
port: 8081
13+
readinessProbe:
14+
httpGet:
15+
path: /health
16+
port: 8081
17+
resources:
18+
limits:
19+
memory: "512Mi"
20+
cpu: "1000m"
21+
requests:
22+
memory: "200Mi"
23+
cpu: "1m"
24+
service:
25+
ports:
26+
http:
27+
port: 8081
28+
targetPort: 8081
29+
resources:
30+
dns:
31+
type: dns
32+
route:
33+
type: route
34+
params:
35+
host: ${resources.dns.host}
36+
path: /
37+
port: 8081
38+
makeline-service:
39+
type: service
40+
product-service:
41+
type: service

0 commit comments

Comments
 (0)