Skip to content

Commit

Permalink
DBZ-8234 Configurable API service port
Browse files Browse the repository at this point in the history
  • Loading branch information
jcechace committed Nov 8, 2024
1 parent bf76204 commit bd4ec61
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package io.debezium.operator.api.model.runtime;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

Expand All @@ -21,6 +22,10 @@ public class RuntimeApi implements ConfigMappable {
@JsonPropertyDescription("Whether the API should be enabled for this instance of Debezium Server")
private boolean enabled = false;

@JsonProperty(defaultValue = "8080")
@JsonPropertyDescription("Port number used by the k8s service exposing the API")
private int port = 8080;

public boolean isEnabled() {
return enabled;
}
Expand All @@ -29,6 +34,14 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public int getPort() {
return port;
}

public void setPort(int port) {
this.port = port;
}

@Override
public ConfigMapping asConfiguration() {
return ConfigMapping.empty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public class ApiServiceDependent extends CRUDKubernetesDependentResource<Service, DebeziumServer> {

public static final String CLASSIFIER = "api";
public static final int API_PORT = DeploymentDependent.DEFAULT_HTTP_PORT;

public ApiServiceDependent() {
super(Service.class);
Expand All @@ -31,6 +30,7 @@ public ApiServiceDependent() {
@Override
protected Service desired(DebeziumServer primary, Context<DebeziumServer> context) {
var name = primary.getMetadata().getName();
var apiConfig = primary.getSpec().getRuntime().getApi();

var labels = CommonLabels.serverComponent(name)
.withDbzClassifier(CLASSIFIER)
Expand All @@ -50,7 +50,7 @@ protected Service desired(DebeziumServer primary, Context<DebeziumServer> contex
.withName("http")
.withProtocol("TCP")
.withTargetPort(new IntOrString(DeploymentDependent.DEFAULT_HTTP_PORT))
.withPort(API_PORT)
.withPort(apiConfig.getPort())
.build())
.build())
.build();
Expand Down
1 change: 1 addition & 0 deletions docs/reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ Used in: <<debezium-operator-schema-reference-runtime, `+Runtime+`>>
|===
| Property | Type | Default | Description
| [[debezium-operator-schema-reference-runtimeapi-enabled]]<<debezium-operator-schema-reference-runtimeapi-enabled, `+enabled+`>> | boolean | | Whether the API should be enabled for this instance of Debezium Server
| [[debezium-operator-schema-reference-runtimeapi-port]]<<debezium-operator-schema-reference-runtimeapi-port, `+port+`>> | int | 8080 | Port number used by the k8s service exposing the API
|===

[#debezium-operator-schema-reference-runtimeenvironment]
Expand Down
4 changes: 4 additions & 0 deletions k8/debeziumservers.debezium.io-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ spec:
description: Whether the API should be enabled for this instance
of Debezium Server
type: boolean
port:
description: Port number used by the k8s service exposing
the API
type: integer
type: object
environment:
description: Additional environment variables used by this Debezium
Expand Down

0 comments on commit bd4ec61

Please sign in to comment.