docker environment, use Kosli to record build and deployment events, and track what
artifacts are running in your runtime environment.
This tutorial uses the docker Kosli environment type, but the same steps can be applied to
other supported environment types.
Playground is an alternative version of this tutorial in which you
embed the Kosli commands in a GitHub CI Workflow (in a clone of the playground repo) rather than running them
directly from your terminal.
Prerequisites
To follow the tutorial, you will need to:- Install
Docker. - Create a Kosli account if you have not got one already.
- Install Kosli CLI.
- Get a Kosli API token.
Steps
Step 1: Setup
Set theKOSLI_ORG and KOSLI_API_TOKEN environment variables:
Step 2: Create a Kosli Flow
The Flow’s yml template-file exists in the git repository. Confirm this yml file exists by catting it:nginx:
quickstart-nginx using this yml template-file:
quickstart-nginx was created:
In the web interface you can select Flows on the left.
It will show you that you have a quickstart-nginx Flow.
If you select the Flow it will show that no Artifacts have
been reported yet.
Step 3: Create a Kosli Trail
Create a Kosli Trail, in thequickstart-nginx Flow, whose
name is the repository’s current git-commit:
Step 4: Attest an Artifact to Kosli
Typically, you would build an Artifact in your CI system, in response to a git-commit being pushed. The quickstart-docker repository contains adocker-compose.yml file that uses a public nginx
docker image which you will be using as your Artifact in this tutorial instead.
Now report the artifact to Kosli using the kosli attest artifact command.
Note:
- The
--nameflag has the valuenginxwhich is the (only) artifact name defined in thekosli.ymlfile from step 2. - The
--build-urland--commit-urlflags have dummy values; in a real call these would be the CI and git hosting provider URLs respectively.
Step 5: Create a Kosli environment
Create a Kosli Environment calledquickstart whose type is docker:
If you refresh the Environments web page in your Kosli account,
it will show you that you have a quickstart environment and that
no snapshot reports have been received yet.
Step 6: Report what is running in your environment
First, run the artifact:kosli snapshot docker command reports all the
docker containers running in your environment, equivalent to the output from
docker ps. This tutorial only shows the nginx container
in the examples.
If you refresh the Environments web page in your Kosli account, you will see
that there is now a timestamp for Last Change At column.
Select the quickstart link on left for a detailed view of what is currently running.
Step 7: Search Kosli
Now that you have reported your Artifact and what’s running in your runtime environment, you can use thekosli search command to find everything Kosli knows about an Artifact or a git-commit.
For example, you can give Kosli search the git-commit whose CI run built and deployed the Artifact: