FAQs
Why can’t I scale StatefulSets directly?
When creating Pulsar CRs, the Pulsar Operators create a group of resources, including the StatefulSets for Pulsar brokers, proxies (optional), bookies, and ZooKeeper. The Pulsar Operators check whether these StatefulSets work as expected according to the CRs and make any change to the StatefulSets if necessary. To increase or decrease the number of Pods controlled by the StatefulSets, you should not edit the StatefulSets directly.
For example, if you run the kubectl scale statefulsets brokers-broker --replicas=5 -n pulsar
command to scale the replicas of Pulsar brokers from the default value 2 to 5, the StatefulSet controller first adds 3 new Pods but it deletes them immediately. This is because the Pulsar Operators detect the difference between the configured replicas (2) in the Pulsar broker CR and the replicas (5) that are actually running. For the Pulsar Operators, this is not the desired state so they force the StatefulSet controller to delete the newly-created 3 Pods.
To see how the Pulsar Operators work on the broker StatefulSet, run the following command:
kubectl -n pulsar describe statefulsets brokers-broker
Navigate to the Events field and you may see the following result:
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 30s statefulset-controller create Pod brokers-broker-0 in StatefulSet brokers-broker successful
Normal SuccessfulCreate 30s statefulset-controller create Pod brokers-broker-1 in StatefulSet brokers-broker successful
Normal SuccessfulDelete 47s statefulset-controller create Pod brokers-broker-2 in StatefulSet brokers-broker successful
Normal SuccessfulDelete 47s statefulset-controller create Pod brokers-broker-3 in StatefulSet brokers-broker successful
Normal SuccessfulDelete 47s statefulset-controller create Pod brokers-broker-4 in StatefulSet brokers-broker successful
Normal SuccessfulCreate 48s statefulset-controller delete Pod brokers-broker-4 in StatefulSet brokers-broker successful
Normal SuccessfulCreate 48s statefulset-controller delete Pod brokers-broker-3 in StatefulSet brokers-broker successful
Normal SuccessfulCreate 48s statefulset-controller delete Pod brokers-broker-2 in StatefulSet brokers-broker successful