Last active
October 25, 2024 11:33
-
-
Save mathieu-benoit/f72516de0be5c50d6535328a6ecdc299 to your computer and use it in GitHub Desktop.
humctl-dev-demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# setup | |
if [ ! -f demo-magic.sh ]; then | |
curl -LO https://github.com/paxtonhare/demo-magic/raw/master/demo-magic.sh | |
fi | |
. demo-magic.sh -d #-n | |
clear | |
# demo cleanup | |
rm score.yaml | |
humctl delete env ephemeral && true | |
humctl delete value MESSAGE && true | |
# Also, delete and recreate the App, as Admin or Manager | |
clear | |
# demo | |
HUMANITEC_ENV=development | |
humctl config set org ${HUMANITEC_ORG} | |
clear | |
pe "humctl version" | |
pe "humctl config set app ${HUMANITEC_APP}" | |
pe "humctl config set env ${HUMANITEC_ENV}" | |
pe "humctl login" | |
clear | |
pe "humctl get apps" | |
pe "humctl get envs" # TODO: add in the tutorial | |
pei "clear && echo \"### 1/5 use case: Deploy a sample Workload.\"" | |
cat <<EOF > score.yaml | |
apiVersion: score.dev/v1b1 | |
metadata: | |
name: my-workload | |
containers: | |
my-container: | |
image: . | |
EOF | |
# Show the Score file in VS Code | |
pe "humctl score validate score.yaml" # TODO: add in the tutorial | |
pe "humctl score deploy -f score.yaml --image ghcr.io/mathieu-benoit/my-sample-workload:latest --message \"Initial deployment\"" # TODO: which container image to use here by default? Yes, customer should have their own, but let's propose a working example. | |
pe "humctl get deploy ." | |
pe "echo 'See Deployment in Humanitec Portal:'" | |
echo "https://app.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/status" | |
pe "humctl get active-resources" | |
# Add a variable | |
pei "clear && echo \"### 2/5 use case: Add a variable.\"" | |
pe "humctl create value MESSAGE \"Hello, Humanitec!\" --env \"\"" | |
cat <<EOF > score.yaml | |
apiVersion: score.dev/v1b1 | |
metadata: | |
name: my-workload | |
containers: | |
my-container: | |
image: . | |
variables: | |
MESSAGE: \${resources.env.MESSAGE} | |
resources: | |
env: | |
type: environment | |
EOF | |
# Show the Score file in VS Code | |
pe "humctl score validate score.yaml" # TODO: add in the tutorial | |
pe "humctl score deploy -f score.yaml --image ghcr.io/mathieu-benoit/my-sample-workload:latest --message \"Add a container variable\"" | |
pe "humctl get deploy ." | |
pe "humctl diff sets deploy/+0 deploy/+1" | |
pe "echo 'See Deployment in Humanitec Portal:'" | |
echo "https://app.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/status" | |
pe "humctl get active-resources" | |
# Add a resource | |
pei "clear && echo \"### 3/5 use case: Deploy a Redis database resource.\"" | |
pe "humctl score available-resource-types" # TODO: add in the tutorial | |
pe "humctl score available-resource-types --filter-type redis -o yaml" # TODO: add in the tutorial | |
cat <<EOF > score.yaml | |
apiVersion: score.dev/v1b1 | |
metadata: | |
name: my-workload | |
containers: | |
my-container: | |
image: . | |
variables: | |
MESSAGE: \${resources.env.MESSAGE} | |
REDIS_HOST: \${resources.my-cache.host} | |
REDIS_PORT: \${resources.my-cache.port} | |
REDIS_USERNAME: \${resources.my-cache.username} | |
REDIS_PASSWORD: \${resources.my-cache.password} | |
resources: | |
env: | |
type: environment | |
my-cache: | |
type: redis | |
EOF | |
# Show the Score file in VS Code | |
pe "humctl score validate score.yaml" # TODO: add in the tutorial | |
pe "humctl score deploy -f score.yaml --image ghcr.io/mathieu-benoit/my-sample-workload:latest --message \"Add a Redis resource\"" | |
pe "humctl get deploy ." | |
pe "humctl diff sets deploy/+0 deploy/+1" | |
pe "echo 'See Deployment in Humanitec Portal:'" | |
echo "https://app.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/status" | |
pe "humctl get active-resources" | |
# Create Ephemeral Env | |
pei "clear && echo \"### 4/5 use case: Create an Ephemeral Env with new variable value and a DNS resource.\"" | |
export HUMANITEC_EPH_ENV=ephemeral | |
pe "humctl create env ${HUMANITEC_EPH_ENV} -t development" | |
pe "humctl get envs" | |
pe "humctl create value MESSAGE \"Hello, Ephemeral Environment!\" --env ${HUMANITEC_EPH_ENV}" | |
pe "humctl score available-resource-types --filter-type dns -o yaml" # TODO: add in the tutorial | |
cat <<EOF > score.yaml | |
apiVersion: score.dev/v1b1 | |
metadata: | |
name: my-workload | |
containers: | |
my-container: | |
image: . | |
variables: | |
MESSAGE: \${resources.env.MESSAGE} | |
REDIS_HOST: \${resources.my-cache.host} | |
REDIS_PORT: \${resources.my-cache.port} | |
REDIS_USERNAME: \${resources.my-cache.username} | |
REDIS_PASSWORD: \${resources.my-cache.password} | |
resources: | |
env: | |
type: environment | |
my-cache: | |
type: redis | |
my-dns: | |
type: dns | |
my-route: | |
type: route | |
params: | |
host: \${resources.my-dns.host} | |
path: / | |
port: 8080 | |
service: | |
ports: | |
tcp: | |
port: 8080 | |
targetPort: 8080 | |
EOF | |
# Show the Score file in VS Code | |
pe "humctl score validate score.yaml" # TODO: add in the tutorial | |
pe "humctl score deploy -f score.yaml --image ghcr.io/mathieu-benoit/my-sample-workload:latest --message \"Add a DNS resource\" --env ${HUMANITEC_EPH_ENV}" | |
pe "humctl get deploy . --env ${HUMANITEC_EPH_ENV}" | |
pe "humctl diff sets env/${HUMANITEC_EPH_ENV} env/${HUMANITEC_ENV}" | |
pe "echo 'See Deployment in Humanitec Portal:'" | |
echo "https://app.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_EPH_ENV}/status" | |
pe "humctl get active-resources --env ${HUMANITEC_EPH_ENV}" | |
# Delete Ephemeral Env | |
pei "clear && echo \"### 5/5 use case: Delete Ephemeral Env and deploy new updates in Development Env.\"" | |
pe "humctl delete env ${HUMANITEC_EPH_ENV}" | |
pe "humctl get envs" | |
pe "humctl score deploy -f score.yaml --image ghcr.io/mathieu-benoit/my-sample-workload:latest --message \"Add a DNS resource\"" | |
pe "humctl get deploy ." | |
pe "humctl diff sets deploy/+0 deploy/+1" | |
pe "echo 'See Deployment in Humanitec Portal:'" | |
echo "https://app.humanitec.io/orgs/${HUMANITEC_ORG}/apps/${HUMANITEC_APP}/envs/${HUMANITEC_ENV}/status" | |
pe "humctl get active-resources" | |
pei "echo \"### End of the demo.\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.