Add publish_events to Gitlab::Kas::Client for events platform

What does this MR do and why?

Adds Gitlab::Kas::Client#publish_events to support publishing CloudEvents to the events_platform service on GitLab Relay (KAS).

References

Related to #594102 (closed)

Roll out issue #601527

Screenshots or screen recordings

Screenshot_2026-05-28_at_15.00.02

How to set up and validate locally

  1. In your GDK directory run
    gdk config set gitlab_k8s_agent.enabled true
    gdk reconfigure
    If it's not yet enabled in gdk.yml
  2. Edit gitlab-k8s-agent-config.yml file and add events_platform: {} at the end.
  3. Run gdk restart
  4. The simplest way to check whether events received is to use relay-playground. Follow "Quick start" steps to configure. Use 2nd terminal window for that.
  5. Start Relay Playground TUI.
  6. In the TUI, hit ctrl+p to open settings. Set the Subscribe/Watch topic to test.publish.
  7. Make sure the Subscribe and Watch panes are visible (toggle via the commands menu if not).
  8. Hit ctrl+l to start the subscribe stream.
  9. In the 1st terminal window, from rails directory, run gdk rails c.
  10. Enable feature flag Feature.enable(:publish_events_to_relay)
  11. Create and publish an event
    event = Gitlab::Agent::Event::CloudEvent.new(
      id: SecureRandom.uuid,
      source: 'rails-test',
      spec_version: '1.0',
      type: 'com.example.test',
      text_data: { hello: 'world' }.to_json
    )
    
    Gitlab::Kas::Client.new.publish_events(topic: 'test.publish', events: event)

The command should return event ID => ["1747840000-0"] (actual ID will differ). Relay playground should display received events.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Vitali Tatarintev

Merge request reports

Loading