Learn how to report running artifacts from a Kubernetes cluster to Kosli — using a Helm chart for production, the CLI for a quick test, or an externally scheduled cron job.
Use this file to discover all available pages before exploring further.
By the end of this tutorial, you will have reported a snapshot of your Kubernetes cluster to Kosli, making its running artifacts visible and trackable.
The Kosli K8S reporter Helm chart deploys a inside your cluster that automatically reports running artifacts to Kosli on a schedule. This is the recommended approach for production use.Install Helm if you have not done so.
Create a Kubernetes secret containing your Kosli API token:
Make sure the secret value does not contain trailing whitespace.
Create a tutorial-values.yaml file to configure the chart:
# the cron schedule at which the reporter is triggeredcronSchedule: "*/5 * * * *"kosliApiToken: # the name of the secret containing the Kosli API token secretName: "kosli-api-token" # the key in the secret data that contains the token secretKey: "apikey"reporterConfig: # the name of the Kosli org kosliOrg: "<your-kosli-org-name>" # the name of the Kosli environment to report to kosliEnvironmentName: "k8s-tutorial" # comma-separated list of namespace name regex patterns to report # leave empty to report the entire cluster namespaces: ""
The CronJob will now run every 5 minutes and report what is running in the cluster to Kosli.
If you cannot run the reporter inside the cluster, you can run kosli snapshot k8s from outside on a regular schedule. This requires network access to the cluster from wherever the CLI runs.The example below uses a GitHub Actions scheduled workflow:
The workflow requires the following GitHub Actions secrets: MY_KOSLI_API_TOKEN, GKE_SA_KEY, GKE_PROJECT.
name: Regular Kubernetes reports to Koslion: workflow_dispatch: schedule: - cron: '0 * * * *' # every hourjobs: k8s-report: runs-on: ubuntu-latest permissions: id-token: write contents: write env: KOSLI_API_TOKEN: ${{ secrets.MY_KOSLI_API_TOKEN }} steps: - name: Install Kosli CLI uses: kosli-dev/setup-cli-action@v2 # Replace this step with one that connects to your cluster if not using GKE - name: Connect to GKE uses: 'Swibi/connect-to-gke' with: GCP_SA_KEY: ${{ secrets.GKE_SA_KEY }} GCP_PROJECT_ID: ${{ secrets.GKE_PROJECT }} GKE_CLUSTER: <your-cluster-name> GKE_ZONE: <your-cluster-zone> - name: Report K8S snapshot to Kosli run: kosli snapshot k8s k8s-tutorial --org <your-kosli-org-name> - name: Notify Slack on failure if: ${{ failure() }} uses: rtCamp/action-slack-notify@v2 env: SLACK_CHANNEL: kosli-reports-failure SLACK_COLOR: ${{ job.status }} SLACK_TITLE: Reporting K8S artifacts to Kosli has failed SLACK_USERNAME: GithubActions SLACK_WEBHOOK: ${{ secrets.SLACK_CI_FAILURES_WEBHOOK }} SLACK_MESSAGE: "Reporting K8S artifacts to Kosli has failed. Please check the logs for more details."
This approach is intended for ad-hoc and local testing only. Do not use it in production — use the Helm chart instead.
You have reported a snapshot of your Kubernetes cluster to Kosli. Kosli now tracks the running artifacts in that environment and will record changes as they happen.From here you can: