The Simplest Way to Make Gitea and Kafka Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You link gitea and kafka to stream code events into your event queues. A Gitea webhook sends push and pull request data to an HTTP endpoint. That receiver checks the payload and writes a message to a Kafka topic. Downstream apps then read that topic to trigger builds, tests, or alerts. This setup decouples your source code server from your background workers. If a build worker goes down, Kafka holds the event until it recovers. Your developers can keep pushing code without waiting on slow downs

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You link gitea and kafka to stream code events into your event queues. A Gitea webhook sends push and pull request data to an HTTP endpoint.

That receiver checks the payload and writes a message to a Kafka topic. Downstream apps then read that topic to trigger builds, tests, or alerts. This setup decouples your source code server from your background workers. If a build worker goes down, Kafka holds the event until it recovers. Your developers can keep pushing code without waiting on slow downstream jobs.

How data and keys flow between gitea and kafka

Gitea does not speak the native binary protocol that Kafka uses. Instead, Gitea sends JSON payloads over HTTP whenever a repo event happens. You must run a small web app or connector between the two tools. This middle service listens for Gitea webhooks and writes records to Kafka.

Security starts with how Gitea talks to this receiver app. You set up a shared secret key inside your Gitea repo settings. Gitea uses this key to sign every webhook request it sends out. The receiver app checks this signature before it accepts the JSON payload. If the signature fails the check, the app drops the request right away.

Next, the receiver app must log in to your Kafka cluster. You give the receiver its own client key or certificate for Kafka. You also set up Kafka access rules for that specific client identity. The receiver should only have write permissions for the exact topics it needs. It never needs permission to read topics or change cluster settings. Downstream workers use their own separate keys to read from those topics.

Common failure modes and how to scope roles

Teams often make mistakes when they rush this setup in production. The biggest mistake is using one shared admin account for all Kafka clients. If an attacker steals that broad key, they can read or delete every topic. You can fix this by creating one service account per app. Give the Gitea receiver write-only rights on a single repo events topic.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Another common failure mode is skipping webhook signature checks on the receiver. Without this check, anyone on the network can send fake build events. Always check the request header signature against your stored secret key. You should also rotate these secret keys on a regular schedule.

Network paths and payload contents also cause headaches for operations teams. Do not expose your Kafka nodes or the receiver to the public internet. Keep both systems inside a private network segment with strict firewall rules. Also, remember that git commit messages sometimes contain sensitive data by mistake. Developers might type emails, phone numbers, card numbers, or national IDs in notes. Your receiver or stream processor can run a masking step before writing data. Masking rewrites matched fields in results so sensitive strings do not spread. Finally, log every webhook receipt and Kafka write error with a request ID. Good logs help your team trace dropped events when a build fails to start.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can Gitea publish events directly to a Kafka topic?

No, Gitea only sends events out as HTTP webhooks. You need a tiny web service or an HTTP source connector in the middle. That service accepts the HTTP post and writes the message to Kafka.

What happens if the Kafka cluster is down when someone pushes code?

The receiver app will fail to write the message and return an error. Gitea records this failed webhook delivery in its repo settings page. You can replay failed webhook events from Gitea once Kafka is back up.

How should we map Gitea repos to Kafka topics?

Most teams send all repo events to one or two shared topics. They use the repo name as the message key to keep events in order. This setup is much easier to manage than making hundreds of tiny topics.

The query runs. The emails stay hidden.