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
How to set up and validate locally
- In your GDK directory run
If it's not yet enabled in
gdk config set gitlab_k8s_agent.enabled true gdk reconfiguregdk.yml - Edit
gitlab-k8s-agent-config.ymlfile and addevents_platform: {}at the end. - Run
gdk restart - 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. - Start Relay Playground TUI.
- In the TUI, hit
ctrl+pto open settings. Set the Subscribe/Watch topic totest.publish. - Make sure the Subscribe and Watch panes are visible (toggle via the commands menu if not).
- Hit
ctrl+lto start the subscribe stream. - In the 1st terminal window, from
railsdirectory, rungdk rails c. - Enable feature flag
Feature.enable(:publish_events_to_relay) - 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
