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

score-k8s #25

Merged
merged 3 commits into from
Jun 3, 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
6 changes: 6 additions & 0 deletions .devcontainer/installMoreTools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ tar -xvf score-compose_${SCORE_COMPOSE_VERSION}_linux_amd64.tar.gz
chmod +x score-compose
sudo mv score-compose /usr/local/bin

SCORE_K8S_VERSION=$(curl -sL https://api.github.com/repos/score-spec/score-k8s/releases/latest | jq -r .tag_name)
wget https://github.com/score-spec/score-k8s/releases/download/${SCORE_K8S_VERSION}/score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
tar -xvf score-k8s_${SCORE_K8S_VERSION}_linux_amd64.tar.gz
chmod +x score-k8s
sudo mv score-k8s /usr/local/bin

HUMCTL_VERSION=$(curl -sL https://api.github.com/repos/humanitec/cli/releases/latest | jq -r .tag_name)
curl -fLO https://github.com/humanitec/cli/releases/download/${HUMCTL_VERSION}/cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz
tar -xvf cli_${HUMCTL_VERSION:1}_linux_amd64.tar.gz
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.score-compose/*
!.score-compose/00-service.provisioners.yaml
compose.yaml
.score-k8s/*
!.score-k8s/00-service.provisioners.yaml
manifests.yaml
7 changes: 7 additions & 0 deletions .score-k8s/00-service.provisioners.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- uri: template://service-provisioners/static-service
type: service
init: |
name: {{ splitList "." .Id | last }}
outputs: |
{{ $w := (index .WorkloadServices .Init.name) }}
name: {{ $w.ServiceName | quote }}
49 changes: 48 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ help:
.PHONY: .FORCE
.FORCE:

compose.yaml: apps/ad/score.yaml apps/cart/score.yaml apps/checkout/score.yaml apps/currency/score.yaml apps/email/score.yaml apps/frontend/score.yaml apps/payment/score.yaml apps/productcatalog/score.yaml apps/recommendation/score.yaml apps/shipping/score.yaml
.score-compose/state.yaml:
score-compose init \
--no-sample

compose.yaml: apps/ad/score.yaml apps/cart/score.yaml apps/checkout/score.yaml apps/currency/score.yaml apps/email/score.yaml apps/frontend/score.yaml apps/loadgenerator/score.yaml apps/payment/score.yaml apps/productcatalog/score.yaml apps/recommendation/score.yaml apps/shipping/score.yaml .score-compose/state.yaml Makefile
score-compose generate \
apps/ad/score.yaml \
apps/cart/score.yaml \
apps/checkout/score.yaml \
apps/currency/score.yaml \
apps/email/score.yaml \
apps/frontend/score.yaml \
apps/loadgenerator/score.yaml \
apps/payment/score.yaml \
apps/productcatalog/score.yaml \
apps/recommendation/score.yaml \
Expand All @@ -42,6 +45,50 @@ compose-test: compose-up
compose-down:
docker compose down -v --remove-orphans || true

.score-k8s/state.yaml:
score-k8s init \
--no-sample

manifests.yaml: apps/ad/score.yaml apps/cart/score.yaml apps/checkout/score.yaml apps/currency/score.yaml apps/email/score.yaml apps/frontend/score.yaml apps/loadgenerator/score.yaml apps/payment/score.yaml apps/productcatalog/score.yaml apps/recommendation/score.yaml apps/shipping/score.yaml .score-k8s/state.yaml Makefile
score-k8s generate \
apps/ad/score.yaml \
apps/cart/score.yaml \
apps/checkout/score.yaml \
apps/currency/score.yaml \
apps/email/score.yaml \
apps/frontend/score.yaml \
apps/loadgenerator/score.yaml \
apps/payment/score.yaml \
apps/productcatalog/score.yaml \
apps/recommendation/score.yaml \
apps/shipping/score.yaml

NAMESPACE ?= default
## Generate a manifests.yaml file from the score spec and apply it in Kubernetes.
.PHONY: k8s-up
k8s-up: manifests.yaml
$(MAKE) compose-down || true
kubectl apply \
-f manifests.yaml \
-n ${NAMESPACE}

## Expose the container deployed in Kubernetes via port-forward.
.PHONY: k8s-test
k8s-test: k8s-up
kubectl wait pods \
-n ${NAMESPACE} \
-l score-workload=frontend \
--for condition=Ready \
--timeout=90s
kubectl -n nginx-gateway port-forward service/ngf-nginx-gateway-fabric 8080:80

## Delete the deployment of the local container in Kubernetes.
.PHONY: k8s-down
k8s-down:
kubectl delete \
-f manifests.yaml \
-n ${NAMESPACE}

## Deploy the workloads to Humanitec.
.PHONY: humanitec-deploy
humanitec-deploy:
Expand Down
8 changes: 4 additions & 4 deletions apps/ad/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ containers:
PORT: "9555"
resources:
limits:
memory: "300Mi"
cpu: "300m"
memory: "100Mi"
cpu: "80m"
requests:
memory: "180Mi"
cpu: "200m"
memory: "80Mi"
cpu: "60m"
service:
ports:
grpc:
Expand Down
6 changes: 3 additions & 3 deletions apps/cart/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ containers:
REDIS_ADDR: "${resources.redis-cart.host}:${resources.redis-cart.port},user=${resources.redis-cart.username},password=${resources.redis-cart.password}"
resources:
limits:
memory: "128Mi"
cpu: "300m"
memory: "90Mi"
cpu: "220m"
requests:
memory: "64Mi"
memory: "70Mi"
cpu: "200m"
resources:
redis-cart:
Expand Down
8 changes: 4 additions & 4 deletions apps/checkout/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ containers:
SHIPPING_SERVICE_ADDR: "${resources.shippingservice.name}:50051"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "40Mi"
cpu: "30m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "20Mi"
cpu: "10m"
resources:
cartservice:
type: service
Expand Down
8 changes: 4 additions & 4 deletions apps/currency/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
PORT: "7000"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "60Mi"
cpu: "40m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "40Mi"
cpu: "20m"
service:
ports:
grpc:
Expand Down
8 changes: 4 additions & 4 deletions apps/email/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
PORT: "8080"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "70Mi"
cpu: "30m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "50Mi"
cpu: "10m"
service:
ports:
grpc:
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ containers:
memory: "128Mi"
cpu: "200m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "40Mi"
cpu: "40m"
resources:
adservice:
type: service
Expand Down
8 changes: 4 additions & 4 deletions apps/loadgenerator/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
USERS: "10"
resources:
limits:
memory: "512Mi"
cpu: "500m"
memory: "220Mi"
cpu: "30m"
requests:
memory: "256Mi"
cpu: "300m"
memory: "200Mi"
cpu: "10m"
resources:
frontend:
type: service
8 changes: 4 additions & 4 deletions apps/payment/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
PORT: "50051"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "50Mi"
cpu: "30m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "30Mi"
cpu: "10m"
service:
ports:
grpc:
Expand Down
8 changes: 4 additions & 4 deletions apps/productcatalog/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
PORT: "3550"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "40Mi"
cpu: "30m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "20Mi"
cpu: "10m"
service:
ports:
grpc:
Expand Down
8 changes: 4 additions & 4 deletions apps/recommendation/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ containers:
PRODUCT_CATALOG_SERVICE_ADDR: "${resources.productcatalogservice.name}:3550"
resources:
limits:
memory: "450Mi"
cpu: "200m"
memory: "70Mi"
cpu: "30m"
requests:
memory: "220Mi"
cpu: "100m"
memory: "50Mi"
cpu: "10m"
service:
ports:
grpc:
Expand Down
8 changes: 4 additions & 4 deletions apps/shipping/score.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ containers:
PORT: "50051"
resources:
limits:
memory: "128Mi"
cpu: "200m"
memory: "30Mi"
cpu: "30m"
requests:
memory: "64Mi"
cpu: "100m"
memory: "10Mi"
cpu: "10m"
service:
ports:
grpc:
Expand Down