-
Notifications
You must be signed in to change notification settings - Fork 122
feat: add redpanda buffering layer with split ingress/egress otel collectors #7275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,198 @@ | ||
| import * as k8s from '@pulumi/kubernetes'; | ||
| import * as pulumi from '@pulumi/pulumi'; | ||
|
|
||
| export type Redpanda = ReturnType<typeof deployRedpanda>; | ||
|
|
||
| export function deployRedpanda() { | ||
| const redpandaConfig = new pulumi.Config('redpanda'); | ||
| const replicas = redpandaConfig.getNumber('replicas') || 3; | ||
| const storageSize = redpandaConfig.get('storageSize') || '20Gi'; | ||
| const memoryLimit = redpandaConfig.get('memoryLimit') || '1Gi'; | ||
| const cpuLimit = redpandaConfig.get('cpuLimit') || '1000m'; | ||
|
|
||
| const labels = { app: 'redpanda' }; | ||
|
|
||
| // StatefulSet for Redpanda | ||
| const statefulSet = new k8s.apps.v1.StatefulSet('redpanda', { | ||
| metadata: { | ||
| name: 'redpanda', | ||
| }, | ||
| spec: { | ||
| serviceName: 'redpanda', | ||
| replicas, | ||
| selector: { | ||
| matchLabels: labels, | ||
| }, | ||
| template: { | ||
| metadata: { | ||
| labels, | ||
| }, | ||
| spec: { | ||
| containers: [ | ||
| { | ||
| name: 'redpanda', | ||
| image: 'redpandadata/redpanda:v25.3.1', | ||
| imagePullPolicy: 'Always', | ||
| resources: { | ||
| limits: { | ||
| cpu: cpuLimit, | ||
| memory: memoryLimit, | ||
| }, | ||
| }, | ||
| args: [ | ||
| 'redpanda', | ||
| 'start', | ||
| '--overprovisioned', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
https://docs.redpanda.com/current/reference/rpk/rpk-redpanda/rpk-redpanda-mode/#production-mode We want to make sure this is disabled in production |
||
| '--smp', | ||
| '1', | ||
| '--memory', | ||
| memoryLimit, | ||
| '--kafka-addr', | ||
| 'PLAINTEXT://0.0.0.0:9092', | ||
| '--advertise-kafka-addr', | ||
| pulumi.interpolate`PLAINTEXT://\${HOSTNAME}.redpanda.default.svc.cluster.local:9092`, | ||
| ], | ||
| ports: [ | ||
| { containerPort: 9092, name: 'kafka' }, | ||
| { containerPort: 8082, name: 'http' }, | ||
| { containerPort: 33145, name: 'rpc' }, | ||
| { containerPort: 9644, name: 'admin' }, | ||
| ], | ||
| volumeMounts: [ | ||
| { | ||
| name: 'datadir', | ||
| mountPath: '/var/lib/redpanda/data', | ||
| }, | ||
| ], | ||
| livenessProbe: { | ||
| httpGet: { | ||
| path: '/v1/status/ready', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for most of our services we use |
||
| port: 9644 as any, | ||
| }, | ||
| initialDelaySeconds: 30, | ||
| periodSeconds: 10, | ||
| }, | ||
| readinessProbe: { | ||
| httpGet: { | ||
| path: '/v1/status/ready', | ||
| port: 9644 as any, | ||
| }, | ||
| initialDelaySeconds: 10, | ||
| periodSeconds: 5, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| volumeClaimTemplates: [ | ||
| { | ||
| metadata: { | ||
| name: 'datadir', | ||
| }, | ||
| spec: { | ||
| accessModes: ['ReadWriteOnce'], | ||
| resources: { | ||
| requests: { | ||
| storage: storageSize, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| // Headless Service for StatefulSet (used for internal cluster communication) | ||
| const headlessService = new k8s.core.v1.Service('redpanda-headless', { | ||
| metadata: { | ||
| name: 'redpanda', | ||
| }, | ||
| spec: { | ||
| clusterIP: 'None', | ||
| selector: labels, | ||
| ports: [ | ||
| { name: 'kafka', port: 9092, targetPort: 9092 as any }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we need the any casts ? |
||
| { name: 'http', port: 8082, targetPort: 8082 as any }, | ||
| { name: 'rpc', port: 33145, targetPort: 33145 as any }, | ||
| { name: 'admin', port: 9644, targetPort: 9644 as any }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| // ClusterIP Service for clients (load balances across all pods) | ||
| const clientService = new k8s.core.v1.Service('redpanda-client-service', { | ||
| metadata: { | ||
| name: 'redpanda-client', | ||
| }, | ||
| spec: { | ||
| type: 'ClusterIP', | ||
| selector: labels, | ||
| ports: [ | ||
| { name: 'kafka', port: 9092, targetPort: 9092 as any }, | ||
| { name: 'http', port: 8082, targetPort: 8082 as any }, | ||
| ], | ||
| }, | ||
| }); | ||
|
|
||
| // Create otel-traces topic | ||
| const topicCreationJob = new k8s.batch.v1.Job( | ||
| 'redpanda-topic-creation', | ||
| { | ||
| metadata: { | ||
| name: 'redpanda-topic-creation', | ||
| }, | ||
| spec: { | ||
| template: { | ||
| spec: { | ||
| restartPolicy: 'OnFailure', | ||
| containers: [ | ||
| { | ||
| name: 'rpk', | ||
| image: 'redpandadata/redpanda:v25.3.1', | ||
| imagePullPolicy: 'Always', | ||
| command: [ | ||
| '/bin/bash', | ||
| '-c', | ||
| ` | ||
| # Wait for Redpanda to be ready | ||
| for i in {1..60}; do | ||
| if rpk cluster health --brokers redpanda-0.redpanda:9092 2>/dev/null | grep -q 'Healthy'; then | ||
| echo "Redpanda cluster is ready" | ||
| break | ||
| fi | ||
| echo "Waiting for Redpanda cluster... ($i/60)" | ||
| sleep 5 | ||
| done | ||
| # Create topic with partitioning only (no replication) | ||
| rpk topic create otel-traces \\ | ||
| --brokers redpanda-0.redpanda:9092 \\ | ||
| --replicas 1 \\ | ||
| --partitions 10 \\ | ||
| --config retention.ms=2592000000 \\ | ||
| --config compression.type=snappy \\ | ||
| --config max.message.bytes=10485760 \\ | ||
| || echo "Topic may already exist" | ||
| # Verify topic creation | ||
| rpk topic describe otel-traces --brokers redpanda-0.redpanda:9092 | ||
| `, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| { dependsOn: [statefulSet, headlessService] }, | ||
| ); | ||
|
|
||
| return { | ||
| statefulSet, | ||
| headlessService, | ||
| clientService, | ||
| topicCreationJob, | ||
| // Client service endpoint - auto-discovers all brokers | ||
| brokerEndpoint: 'redpanda-client:9092', | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| dist: | ||
| version: 0.122.0 | ||
| name: otelcol-custom | ||
| description: Custom OTel Collector distribution | ||
| output_path: ./otelcol-custom | ||
|
|
||
| receivers: | ||
| - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/kafkareceiver v0.122.0 | ||
|
|
||
| processors: | ||
| - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.122.0 | ||
|
|
||
| exporters: | ||
| - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.122.0 | ||
| - gomod: | ||
| github.com/open-telemetry/opentelemetry-collector-contrib/exporter/clickhouseexporter v0.122.0 | ||
|
|
||
| extensions: | ||
| - gomod: | ||
| github.com/open-telemetry/opentelemetry-collector-contrib/extension/healthcheckextension | ||
| v0.122.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we keep this configurable by env?