// Module included in the following assemblies:
//
// assembly-upgrade-resources.adoc

[id='proc-upgrade-kafka-mirror-maker-resources-{context}']
= Upgrading Kafka MirrorMaker resources to {ApiVersion}

.Prerequisites

* A Cluster Operator supporting the `{ApiVersion}` API version is up and running.
* MirrorMaker is configured and deployed. 
See xref:deploying-kafka-mirror-maker-{context}[]. 

.Procedure
Perform the following steps for each `KafkaMirrorMaker` custom resource in your deployment.

. Update the `KafkaMirrorMaker` custom resource in an editor.
+
[source,shell,subs="+quotes,attributes"]
----
kubectl edit kafkamirrormaker _MIRROR-MAKER_
----

. If present, move:
+
[source,shell]
----
KafkaMirrorMaker.spec.affinity
----
+
[source,shell]
----
KafkaMirrorMaker.spec.tolerations
----
+
to:
+
[source,shell]
----
KafkaMirrorMaker.spec.template.pod.affinity
----
+
[source,shell]
----
KafkaMirrorMaker.spec.template.pod.tolerations
----
+
For example, move:
+
[source,shell]
----
spec:
  # ...
  affinity:
    # ...
  tolerations:
    # ...
----
+
to:
+
[source,shell]
----
spec:
  # ...
  template:
    pod:
      affinity:
        # ...
      tolerations:
        # ...
----

. If `type: external` logging is configured in `.spec.logging`:
+
Replace the `name` of the ConfigMap containing the logging configuration:
+
[source,yaml,subs="attributes+"]
----
logging:
  type: external
  name: my-config-map
----
+
With the `valueFrom.configMapKeyRef` field, and specify both the ConfigMap `name` and the `key` under which the logging is stored:
+
[source,yaml,subs="attributes+"]
----
logging:
  type: external
  valueFrom:
    configMapKeyRef:
      name: my-config-map
      key: log4j.properties
----

. If the `.spec.metrics` field is used to enable metrics:

.. Create a new ConfigMap that stores the YAML configuration for the JMX Prometheus exporter under a key. 
The YAML must match what is currently in the `.spec.metrics` field.
+
[source,yaml,subs="attributes+"]
----
kind: ConfigMap
apiVersion: v1
metadata:
  name: kafka-mm-metrics
  labels:
    app: strimzi
data:
  mm-metrics-config.yaml: |
      <YAML>
----

.. Add a `.spec.metricsConfig` property that points to the ConfigMap and key:
+
[source,yaml,subs="attributes+"]
----
metricsConfig:
  type: jmxPrometheusExporter
  valueFrom:
    configMapKeyRef:
      name: kafka-mm-metrics
      key: mm-metrics-config.yaml
----

.. Delete the old `.spec.metrics` field.

. Update the `apiVersion` of the `KafkaMirrorMaker` custom resource to `{ApiVersion}`:
+
Replace:
+
[source,shell,subs="attributes"]
----
apiVersion: {KafkaMirrorMakerApiVersionPrev}
----
+
with:
+
[source,shell,subs="attributes"]
----
apiVersion: {KafkaMirrorMakerApiVersion}
----

. Save the file, exit the editor and wait for the updated custom resource to be reconciled.