Skip to content

Commit

Permalink
Add SchemaRegistry with RestProxy API
Browse files Browse the repository at this point in the history
Signed-off-by: obaydullahmhs <[email protected]>
  • Loading branch information
obaydullahmhs committed Dec 23, 2024
1 parent 34e3d3f commit c0b5361
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apis/kafka/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions apis/kafka/v1alpha1/restproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ type RestProxySpec struct {
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`

// EnableSchemaRegistry indicates whether the REST Proxy should connect to a Schema Registry.
// If set to true, the REST Proxy will establish a connection to the Schema Registry before communicating with Kafka.
// This is necessary when producing or consuming messages that use Avro or other schema-based formats.
// +optional
EnableSchemaRegistry bool `json:"enableSchemaRegistry,omitempty"`

// SchemaRegistryRef provides a reference to the Schema Registry configuration.
// If EnableSchemaRegistry and SchemaRegistryRef are both set, the REST Proxy will connect to the external Schema Registry.
// Otherwise, the REST Proxy will use the internal Schema Registry.
// +optional
SchemaRegistryRef *kmapi.ObjectReference `json:"schemaRegistryRef,omitempty"`

// ServiceTemplates is an optional configuration for services used to expose database
// +optional
ServiceTemplates []dbapi.NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"`
Expand Down
8 changes: 8 additions & 0 deletions apis/kafka/v1alpha1/restproxy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ func (k *RestProxy) ValidateCreateOrUpdate() field.ErrorList {
return allErr
}

if !k.Spec.EnableSchemaRegistry {
if k.Spec.SchemaRegistryRef != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSchemaRegistry"),
k.Name,
"SchemaRegistryRef can only be set when EnableSchemaRegistry is true"))
}
}

if k.Spec.DeletionPolicy == dbapi.DeletionPolicyHalt {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deletionPolicy"),
k.Name,
Expand Down
5 changes: 5 additions & 0 deletions apis/kafka/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions crds/kafka.kubedb.com_restproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ spec:
- WipeOut
- DoNotTerminate
type: string
enableSchemaRegistry:
type: boolean
healthChecker:
default:
failureThreshold: 3
Expand Down Expand Up @@ -3152,6 +3154,15 @@ spec:
replicas:
format: int32
type: integer
schemaRegistryRef:
properties:
name:
type: string
namespace:
type: string
required:
- name
type: object
serviceTemplates:
items:
properties:
Expand Down

0 comments on commit c0b5361

Please sign in to comment.