Skip to content

Commit

Permalink
explicit variable names for workload, versus container
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu-benoit committed May 12, 2024
1 parent 953a26b commit a0653a5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ help:
.PHONY: .FORCE
.FORCE:

CONTAINER_IMAGE = my-sample-container:test
WORKLOAD_NAME = my-sample-workload
CONTAINER_NAME = my-sample-container
CONTAINER_IMAGE = ${CONTAINER_NAME}:test
compose.yaml: score/score.yaml
score-compose init \
--no-sample
score-compose generate score/score.yaml \
--build 'my-sample-container={"context":"app/","tags":["${CONTAINER_IMAGE}"]}' \
--override-property containers.my-sample-container.variables.MESSAGE="Hello, Compose!"
--build '${CONTAINER_NAME}={"context":"app/","tags":["${CONTAINER_IMAGE}"]}' \
--override-property containers.${CONTAINER_NAME}.variables.MESSAGE="Hello, Compose!"

## Generate a compose.yaml file from the score spec and launch it.
.PHONY: compose-up
Expand All @@ -28,7 +30,7 @@ compose-up: compose.yaml
.PHONY: compose-test
compose-test: compose-up
sleep 5
curl $$(score-compose resources get-outputs dns.default#my-sample-workload.dns --format '{{ .host }}:8080')
curl $$(score-compose resources get-outputs dns.default#${WORKLOAD_NAME}.dns --format '{{ .host }}:8080')

## Delete the containers running via compose down.
.PHONY: compose-down
Expand All @@ -38,8 +40,8 @@ compose-down:
values.yaml: score/score.yaml
score-helm run \
-f score/score.yaml \
-p containers.my-sample-container.image=${CONTAINER_IMAGE} \
-p containers.my-sample-container.variables.MESSAGE="Hello, Kubernetes!" \
-p containers.${CONTAINER_NAME}.image=${CONTAINER_IMAGE} \
-p containers.${CONTAINER_NAME}.variables.MESSAGE="Hello, Kubernetes!" \
-o values.yaml

## Load the local container image in the current Kind cluster.
Expand All @@ -57,7 +59,7 @@ k8s-up: values.yaml
-n ${NAMESPACE} \
--install \
--create-namespace \
my-sample-workload \
${WORKLOAD_NAME} \
--repo https://score-spec.github.io/score-helm-charts \
workload \
--values values.yaml
Expand All @@ -67,17 +69,17 @@ k8s-up: values.yaml
k8s-test: k8s-up
kubectl wait pods \
-n ${NAMESPACE} \
-l app.kubernetes.io/name=my-sample-workload \
-l app.kubernetes.io/name=${WORKLOAD_NAME} \
--for condition=Ready \
--timeout=90s
kubectl port-forward \
-n ${NAMESPACE} \
service/my-sample-workload \
service/${WORKLOAD_NAME} \
8080:8080

## Delete the the deployment of the local container in Kubernetes.
.PHONY: k8s-down
k8s-down:
helm uninstall \
-n ${NAMESPACE} \
my-sample-workload
${WORKLOAD_NAME}

0 comments on commit a0653a5

Please sign in to comment.