Skip to content
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

Add support for scale subresource to Connect, S2I, MM1, MM2, Bridge and Connectors #3165

Merged
merged 16 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .azure/templates/default_variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ variables:
branch: $(Build.SourceBranchName)
commit_message: $(Build.SourceVersionMessage)
test_cluster: minikube
test_kubectl_version: v1.15.0
test_kubectl_version: v1.16.0
test_nsenter_version: 2.32
test_helm_version: v2.16.3
test_minikube_version: v1.2.0
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:
- DOCKER_ORG=strimzici
- DOCKER_REGISTRY=docker.io
- TEST_CLUSTER=minikube
- TEST_KUBECTL_VERSION=v1.15.0
- TEST_KUBECTL_VERSION=v1.16.0
- TEST_NSENTER_VERSION=2.32
- TEST_HELM_VERSION=v2.16.3
- TEST_MINIKUBE_VERSION=v1.2.0
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@

## 0.19.0

* Add support for scale subresource to make scaling of following resources easier:
* KafkaConnect
* KafkaConnectS2I
* KafkaBridge
* KafkaMirrorMaker
* KafkaMirrorMaker2
* KafkaConnector
* Remove deprecated `Kafka.spec.topicOperator` classes and deployment logic
* Use Java 11 as the Java runtime

Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/io/strimzi/api/kafka/model/Kafka.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@Crd.Spec.Version(name = Kafka.V1ALPHA1, served = true, storage = false)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status()
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down
10 changes: 9 additions & 1 deletion api/src/main/java/io/strimzi/api/kafka/model/KafkaBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaBridge.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaBridge.STATUS_REPLICAS_PATH,
labelSelectorPath = KafkaBridge.LABEL_SELECTOR_PATH
)
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down Expand Up @@ -95,6 +100,9 @@ public class KafkaBridge extends CustomResource implements UnknownPropertyPreser
public static final String CRD_NAME = RESOURCE_PLURAL + "." + RESOURCE_GROUP;
public static final String SHORT_NAME = "kb";
public static final List<String> RESOURCE_SHORTNAMES = singletonList(SHORT_NAME);
public static final String SPEC_REPLICAS_PATH = ".spec.replicas";
public static final String STATUS_REPLICAS_PATH = ".status.replicas";
public static final String LABEL_SELECTOR_PATH = ".status.selector";

private String apiVersion;
private ObjectMeta metadata;
Expand Down
10 changes: 9 additions & 1 deletion api/src/main/java/io/strimzi/api/kafka/model/KafkaConnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaConnect.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaConnect.STATUS_REPLICAS_PATH,
labelSelectorPath = KafkaConnect.LABEL_SELECTOR_PATH
)
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down Expand Up @@ -93,6 +98,9 @@ public class KafkaConnect extends CustomResource implements UnknownPropertyPrese
public static final String CRD_NAME = RESOURCE_PLURAL + "." + RESOURCE_GROUP;
public static final String SHORT_NAME = "kc";
public static final List<String> RESOURCE_SHORTNAMES = singletonList(SHORT_NAME);
public static final String SPEC_REPLICAS_PATH = ".spec.replicas";
public static final String STATUS_REPLICAS_PATH = ".status.replicas";
public static final String LABEL_SELECTOR_PATH = ".status.selector";

private String apiVersion;
private KafkaConnectSpec spec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@
)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaConnectS2I.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaConnectS2I.STATUS_REPLICAS_PATH,
labelSelectorPath = KafkaConnectS2I.LABEL_SELECTOR_PATH
)
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down Expand Up @@ -96,6 +101,9 @@ public class KafkaConnectS2I extends CustomResource implements UnknownPropertyPr
public static final String CRD_NAME = RESOURCE_PLURAL + "." + RESOURCE_GROUP;
public static final String SHORT_NAME = "kcs2i";
public static final List<String> RESOURCE_SHORTNAMES = singletonList(SHORT_NAME);
public static final String SPEC_REPLICAS_PATH = ".spec.replicas";
public static final String STATUS_REPLICAS_PATH = ".status.replicas";
public static final String LABEL_SELECTOR_PATH = ".status.selector";

private String apiVersion;
private ObjectMeta metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
storage = true)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaConnector.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaConnector.STATUS_REPLICAS_PATH
)
)
)
)
Expand All @@ -71,6 +75,8 @@ public class KafkaConnector extends CustomResource implements UnknownPropertyPre
public static final String RESOURCE_KIND = "KafkaConnector";
public static final String RESOURCE_LIST_KIND = RESOURCE_KIND + "List";
public static final String SHORT_NAME = "kctr";
public static final String SPEC_REPLICAS_PATH = ".spec.tasksMax";
public static final String STATUS_REPLICAS_PATH = ".status.tasksMax";

private KafkaConnectorSpec spec;
private KafkaConnectorStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaMirrorMaker.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaMirrorMaker.STATUS_REPLICAS_PATH,
labelSelectorPath = KafkaMirrorMaker.LABEL_SELECTOR_PATH
)
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down Expand Up @@ -108,6 +113,9 @@ public class KafkaMirrorMaker extends CustomResource implements UnknownPropertyP
public static final String CRD_NAME = RESOURCE_PLURAL + "." + RESOURCE_GROUP;
public static final String SHORT_NAME = "kmm";
public static final List<String> RESOURCE_SHORTNAMES = singletonList(SHORT_NAME);
public static final String SPEC_REPLICAS_PATH = ".spec.replicas";
public static final String STATUS_REPLICAS_PATH = ".status.replicas";
public static final String LABEL_SELECTOR_PATH = ".status.selector";

