Skip to content

Commit

Permalink
Add SchemaRegistry with RestProxy API (#1372)
Browse files Browse the repository at this point in the history
* Add SchemaRegistry with RestProxy API

Signed-off-by: obaydullahmhs <[email protected]>

* Update apis

Signed-off-by: obaydullahmhs <[email protected]>

---------

Signed-off-by: obaydullahmhs <[email protected]>
  • Loading branch information
obaydullahmhs authored Jan 17, 2025
1 parent bdae9dd commit a790052
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 1 deletion.
29 changes: 28 additions & 1 deletion apis/kafka/v1alpha1/openapi_generated.go

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

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

// SchemaRegistryRef provides a reference to the Schema Registry configuration.
// the REST Proxy will connect to the Schema Registry if SchemaRegistryRef is provided.
// +optional
SchemaRegistryRef *SchemaRegistryRef `json:"schemaRegistryRef,omitempty"`

// ServiceTemplates is an optional configuration for services used to expose database
// +optional
ServiceTemplates []dbapi.NamedServiceTemplateSpec `json:"serviceTemplates,omitempty"`
Expand All @@ -84,6 +89,19 @@ type RestProxySpec struct {
HealthChecker kmapi.HealthCheckSpec `json:"healthChecker"`
}

// SchemaRegistryRef provides a reference to the Schema Registry configuration.
type SchemaRegistryRef struct {
// Name and namespace of appbinding of schema registry
// If this is provided, the REST Proxy will connect to the Schema Registry
// InternallyManaged must be set to false in this case
// +optional
*kmapi.ObjectReference `json:",omitempty"`

// InternallyManaged true specifies if the schema registry runs internally along with the rest proxy
// +optional
InternallyManaged bool `json:"internallyManaged,omitempty"`
}

// RestProxyStatus defines the observed state of RestProxy
type RestProxyStatus struct {
// Specifies the current phase of the database
Expand Down
13 changes: 13 additions & 0 deletions apis/kafka/v1alpha1/restproxy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ func (k *RestProxy) ValidateCreateOrUpdate() field.ErrorList {
return allErr
}

if k.Spec.SchemaRegistryRef != nil {
if k.Spec.SchemaRegistryRef.InternallyManaged && k.Spec.SchemaRegistryRef.ObjectReference != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("schemaRegistryRef").Child("objectReference"),
k.Name,
"ObjectReference should be nil when InternallyManaged is true"))
}
if !k.Spec.SchemaRegistryRef.InternallyManaged && k.Spec.SchemaRegistryRef.ObjectReference == nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("schemaRegistryRef").Child("objectReference"),
k.Name,
"ObjectReference should not be nil when InternallyManaged is false"))
}
}

if k.Spec.DeletionPolicy == dbapi.DeletionPolicyHalt {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("deletionPolicy"),
k.Name,
Expand Down
26 changes: 26 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 @@ -3152,6 +3152,17 @@ spec:
replicas:
format: int32
type: integer
schemaRegistryRef:
properties:
internallyManaged:
type: boolean
name:
type: string
namespace:
type: string
required:
- name
type: object
serviceTemplates:
items:
properties:
Expand Down

0 comments on commit a790052

Please sign in to comment.