Chapter 16. Managing AMQ Streams
This chapter covers tasks to maintain a deployment of AMQ Streams.
16.1. Checking the status of a custom resource Copy linkLink copied to clipboard!
This procedure describes how to find the status of a custom resource.
Prerequisites
- An OpenShift cluster.
- The Cluster Operator is running.
Procedure
Specify the custom resource and use the
-o jsonpath
option to apply a standard JSONPath expression to select thestatus
property:oc get kafka <kafka_resource_name> -o jsonpath='{.status}'
oc get kafka <kafka_resource_name> -o jsonpath='{.status}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This expression returns all the status information for the specified custom resource. You can use dot notation, such as
status.listeners
orstatus.observedGeneration
, to fine-tune the status information you wish to see.
Additional resources
- Section 2.2.2, “AMQ Streams custom resource status”
- For more information about using JSONPath, see JSONPath support.
16.2. Recovering a cluster from persistent volumes Copy linkLink copied to clipboard!
You can recover a Kafka cluster from persistent volumes (PVs) if they are still present.
You might want to do this, for example, after:
- A namespace was deleted unintentionally
- A whole OpenShift cluster is lost, but the PVs remain in the infrastructure
16.2.1. Recovery from namespace deletion Copy linkLink copied to clipboard!
Recovery from namespace deletion is possible because of the relationship between persistent volumes and namespaces. A PersistentVolume
(PV) is a storage resource that lives outside of a namespace. A PV is mounted into a Kafka pod using a PersistentVolumeClaim
(PVC), which lives inside a namespace.
The reclaim policy for a PV tells a cluster how to act when a namespace is deleted. If the reclaim policy is set as:
- Delete (default), PVs are deleted when PVCs are deleted within a namespace
- Retain, PVs are not deleted when a namespace is deleted
To ensure that you can recover from a PV if a namespace is deleted unintentionally, the policy must be reset from Delete to Retain in the PV specification using the persistentVolumeReclaimPolicy
property:
Alternatively, PVs can inherit the reclaim policy of an associated storage class. Storage classes are used for dynamic volume allocation.
By configuring the reclaimPolicy
property for the storage class, PVs that use the storage class are created with the appropriate reclaim policy. The storage class is configured for the PV using the storageClassName
property.
If you are using Retain as the reclaim policy, but you want to delete an entire cluster, you need to delete the PVs manually. Otherwise they will not be deleted, and may cause unnecessary expenditure on resources.
16.2.2. Recovery from loss of an OpenShift cluster Copy linkLink copied to clipboard!
When a cluster is lost, you can use the data from disks/volumes to recover the cluster if they were preserved within the infrastructure. The recovery procedure is the same as with namespace deletion, assuming PVs can be recovered and they were created manually.
16.2.3. Recovering a cluster from persistent volumes Copy linkLink copied to clipboard!
This procedure describes how to recover a deleted cluster from persistent volumes (PVs).
In this situation, the Topic Operator identifies that topics exist in Kafka, but the KafkaTopic
resources do not exist.
When you get to the step to recreate your cluster, you have two options:
Use Option 1 when you can recover all
KafkaTopic
resources.The
KafkaTopic
resources must therefore be recovered before the cluster is started so that the corresponding topics are not deleted by the Topic Operator.Use Option 2 when you are unable to recover all
KafkaTopic
resources.This time you deploy your cluster without the Topic Operator, delete the Topic Operator data in ZooKeeper, and then redeploy it so that the Topic Operator can recreate the
KafkaTopic
resources from the corresponding topics.
If the Topic Operator is not deployed, you only need to recover the PersistentVolumeClaim
(PVC) resources.
Before you begin
In this procedure, it is essential that PVs are mounted into the correct PVC to avoid data corruption. A volumeName
is specified for the PVC and this must match the name of the PV.
For more information, see:
The procedure does not include recovery of KafkaUser
resources, which must be recreated manually. If passwords and certificates need to be retained, secrets must be recreated before creating the KafkaUser
resources.
Procedure
Check information on the PVs in the cluster:
oc get pv
oc get pv
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Information is presented for PVs with data.
Example output showing columns important to this procedure:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - NAME shows the name of each PV.
- RECLAIM POLICY shows that PVs are retained.
- CLAIM shows the link to the original PVCs.
Recreate the original namespace:
oc create namespace myproject
oc create namespace myproject
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate the original PVC resource specifications, linking the PVCs to the appropriate PV:
For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the PV specifications to delete the
claimRef
properties that bound the original PVC.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In the example, the following properties are deleted:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the Cluster Operator.
oc apply -f install/cluster-operator -n my-project
oc apply -f install/cluster-operator -n my-project
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Recreate your cluster.
Follow the steps depending on whether or not you have all the
KafkaTopic
resources needed to recreate your cluster.Option 1: If you have all the
KafkaTopic
resources that existed before you lost your cluster, including internal topics such as committed offsets from__consumer_offsets
:Recreate all
KafkaTopic
resources.It is essential that you recreate the resources before deploying the cluster, or the Topic Operator will delete the topics.
Deploy the Kafka cluster.
For example:
oc apply -f kafka.yaml
oc apply -f kafka.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Option 2: If you do not have all the
KafkaTopic
resources that existed before you lost your cluster:Deploy the Kafka cluster, as with the first option, but without the Topic Operator by removing the
topicOperator
property from the Kafka resource before deploying.If you include the Topic Operator in the deployment, the Topic Operator will delete all the topics.
Run an
exec
command to one of the Kafka broker pods to open the ZooKeeper shell script.For example, where my-cluster-kafka-0 is the name of the broker pod:
oc exec my-cluster-kafka-0 bin/zookeeper-shell.sh localhost:2181
oc exec my-cluster-kafka-0 bin/zookeeper-shell.sh localhost:2181
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Delete the whole
/strimzi
path to remove the Topic Operator storage:deleteall /strimzi
deleteall /strimzi
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the Topic Operator by redeploying the Kafka cluster with the
topicOperator
property to recreate theKafkaTopic
resources.For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- 1
- Here we show the default configuration, which has no additional properties. You specify the required configuration using the properties described in Section B.62, “
EntityTopicOperatorSpec
schema reference”.
Verify the recovery by listing the
KafkaTopic
resources:oc get KafkaTopic
oc get KafkaTopic
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.3. Uninstalling AMQ Streams Copy linkLink copied to clipboard!
This procedure describes how to uninstall AMQ Streams and remove resources related to the deployment.
Prerequisites
In order to perform this procedure, identify resources created specifically for a deployment and referenced from the AMQ Streams resource.
Such resources include:
- Secrets (Custom CAs and certificates, Kafka Connect secrets, and other Kafka secrets)
-
Logging
ConfigMaps
(of typeexternal
)
These are resources referenced by Kafka
, KafkaConnect
, KafkaConnectS2I
, KafkaMirrorMaker
, or KafkaBridge
configuration.
Procedure
Delete the Cluster Operator
Deployment
, relatedCustomResourceDefinitions
, andRBAC
resources:oc delete -f install/cluster-operator
oc delete -f install/cluster-operator
Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningDeleting
CustomResourceDefinitions
results in the garbage collection of the corresponding custom resources (Kafka
,KafkaConnect
,KafkaConnectS2I
,KafkaMirrorMaker
, orKafkaBridge
) and the resources dependent on them (Deployments, StatefulSets, and other dependent resources).- Delete the resources you identified in the prerequisites.