- [PE-HUM] Create the Online Boutique App
- [PE-HUM] Create the in-cluster Redis resource definition
- [DE-HUM] Deploy the Online Boutique Workloads in Development Environment
- Test the Online Boutique website
flowchart LR
subgraph Humanitec
direction LR
subgraph onlineboutique-app [Online Boutique App]
subgraph Development
direction LR
cartservice-workload([cartservice])
frontend-workload([frontend])
end
end
subgraph Resources
redis-cart-connection>redis-cart-connection]
end
end
subgraph cloud [Humanitec's Cloud]
direction LR
subgraph onlineboutique
frontend{{frontend}}-->cartservice{{cartservice}}
cartservice-->redis-cart-db[(redis-cart)]
end
end
onlineboutique-app-.->onlineboutique
redis-cart-connection-.->redis-cart-db
enduser((End user))-->frontend
HUMANITEC_ORG=FIXME
export HUMANITEC_CONTEXT=/orgs/${HUMANITEC_ORG}
export HUMANITEC_TOKEN=FIXME
ENVIRONMENT=developmentBefore starting, let's clone this current GitHub repository, you will need to have the files locally:
git clone https://github.com/mathieu-benoit/hello-humanitec
cd hello-humanitec/As Platform Engineer, in Humanitec.
ONLINEBOUTIQUE_APP=onlineboutique
humctl create app ${ONLINEBOUTIQUE_APP} \
--name ${ONLINEBOUTIQUE_APP}With curl.
ONLINEBOUTIQUE_APP=onlineboutique
curl "https://api.humanitec.io/orgs/${HUMANITEC_ORG}/apps" \
-X POST \
-H "Authorization: Bearer ${HUMANITEC_TOKEN}" \
-H "Content-Type: application/json" \
-d @- <<EOF
{
"id": "${ONLINEBOUTIQUE_APP}",
"name": "Online Boutique"
}
EOFAs Platform Engineer, in Humanitec.
Create the in-cluster Redis resource definition:
humctl create \
-f resources/yaml/redis-in-cluster.yamlAs Developer, in Humanitec.
FIRST_WORKLOAD="adservice"
COMBINED_DELTA=$(score-humanitec delta --app ${ONLINEBOUTIQUE_APP} --env ${ENVIRONMENT} --org ${HUMANITEC_ORG} --token ${HUMANITEC_TOKEN} --retry -f samples/onlineboutique/${FIRST_WORKLOAD}/score.yaml --extensions samples/onlineboutique/${FIRST_WORKLOAD}/humanitec.score.yaml | jq -r .id)
WORKLOADS="cartservice checkoutservice currencyservice emailservice frontend loadgenerator paymentservice productcatalogservice recommendationservice shippingservice"
for w in ${WORKLOADS}; do \
COMBINED_DELTA=$(score-humanitec delta \
--app ${ONLINEBOUTIQUE_APP} \
--env ${ENVIRONMENT} \
--org ${HUMANITEC_ORG} \
--token ${HUMANITEC_TOKEN} \
--delta ${COMBINED_DELTA} \
--retry \
-f samples/onlineboutique/$w/score.yaml \
--extensions samples/onlineboutique/$w/humanitec.score.yaml \
| jq -r .id); \
done
humctl deploy delta ${COMBINED_DELTA} ${ENVIRONMENT} \
--context /orgs/${HUMANITEC_ORG}/apps/${ONLINEBOUTIQUE_APP}FIRST_WORKLOAD="adservice"
COMBINED_DELTA=$(score-humanitec delta --app ${ONLINEBOUTIQUE_APP} --env ${ENVIRONMENT} --org ${HUMANITEC_ORG} --token ${HUMANITEC_TOKEN} --retry -f samples/onlineboutique/${FIRST_WORKLOAD}/score.yaml --extensions samples/onlineboutique/${FIRST_WORKLOAD}/humanitec.score.yaml | jq -r .id)
WORKLOADS=(cartservice checkoutservice currencyservice emailservice frontend loadgenerator paymentservice productcatalogservice recommendationservice shippingservice)
for ((i = 1; i < ${#WORKLOADS[@]}; i++)); do \
COMBINED_DELTA=$(score-humanitec delta \
--app ${ONLINEBOUTIQUE_APP} \
--env ${ENVIRONMENT} \
--org ${HUMANITEC_ORG} \
--token ${HUMANITEC_TOKEN} \
--delta ${COMBINED_DELTA} \
--retry \
-f samples/onlineboutique/${WORKLOADS[$i]}/score.yaml \
--extensions samples/onlineboutique/${WORKLOADS[$i]}/humanitec.score.yaml \
| jq -r .id); \
done
humctl deploy delta ${COMBINED_DELTA} ${ENVIRONMENT} \
--context /orgs/${HUMANITEC_ORG}/apps/${ONLINEBOUTIQUE_APP}
Note: loadgenerator is deployed to generate both: traffic on these apps and data in the database. If you don't want this, feel free to remove it from the above list of WORKLOADS.
Get the public DNS exposing the frontend Workload:
echo -e "https://$(humctl get active-resources \
--context /orgs/${HUMANITEC_ORG}/apps/${ONLINEBOUTIQUE_APP}/envs/${ENVIRONMENT} \
-o json \
| jq -c '.[] | select(.object.type | contains("dns"))' \
| jq -r .object.resource.host)"With curl.
echo -e "https://$(curl "https://api.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${ONLINEBOUTIQUE_APP}/envs/${ENVIRONMENT}/resources" \
-s \
-H "Authorization: Bearer ${HUMANITEC_TOKEN}" \
-H "Content-Type: application/json" \
| jq -c '.[] | select(.type | contains("dns"))' \
| jq -r .resource.host)"Note: re-run the above command until you get a value.