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

[id='creating-a-topic-{context}']
= Creating a topic

This procedure describes how to create a Kafka topic using a `KafkaTopic` {ProductPlatformName} resource.

.Prerequisites

* A running Kafka cluster.
* A running Topic Operator.

.Procedure

. Prepare a file containing the `KafkaTopic` to be created
+
.An example `KafkaTopic`
[source,yaml,subs="attributes+"]
----
apiVersion: {KafkaTopicApiVersion}
kind: KafkaTopic
metadata:
  name: orders
  labels:
    strimzi.io/cluster: my-cluster
spec:
  partitions: 10
  replicas: 2
----
+
NOTE: It is recommended to use a topic name that is a valid {ProductPlatformName} resource name. Doing this means that it is not necessary to set the `KafkaTopic.spec.topicName` property. In any case the `KafkaTopic.spec.topicName` cannot be changed after creation.
+
NOTE: The `KafkaTopic.spec.partitions` cannot be decreased.

. Create 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 using the Cluster Operator, 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 deploying the standalone Topic Operator, see xref:deploying-the-topic-operator-standalone-deploying[].
