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

[id='proc-upgrade-zookeeper-api-version-{context}']
= Upgrading ZooKeeper to support {ApiVersion}

.Prerequisites

* A Cluster Operator supporting the `{ApiVersion}` API version is up and running.

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

. Update the `Kafka` custom resource in an editor.
+
[source,shell,subs="+quotes,attributes"]
----
kubectl edit kafka _KAFKA-CLUSTER_
----

. If present, move `affinity` from `.spec.zookeeper.affinity` to `.spec.zookeeper.template.pod.affinity`.

. If present, move `tolerations` from `.spec.zookeeper.tolerations` to `.spec.zookeeper.template.pod.tolerations`.

. If present, remove `.spec.zookeeper.template.tlsSidecarContainer`.

. If present, remove `.spec.zookeeper.tlsSidecarContainer`.

. If `type: external` logging is configured in `.spec.kafka.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.zookeeper.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.zookeeper.metrics` field.
+
[source,yaml,subs="attributes+"]
----
kind: ConfigMap
apiVersion: v1
metadata:
  name: kafka-metrics
  labels:
    app: strimzi
data:
  zookeeper-metrics-config.yaml: |
      <YAML>
----

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

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

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