// 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` resource.

.Before you start

It is important that you consider the following before making your changes:

* Kafka does _not_ support making the following changes through the `KafkaTopic` resource:
** Changing topic names using `spec.topicName`
** Decreasing partition size using `spec.partitions`
* You cannot change the number of replicas initially specified using `spec.replicas`.
* Increasing `spec.partitions` for topics with keys will change how records are partitioned, which can be particularly problematic when the topic uses _semantic partitioning_.

.Prerequisites

* A running Kafka cluster.
* A running Topic Operator (typically xref:assembly-kafka-entity-operator-deployment-configuration-kafka[deployed with the Entity Operator]).
* An existing `KafkaTopic` to be changed.

.Procedure

. Prepare a file containing the desired `KafkaTopic`
+
For example:
+
[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 `kubectl get kafkatopic orders -o yaml`.

. Apply the changes to the deployment of your `KafkaTopic` resource.
+
[source,shell,subs=+quotes]
kubectl 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[Deploying the Cluster Operator].
* For more information about deploying the Topic Operator using the Cluster Operator, see xref:deploying-the-topic-operator-using-the-cluster-operator-str[Deploying the Topic Operator using the Cluster Operator].
* For more information about creating a topic using the Topic Operator, see xref:creating-a-topic-str[Creating a Topic].
