---
title: "The 2024 edition of How I deploy my Telegram bot"
description: "Using semantic release, Docker and k3s to deploy my Python Telegram bot."
datePublished: 2024-05-23T14:30:00.000Z
slug: "deploying-ssgbot-2024"
previewImage: "/preview/deploying-python-telegram-bot.jpg"
permalink: "https://obviy.us/blog/deploying-ssgbot-2024/"
---

  

It has been a good 600 days since I [last wrote](https://obviy.us/blog/deploying-my-python-telegram-bot/) about deploying

[`@SuperSeriousBot`](https://github.com/obviyus/SuperSeriousBot)

. There are now about 8,000 users.

Not a lot has changed since the last update regarding comittting the code and building it. I still use [`semantic-release`](https://github.com/semantic-release/semantic-release) to manage releases and Docker to build the project. However, I have migrated away from Nomad to `k3s` for deployment.

## Building

-   I now use my own [self-hosted ARM runner](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners) for GitHub actions. I can now finally build the `arm64` Docker image in a reasonable amount of time!
-   Like before, GitHub Actions then publish the Docker images to [ghcr.io](https://ghcr.io/) with the `:latest` tag

## Deploying

I now use [k3s](https://k3s.io/) to deploy `@SuperSeriousBot`. It’s a stripped down Kubernetes distribution that runs off of a single binary. I liked it enough to migrate most of my projects off of `systemd` and Nomad to `k3s` (I blame [Katia](https://github.com/iakat)). If you’re curious you can check out my [k3s setup](https://github.com/obviyus/k3s).

The manifest for @SuperSeriousBot can be found [here](https://github.com/obviyus/k3s/blob/master/superseriousbot/base/superseriousbot.yaml).

What I like about `k3s`:

-   Setting it up was a breeze. It’s a single binary that you can run with a few flags
-   `kubeseal` lets me commit secrets to the repository in an encrypted format. This is probably my favourite feature:

```bash
$ kubeseal --format=yaml < unsealed-secrets/superseriousbot.yaml > superseriousbot/base/secrets.yaml
```

-   `kubernetes-dashboard` is awesome
-   Full compatibility with `kubectl` lets me use tools like `k9s` and `kubectx`
-   BIG fan of automatic TLS with `cert-manager` and `nginx-ingress`:

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: superseriousbot
  annotations:
    nginx.ingress.kubernetes.io/proxy-read-timeout: "300"
    nginx.ingress.kubernetes.io/proxy-send-timeout: "300"
    kubernetes.io/ingress.class: nginx
    cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
  rules:
    - host: superseriousbot.superserio.us
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: superseriousbot
                port:
                  number: 4242
  tls:
    - hosts:
        - superseriousbot.superserio.us
      secretName: superseriousbot-tls
```

…plus a few more goodies that I might put in a separate post.

What I miss from Nomad:

-   Integrated templating with `consul-template` (but you need to install `consul`)
-   HCL >>> YAML
-   Ability to schedule non-Docker workloads

But all in all, I think I’m leaning a bit more towards `k3s` for now. Not enough to start a migration at work though ;)

## Conclusion

Lately I’ve been tinkering more with deploying the bot rather than the bot itself. I need to trim the fat, remove unused commands, rip out some dependencies and profile the random delays that have been creeping in. But that’s a story for another day.

## Wishlist

-    Use Litestream / Turso for backups
    
    I actually lost a few days of data due to accidentally deleting the `pvc` that stored the SQLite database.
    
-    Python 3.12
    
-    A feature that uses Telegram’s [Web Apps](https://core.telegram.org/bots/webapps)
