A practical guide to use and install Komiser
Tags: cloudnative, cloud, guide, tutorial
Published: 2023-01-18 15:06:22

[Komiser](https://www.komiser.io/?utm_source=dev.to&utm_medium=social&utm_campaign=content) is an open-source cloud-agnostic resource manager. It integrates with multiple cloud providers (including AWS, OCI, DigitalOcean, and CIVO), builds a cloud asset inventory, and helps you break down your cost at the resource level.

> In the world of Komiser we have two universes, one pre-v3 and another one post-Komiser v3. This installation guide is applicable to any version v3.0.0 onwards. Komiser natively supports multiple cloud providers and cloud accounts using the config.toml file.

Authentication is done using the **config.toml** file. When the Komiser executable is run it will look for the file in the current directory, if you have the config file somewhere else then you can pass in the **\--config /path/to/config.toml** flag.

To find more in-depth installation guides and instructions check out the official Komiser documentation [here](https://docs.komiser.io/?utm_source=dev.to&utm_medium=social&utm_campaign=content).

#### Methods of deployment

-   Running Komiser locally
-   Running Komiser as a Docker container
-   Running Komiser on a Kubernetes cluster

#### Running Komiser locally

Links to download install commands are [here](https://docs.komiser.io/docs/overview/introduction/getting-started?utm_source=dev.to&utm_medium=social&utm_campaign=content).

![Komiser download links](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c16a0918127269b351e853_unified-download-links.png)

Alternatively, you can use [Homebrew](https://brew.sh/) by running:

![Homebrew install commands](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14b6aecd9a60298e72cb7_komiser-homebrew.png)

**Step 1:** Install Komiser using one of the commands above

**Step 2:** Create a config.toml file

**Step 3:** Choose your mode of persistence

**Step 4:** Run Komiser with the following command **komiser start**

**Step 5:** Access the dashboard from **localhost:3000**

> Remember if the **config.toml** file is in a different location to the directory you find yourself in you will have to use the **—config /path/to/file** flag

#### Running Komiser as a Docker container

_Prerequisites: Installed Docker Desktop_

Docker is a platform for developing, shipping, and running applications in containers. It allows developers to create and test applications in a consistent and reproducible environment, regardless of the underlying infrastructure. All dependencies are within the container making it self-sufficient. Komiser’s dependencies, mainly the configuration and credential files need to be mounted to the docker container as volumes.

To do so the -v flag in the docker run command is used to mount a volume for each file.

**Step 1:** Make sure the docker daemon is running in the background.

**Step 2:** Have your config.toml file and credential file (if applicable) ready.

**Step 3:** Edit the paths to the local path to your configuration files.

![docker run komiser command](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14976f95a0211cd61d070_docker-run-command.png)

**Step 4:** Run the [docker command](https://gist.github.com/jakepage91/8e4e35702cffb7c1ec34afa44f386581#file-komiser-docker-run)

**Step 5:** Access the dashboard from localhost:3000

**Here's a video tutorial on how to install Komiser using a Docker container:**

{% youtube 8IJMoH4PKe8 %}

#### Running Komiser in a Kubernetes cluster

_Prerequisites: Access to a Kubernetes cluster, kubectl installed, Helm installed_

The easiest way to deploy Komiser to a Kubernetes cluster is by using the official Komiser [Helm chart](https://github.com/tailwarden/helm). Which is going to give you the templates to create the requisite Kubernetes object that we are going to need to run the deployment successfully. This helm chart can be deployed to any Kubernetes cluster but the resources used in the steps below will reference Amazon EKS.

##### Steps to deploy:

-   Have **kubectl** access to a Kubernetes cluster with at least one working node.
-   Create an IAM role that has the recommended Komiser permissions policy attached to it. Instructions to create [IAM policy here](https://docs.komiser.io/docs/Cloud%20Providers/aws?utm_source=dev.to&utm_medium=social&utm_campaign=content#eks-installation-single-account). (AWS example)
-   Clone the [Helm chart](https://github.com/tailwarden/helm) repository
-   The Kubernetes objects provisioned by the helm chart are the following:
-   **ServiceAccount**
-   **ConfigMaps**
-   **Deployment**
-   **PersistentVolume**
-   **PersistentVolumeClaim**
-   **Service**

> The only changes you will have to make to the helm chart templates are to the ServiceAccount and to the config and credentials config maps. You might also want to customize the namespace you are deploying to. Default is testing-komiser

-   Create your **config.toml** file
-   Choose your mode of data persistence

![Amazon EKS diagram](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14bd79c9d3bde8b82024b_blog-post-installation-komiser.png)

Once you’ve added your credentials, updated the ServiceAccount role ARN, and chosen your data persistence mode you are ready to deploy.

![Helm install command](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14bf9abf90b91dfd4759c_helm-install-command.png)

**If you need any additional help follow along with me in the EKS installation video below:**

{% youtube 4veDmJpui44 %}

#### Integrations

As mentioned, Komiser depends on the **config.toml** to authenticate to your cloud accounts, let’s take a look at [an example](https://gist.github.com/jakepage91/10c6cfa0a748d6fd3bd07b90a3dbc3be):

![Example configuration file](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c1486497cde07b213202a0_config-toml-example-1.png)

In the [gist](https://gist.github.com/jakepage91/10c6cfa0a748d6fd3bd07b90a3dbc3be) above we can see that we are connecting two AWS accounts and we are using both of the authentication methods that are available to us.

#### Authentication Methods

**CREDENTIALS\_FILE**

We can use a credentials file similar to the one found in a local **.aws** folder. You will have to add a path to the credentials file relative to the **config.toml** file.

In the case of an AWS credentials file, it should look something like this:

![Example credentials file](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c148b2d4c21a194770cc42_credentials-file-example.png)

The name in brackets is the profile name and should be matched to the profile line in the **config.toml** file.

**ENVIRONMENT\_VARIABLES**

Selecting **ENVIRONMENT\_VARIABLES** as the source instructs Komiser to retrieve the necessary authentication credentials from the locally exported environment variables on the machine. If you are experiencing difficulties, ensure that your exported credentials are correct by using the echo command to check their values.

Example: **echo $AWS\_ACCESS\_KEY\_ID**

#### Modes of persistence

The configuration file allows you to include one of the data persistence methods. Persisting data is necessary to save and update custom views, decrease resource fetch time, and improve dashboard population after the initial deployment. The stored data can also be useful for local data exploration or building your own visualization dashboard with third-party tools (e.g: Grafana)

**SQLite**

Using the mode of persistence is likely the easiest method for saving your data. Simply choose where you want the .db file to be. It will be created at first launch, you don’t have to manually create the file.

In the screenshot above you can see the SQLite method being used.

**Postgres**

You can also run an external Postgres instance as a container (recommended) and attach it to Komiser.

Run a Postgres docker container with the following commands

![Postgres docker run command](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c148e2190cb7785eb4332c_docker-run-postgres.png)

Update the **config.toml** file to include the Postgres connection URI as seen below

![Postgres connection URI in configuration file](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14902ecd9a64113e4fc1c_postgres-uri.png)


#### Troubleshooting

**Komiser doesn’t have access to the config.toml file**

![Missing config file error](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14c9ed4c21aa18f73dabb_missing-config-file-error.png)

Komiser can’t find the configuration file, make sure the config.toml file is located in the same directory as the Komiser executable, if not that case, use the --config followed by the path to the configuration file.

**A mode of persistence is missing**

![Data persistence mode error](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14cbda36ab6626c6ac451_data-persistence-error.png)

Make sure that you have correctly added your persistence mode in the config.toml file.

**A port is already in use**

![Port binding in use error](https://uploads-ssl.webflow.com/6373a295d370a41a1a802e8c/63c14cd5640e32d58466886c_port-binding-error.png)

In this case, there is a live process currently bound to port 3000 you can inspect the live processes running and [unbind them from the port](https://www.tecmint.com/find-out-which-process-listening-on-a-particular-port/). Alternatively, you can run Komiser passing in the **\--port** flag and choose an available port binding.

**SCP in your account is restricting Komiser access**

We have seen instances of Komiser returning resource fetch issues when being deployed to an environment with SCPs in place that restricts the action certain entities can perform in an AWS organization. What we would recommend in this case would be to use the **—regions** flag to specify exactly which regions you would like to retrieve resources from. That way, you can make sure that you are only retrieving data from unrestricted regions.

> _Regardless if you are a Developer, DevOps, or Cloud engineer. Dealing with the cloud can be tough at times, especially on your own. If you are using Tailwarden or Komiser and want to share your thoughts doubts and insights with other cloud practitioners feel free to join our_ [Tailwarden Discord Server](https://discord.tailwarden.com/)_. Where you will find tips, community calls, and much more._