private String apiVersion;
private ObjectMeta metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@
)
},
subresources = @Crd.Spec.Subresources(
status = @Crd.Spec.Subresources.Status()
status = @Crd.Spec.Subresources.Status(),
scale = @Crd.Spec.Subresources.Scale(
specReplicasPath = KafkaMirrorMaker2.SPEC_REPLICAS_PATH,
statusReplicasPath = KafkaMirrorMaker2.STATUS_REPLICAS_PATH,
labelSelectorPath = KafkaMirrorMaker2.LABEL_SELECTOR_PATH
)
),
additionalPrinterColumns = {
@Crd.Spec.AdditionalPrinterColumn(
Expand Down Expand Up @@ -87,6 +92,9 @@ public class KafkaMirrorMaker2 extends CustomResource implements UnknownProperty
public static final String CRD_NAME = RESOURCE_PLURAL + "." + RESOURCE_GROUP;
public static final String SHORT_NAME = "kmm2";
public static final List<String> RESOURCE_SHORTNAMES = singletonList(SHORT_NAME);
public static final String SPEC_REPLICAS_PATH = ".spec.replicas";
public static final String STATUS_REPLICAS_PATH = ".status.replicas";
public static final String LABEL_SELECTOR_PATH = ".status.selector";

private String apiVersion;
private KafkaMirrorMaker2Spec spec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -27,6 +29,8 @@ public class KafkaBridgeStatus extends Status {
private static final long serialVersionUID = 1L;

private String url;
private int replicas;
private LabelSelector podSelector;

@Description("The URL at which external client applications can access the Kafka Bridge.")
public String getUrl() {
Expand All @@ -36,4 +40,25 @@ public String getUrl() {
public void setUrl(String url) {
this.url = url;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@Description("The current number of pods being used to provide this resource.")
public int getReplicas() {
return replicas;
}

public void setReplicas(int replicas) {
this.replicas = replicas;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@KubeLink(group = "meta", version = "v1", kind = "labelselector")
@Description("Label selector for pods providing this resource.")
public LabelSelector getPodSelector() {
return podSelector;
}

public void setPodSelector(LabelSelector podSelector) {
this.podSelector = podSelector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.api.kafka.model.connect.ConnectorPlugin;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -31,6 +33,8 @@ public class KafkaConnectStatus extends Status {

private String url;
private List<ConnectorPlugin> connectorPlugins;
private int replicas;
private LabelSelector podSelector;

@Description("The URL of the REST API endpoint for managing and monitoring Kafka Connect connectors.")
public String getUrl() {
Expand All @@ -50,4 +54,25 @@ public List<ConnectorPlugin> getConnectorPlugins() {
public void setConnectorPlugins(List<ConnectorPlugin> connectorPlugins) {
this.connectorPlugins = connectorPlugins;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@Description("The current number of pods being used to provide this resource.")
public int getReplicas() {
return replicas;
}

public void setReplicas(int replicas) {
this.replicas = replicas;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@KubeLink(group = "meta", version = "v1", kind = "labelselector")
@Description("Label selector for pods providing this resource.")
public LabelSelector getPodSelector() {
return podSelector;
}

public void setPodSelector(LabelSelector podSelector) {
this.podSelector = podSelector;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class KafkaConnectorStatus extends Status {
private static final long serialVersionUID = 1L;

private Map<String, Object> connectorStatus;
private int tasksMax;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Description("The connector status, as reported by the Kafka Connect REST API.")
Expand All @@ -39,4 +40,14 @@ public Map<String, Object> getConnectorStatus() {
public void setConnectorStatus(Map<String, Object> connectorStatus) {
this.connectorStatus = connectorStatus;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@Description("The maximum number of tasks for the Kafka Connector.")
public int getTasksMax() {
return tasksMax;
}

public void setTasksMax(int tasksMax) {
this.tasksMax = tasksMax;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.strimzi.api.kafka.model.Constants;
import io.strimzi.crdgenerator.annotations.Description;
import io.strimzi.crdgenerator.annotations.KubeLink;
import io.sundr.builder.annotations.Buildable;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand All @@ -24,4 +27,28 @@
@ToString(callSuper = true)
public class KafkaMirrorMakerStatus extends Status {
private static final long serialVersionUID = 1L;

private int replicas;
private LabelSelector podSelector;

@JsonInclude(JsonInclude.Include.NON_NULL)
@Description("The current number of pods being used to provide this resource.")
public int getReplicas() {
return replicas;
}

public void setReplicas(int replicas) {
this.replicas = replicas;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@KubeLink(group = "meta", version = "v1", kind = "labelselector")
@Description("Label selector for pods providing this resource.")
public LabelSelector getPodSelector() {
return podSelector;
}

public void setPodSelector(LabelSelector podSelector) {
this.podSelector = podSelector;
}
}
Loading