Deploy your Application
- Introduction
- Prerequisites
- Log in
- Connect your Kubernetes cluster
- Match your Application to the cluster
- Create your Application
- Create a new workload
- Add container image to workload
- Add container commands and arguments
- Add environment variables to workloads
- Deploy the Application
- Cleaning up
- Switch interfaces
- Recap
- Next steps
On this page
- Introduction
- Prerequisites
- Log in
- Connect your Kubernetes cluster
- Match your Application to the cluster
- Create your Application
- Create a new workload
- Add container image to workload
- Add container commands and arguments
- Add environment variables to workloads
- Deploy the Application
- Cleaning up
- Switch interfaces
- Recap
- Next steps
Introduction
This tutorial guides you through the process of deploying your first Application using the Humanitec Platform Orchestrator. You will learn how to
- Create an Application
- Connect the Orchestrator to a Kubernetes cluster
- Deploy a Workload to your cluster
- Modify the Workload
- Use both the Portal as well as Score and the
humctl
CLI
Prerequisites
To get started you’ll need:
- A Humanitec Organization. If you do not have one, sign up here for a free trial
- (optional) A Kubernetes cluster to deploy your Workload onto. Its API server should be publicly accessible for the cloud-based Platform Orchestrator. If you do not have a cluster ready, not a problem - we will provide a simple way to spin one up along the way
- (optional) The
humctl
CLI installed
Log in
To begin, navigate to the Portal login page and choose your preferred authentication option.
If it was you who created the Humanitec Organization, select the same option you used for that creation to log back in again.
After logging in, you start out on the “Applications” screen. This screen showcases all the Applications you can access within your Organization.
Execute this command and follow the on-screen instructions:
humctl login
Connect your Kubernetes cluster
The Platform Orchestrator always needs a target Kubernetes cluster to deploy your Workload into.
Available clusters are configured in the Resource Management section in the Portal. Click on that item in the main navigation on the left. You will see a list of Platform Orchestrator Resource Definitions. They instruct the Orchestrator how to handle a particular Resource your Workloads require, including the Kubernetes clusters.
If you are just starting out with the Orchestrator, you will see a number of “Default” items only. If you or another member of your Organization has already configured Resource Definitions, they will show up in this list.
Enter k8s-cluster
into the Filter resources field at the top. This will show Kubernetes cluster Resource Definitions only. For new Organizations, this list will be empty.
You have these options to proceed:
Five-minute-IDP | Bring your own cluster | Reference architecture |
---|---|---|
Set up a local demo cluster following the Five-minute IDP Duration: 5 min No need to deploy the demo Workload, just perform the setup Ephemeral (throw-away) setup for demo purposes |
Connect an existing cluster by following the Quickstart up to “Connect your cluster” (guided), or using the instructions in Kubernetes (self-guided) Duration: 15-30 min One-time effort per cluster, can be re-used going forward |
Set up the reference architecture Duration: 15-30 min Creates a new cluster plus supporting cloud infrastructure, and connects it to the Platform Orchestrator |
For new starters, our recommendation is to go for the “Five-minute-IDP” option first and then diving in deeper into a more permanent setup using your own cluster and/or setting up the Reference architecture.
Choose and execute one option. As an outcome, you will now see a new k8s-cluster
in the list of Resource Definitions in Resource Management.
Match your Application to the cluster
You have the choice to use either the Portal or the humctl
CLI with Score going forward.
We suggest to try first the one, then the other, in any order, to become acquainted with both interfaces.
To make the Platform Orchestrator pick the right cluster for your Application, you need to add Matching Criteria to the cluster’s Resource Definition.
You will add matching criteria for an Application ID
of demo-app
. You will create an Application with this ID in the next step.
- Navigate to the Resource Management menu and select your target Kubernetes cluster
- Select Matching criteria
- Select + Add new criteria
- Enter
Application ID
isdemo-app
- Click Save
Choose the Resource Definition of the target Kubernetes cluster. You can use humctl get resource-definition
to get a list of available Resource Definitions, or go to the “Resource Management” section in the Platform Orchestrator UI.
export K8S_RESDEF=<my-k8s-cluster-resource-definition-id>
Also set your Humanitec Organization ID (must be all lowercase):
export HUMANITEC_ORG=<your-org-id>
Create the matching criteria and capture their ID for later use:
export CRITERIA_ID=$(humctl api post /orgs/${HUMANITEC_ORG}/resources/defs/${K8S_RESDEF}/criteria \
-d '{
"app_id": "demo-app"
}' | jq --raw-output '.id' )
echo $CRITERIA_ID
Your target cluster is now finally ready to be deployed to. Let’s dive in and create your first Application.
Create your Application
- From the Applications screen, select Create new application
- Enter
demo-app
as the name for your Application and select Create new application to continue
Following this, you’ll land on your Application’s Status page. Here, you can find Application level settings, like Shared Values & Secrets or access management, and a list of Environments. The development
Environment has been created by default.
To add Workloads or Shared Resources to your Application, click on the development
Environment and continue to create a new Workload.
humctl create app demo-app
Create a new workload
- Click on the Create draft delta button in the top right corner. This will create a new draft Deployment where you can make changes
- Click the edit icon next to the “Untitled draft” title and give your draft the name
Adding sample-service
- To add your first workload, select + Create new workload
- Enter
sample-service
as the name for your workload , then select Create workload
default-module
profile. This will create a regular Kubernetes Deployment. Using a different Workload Profile like default-cronjob
or default-job
is an advanced topic we do not need to handle now.
- Click on the sample-service link to navigate to the Workload details page
On the Workload details page, you have the ability to:
- Add a container image
- Add resource dependencies
- Add DNS resources
- Specify a service account
- Add ports, and more
Next, add a container image to your Workload.
Create a Score file that describes your Workload. You will use that file for the upcoming deployment.
cat <<EOF > score.yaml
apiVersion: score.dev/v1b1
metadata:
name: sample-service
containers:
busybox:
image: busybox:latest
command: ["/bin/sh"]
args: ["-c", "while true; do printenv && sleep 10; done"]
variables:
SAMPLE_VARIABLE: Sample value
CURRENT_ENV: \${context.env.id}
EOF
This Score file describes a Workload named sample-service
having a single container named busybox
, using the image busybox:latest
.
Add container image to workload
- Click on + Add container
- Scroll to the bottom and enter the image name
busybox:latest
- Click on Add image and then Create to add the container to your Workload
You’re good! The Score file already contains the container image
.
Add container commands and arguments
The newly added container needs some additional commands to run properly.
- In the “Containers” section, click on the busybox container
- Scroll down to “Command overrides” and click Edit YAML
- Place the cursor in the first line and enter this content:
- '/bin/sh'
- Click Save.
Supplement the command with additional arguments.
- Scroll down to “Argument overrides” and click Edit YAML
- Place the cursor in the first line and enter this content:
- '-c'
- 'while true; do printenv && sleep 10; done'
- Click Save.
You’re good! The Score file already contains the container command
and args
.
These instructions will have the container periodically log all of its environment variables.
Add environment variables to workloads
- Scroll up to the “Variables” section and select + Add Variables
- For “Key”, add
SAMPLE_VARIABLE
- For “Value”, add
Sample value
- Click Save
The Platform Orchestrator also lets you tap into the Workload’s runtime context by using specific Placeholders. Add another variable:
- For “Key”, add
CURRENT_ENV
- For “Value”, add
${context.env.id}
- Click Save
You’re good! The Score file already contains the variables
section.
While the SAMPLE_VARIABLE
has a static value, the CURRENT_ENV
variable will be populated with the ID of the Application Environment your Workload is running in.
Your sample Application is now ready to be deployed.
Deploy the Application
Ready to deploy your Application? Follow these steps:
- Scroll to the top of the screen and select Review and Deploy
- Should you have left the previous screen in the meantime, you can navigate back to the draft you have been preparing by going to the Applications menu and selecting the
development
environment of thedemo-app
. The select Draft deltas and the existing Delta namedAdding sample-service
. This is the one you configured earlier. Click Review & Deploy. - Type a comment in the Comment field, then click Deploy again
You will see the Deployment being executed. Wait for the status to show “Succeeded”.
Click the link to the development
Environment. The Status page is now populated with an overview of the last Deployment, its status, Workloads, and Shared resources that were provisioned along with them.
The Deployment status will display as Running
.
Now inspect your workload’s output.
- Click on the
sample-service
Workload - On the Workload screen, click on the
busybox
container
The container screen will show the container logs. You should see those lines included in the output:
2030-05-17T10:45:09Z CURRENT_ENV=development
2030-05-17T10:45:09Z SAMPLE_VARIABLE=Sample value
Perform the Deployment:
humctl score deploy -f score.yaml --app demo-app --env development --wait
The output will show Status: succeeded
when finished.
--wait
flag to skip the detailed progress outout and return immediately. The deployment will run asynchonously.
Check the runtime status of the target Environment:
humctl api get /orgs/${HUMANITEC_ORG}/apps/demo-app/envs/development/runtime
The response will show "status": "Success"
for the sample-service
.
You can also access the container logs via the Platform Orchestrator:
humctl api get /orgs/${HUMANITEC_ORG}/apps/demo-app/envs/development/logs?workload_id=sample-service&container_id=busybox
You will see the payload values SAMPLE_VARIABLE=Sample value
and CURRENT_ENV=development
.
Quit the log display using Cmd+C or CTRL+C.
You have successfully deployed your first Application via the Humanitec Platform Orchestrator! The Application runs on the cluster you provided and has dynamic runtime information injected into the Workload.
kubectl
and know your way around, feel free to find and inspect the newly created namespace and the objects inside it.Cleaning up
Remove your setup unless you want to keep working with it.
Deleting the Application will make the Platform Orchestrator un-deploy the Workload from the cluster.
From the Applications menu, click the trash icon for the demo-app
and confirm the deletion.
Delete the matching criteria from the cluster Resource Definition:
- Navigate to the Resource Management menu and select your target Kubernetes cluster
- Select Matching criteria
- Click the trash icon for the
demo-app
criteria
If you have been using the Five-minute IDP setup, execute the cleanup now.
Delete the Application:
humctl delete app demo-app
Delete the Score file:
rm score.yaml
Delete the matching criteria from the cluster:
humctl api delete /orgs/${HUMANITEC_ORG}/resources/defs/${K8S_RESDEF}/criteria/${CRITERIA_ID}
Switch interfaces
This tutorial offered both the Portal and the humctl
CLI plus Score as alternative interfaces. If you have been using one and and would now like to experience the other, we invite you to go back to Matching your Application and follow the steps once more, using the alternative instructions.
Recap
Congratulations! You have successfully completed the tutorial and deployed your first Application. You learned how to:
- Connect your Kubernetes cluster to the Platform Orchestrator
- Create a new Application
- Configure a Workload
- Inject concext information into the Workload using Placeholders
- Use either the Portal,
humctl
with Score, or both, to describe your Workload and manage Platform Orchestrator objects
Next steps
If you haven’t done so in the process:
- Set up the Five-minute IDP
- Follow the Quickstart guide tp experience all Platform Orchestrator fundamentals in 60 minutes
- Set up the reference architecture
- Start building your estate by connecting your own Kubernetes cluster
- Have a look the the Score examples to see additional configuration options for your Workloads
- Dive deeper into Resource management by following the tutorials Update Resource Definitions for related Applications or Provision S3 buckets