Setting up k9s skins for different Kubernetes clusters
Tags: kubernetes, tooling, tutorial
Published: 2023-04-01 07:18:07

This post is going to show you how to define different skins for [k9s](https://k9scli.io), so you can quickly see which environment you're working on.

`k9s` is a terminal application that allows you to manage your [Kubernetes](https://kubernetes.io) clusters. So if you're managing your production cluster, for example, you probably want to take extra care of what you're doing.

Every time I jump onto a production database for nearly two decades, I have set the background to red. Over the years better tooling has come out, so I now have iTerm profiles that allow me to quickly change the colour of the background when in different environments. Recently I was doing a bit of work on a Kubernetes platform using `k9s` and was doing the same thing, setting my iTerm profile. Then I checked on the `k9s` docs and realised you can do this within `k9s`. More importantly, it would be automatic **based on your cluster name**, which sounds even better.

So, I've set up the following skins:

- A standard skin
- A testing skin
- A production skin

You can check out the [official skins on GitHub](https://github.com/derailed/k9s/tree/master/skins). I've based my skins on `monokai.yml`.

Once you have picked your base skin, save it to this path:

```shell
~/Library/Application\ Support/k9s/skin.yml
```

When you now fire up `k9s`, you should have the skin you have picked. This is what mine looks like as standard.

![k9s standard monokai skin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1r10cwcam64l4fwkqx88.png)

Now we want to move on to the good stuff and have different skins for different clusters. Well luckily, [k9s supports this](https://k9scli.io/topics/skins/). It's about naming the skin after the cluster name. So, I have a cluster called `prod`, therefore I've created a file called:

```shell
~/Library/Application\ Support/k9s/prod_skin.yml
```

The theme is still the base `monokai.yml` skin, but I changed the `background` value to:

```yaml
background: &background '#41000c'
```

So now, when I connect to the `prod` cluster using `k9s`, my experience looks like this:

![k9s production monokai skin with red background](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yhzqtnj0mlilygzrg7kx.png)

I've also gotten into the habit of having a specific colour for testing environments. So basically only my local development environment looks "normal". Everything else has a colour that can imply how worried I should be about making changes. My testing skin has a dark purple background.

![k9s testing monokai skin with purple background](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fd40kam6tr43sf4he47p.png)

All of these skins are defined in my [dotfiles repo](https://github.com/benmatselby/dotfiles/tree/main/k9s) and you can see I [symlink](https://github.com/benmatselby/dotfiles/blob/main/k9s/install.sh) the skins, so I can easily track changes in git.

Hopefully, you found this useful.


---

Photo by <a href="https://unsplash.com/@ventiviews?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Venti Views</a> on <a href="https://unsplash.com/photos/1cqIcrWFQBI?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>