// Module included in the following assemblies:
//
// assembly-using-the-topic-operator.adoc

[id='changing-a-topic-{context}']
= Changing a topic

This procedure describes how to change the configuration of an existing Kafka topic by using a `KafkaTopic` {ProductPlatformName} resource.

.Prerequisites

* A running Kafka cluster.
* A running Topic Operator.
* An existing `KafkaTopic` to be changed.

.Procedure

. Prepare a file containing the desired `KafkaTopic`
+
.An example `KafkaTopic`
[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaTopicApiVersion}
kind: KafkaTopic
metadata:
  name: orders
  labels:
    strimzi.io/cluster: my-cluster
spec:
  partitions: 16
  replicas: 2
----
+
TIP: You can get the current version of the resource using `oc get kafkatopic orders -o yaml`.
+
NOTE: Changing topic names using the `KafkaTopic.spec.topicName` variable and decreasing partition size using the `KafkaTopic.spec.partitions` variable is not supported by Kafka.
+
CAUTION: Increasing `spec.partitions` for topics with keys will change how records are partitioned, which can be particularly problematic when the topic uses _semantic partitioning_.

. Update the `KafkaTopic` resource in {ProductPlatformName}.
+
ifdef::Kubernetes[]
On {KubernetesName} this can be done using `kubectl apply`:
+
[source,shell,subs=+quotes]
kubectl apply -f _your-file_
+
endif::Kubernetes[]
On {OpenShiftName} this can be done using `oc apply`:
+
[source,shell,subs=+quotes]
oc apply -f _your-file_


.Additional resources
* For more information about the schema for `KafkaTopics`, see xref:type-KafkaTopic-reference[`KafkaTopic` schema reference].
* For more information about deploying a Kafka cluster, see xref:cluster-operator-str[].
* For more information about deploying the Topic Operator using the Cluster Operator, see xref:deploying-the-topic-operator-using-the-cluster-operator-str[].
* For more information about creating a topic using the Topic Operator, see xref:creating-a-topic-str[].
