Skip to content

feat(operator): initial operator implementation (no deploy)#339

Merged
bmcquilkin-sentry merged 3 commits into
mainfrom
bmcquilkin/operator/v1
Jul 16, 2026
Merged

feat(operator): initial operator implementation (no deploy)#339
bmcquilkin-sentry merged 3 commits into
mainfrom
bmcquilkin/operator/v1

Conversation

@bmcquilkin-sentry

@bmcquilkin-sentry bmcquilkin-sentry commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Phase 1 of creating a k8s operator to the streams repository to manage Kafka consumer pod lifecycles. Creates the StreamingConsumer CRD and a basic operator that reconciles resources into a Deployment and ConfigMap. Splits shared logic from that and the PipelineStep macro into consumer builder methods.

@bmcquilkin-sentry
bmcquilkin-sentry requested a review from a team as a code owner July 1, 2026 00:19
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py Outdated
metadata:
name: streams-k8s-operator
rules:
- apiGroups: ["streams.sentry.io"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems specific to Sentry. Is that okay even though streams itself is open source?

Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
@fpacifici

Copy link
Copy Markdown
Collaborator

Please provide a description for the PR with context.

@fpacifici

Copy link
Copy Markdown
Collaborator

Also please update this file https://github.com/getsentry/streams/tree/main/sentry_streams_k8s#readme
If you add the operator there, the readme is not accurate anymore.

@fpacifici fpacifici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several high level changes:

  • Let's break down this PR. I would recommend Putting together the CRD and an empty operator here. So the key of this PR is the CRD and we can iterate on that.
  • Break down the macro to extract the business logic so you can use it from the operator as well. See my comments on the dependencies
  • Then we can start fill in the business logic in the operator

Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/manifests/crd.yaml
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/manifests/crd.yaml Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/manifests/crd.yaml Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/operator.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/operator/streaming_consumer.py Outdated
Comment thread sentry_streams_k8s/sentry_streams_k8s/consumer_builder.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit cbecfc3. Configure here.

Comment thread sentry_streams_k8s/pyproject.toml
@bmcquilkin-sentry
bmcquilkin-sentry force-pushed the bmcquilkin/operator/v1 branch from cbecfc3 to ed2e029 Compare July 2, 2026 21:34
@bmcquilkin-sentry
bmcquilkin-sentry changed the base branch from main to bmcquilkin/operator/split July 2, 2026 21:34
@linear-code

linear-code Bot commented Jul 7, 2026

Copy link
Copy Markdown

STREAM-1246

Add a Kopf-based operator that reconciles StreamingConsumer CRs into
Deployments, using the shared consumer_builder logic.
@bmcquilkin-sentry
bmcquilkin-sentry changed the base branch from bmcquilkin/operator/split to main July 10, 2026 21:05

@fpacifici fpacifici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last clarification.
What is the scenario where we would prune deployments ?

Comment thread sentry_streams_k8s/pyproject.toml
Comment on lines +94 to +100
_prune_stale_deployments(
namespace=namespace,
owner_uid=uid,
service_name=consumer["service_name"],
pipeline_name=consumer["pipeline_name"],
desired_names={m["metadata"]["name"] for m in manifests if m["kind"] == "Deployment"},
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I understand this.
Could you give me an example about when we would remove a deployment here ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing with_canary from true to false would need this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not sure if we would ever do this but in the case where we delete a CR we would need it.

@fpacifici fpacifici left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the unit test are validating rendering.
Do we have a way to test the behavior of the operator ? I think you should at least unit test the "reconcile" function against a mock of the Kubernetes api before merging.

@bmcquilkin-sentry
bmcquilkin-sentry merged commit 4e1a8eb into main Jul 16, 2026
26 checks passed
@bmcquilkin-sentry
bmcquilkin-sentry deleted the bmcquilkin/operator/v1 branch July 16, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants