@Override
	public boolean patch(ApiClient apiClient, String name, String namespace, V1beta2StatefulSet target)
			throws HyscaleException {
		if (target == null) {
			LOGGER.debug("Cannot patch null StatefulSet");
			return false;
		}
		AppsV1beta2Api appsV1beta2Api = new AppsV1beta2Api(apiClient);
		target.getMetadata().putAnnotationsItem(AnnotationKey.K8S_HYSCALE_LAST_APPLIED_CONFIGURATION.getAnnotation(),
				GsonProviderUtil.getPrettyGsonBuilder().toJson(target));
		V1beta2StatefulSet sourceStatefulSet = null;
		try {
			sourceStatefulSet = get(apiClient, name, namespace);
		} catch (HyscaleException e) {
			LOGGER.debug("Error while getting StatefulSet {} in namespace {} for Patch, creating new", name, namespace);
			V1beta2StatefulSet statefulSet = create(apiClient, target, namespace);
			return statefulSet != null;
		}
		WorkflowLogger.startActivity(DeployerActivity.DEPLOYING_STATEFULSET);
		Object patchObject = null;
		String lastAppliedConfig = sourceStatefulSet.getMetadata().getAnnotations()
				.get(AnnotationKey.K8S_HYSCALE_LAST_APPLIED_CONFIGURATION.getAnnotation());
		boolean deleteRequired = false;
		String serviceName = sourceStatefulSet.getMetadata().getLabels().get(ResourceLabelKey.SERVICE_NAME.getLabel());
		try {
			patchObject = K8sResourcePatchUtil.getJsonPatch(GsonProviderUtil.getPrettyGsonBuilder().fromJson(lastAppliedConfig, V1beta2StatefulSet.class),
					target, V1beta2StatefulSet.class);
			deleteRequired = isDeletePodRequired(apiClient, serviceName, namespace);
			LOGGER.debug("Deleting existing pods for updating StatefulSet patch required :{}", deleteRequired);
			V1Patch v1Patch = new V1Patch(patchObject.toString());
			appsV1beta2Api.patchNamespacedStatefulSet(name, namespace, v1Patch, DeployerConstants.TRUE, null, null, null);
		} catch (HyscaleException ex) {
			LOGGER.error("Error while creating patch for StatefulSet {}, source {}, target {}, error {}", name,
					sourceStatefulSet, target, ex.toString());
			WorkflowLogger.endActivity(Status.FAILED);
			throw ex;
		} catch (ApiException e) {
			HyscaleException ex = new HyscaleException(e, DeployerErrorCodes.FAILED_TO_PATCH_RESOURCE,
					ExceptionHelper.getExceptionMessage(getKind(), e, ResourceOperation.PATCH));
			LOGGER.error("Error while patching StatefulSet {} in namespace {} , error {}", name, namespace,
					ex.toString());
			WorkflowLogger.endActivity(Status.FAILED);
			throw ex;
		} finally {
			if (deleteRequired) {
				V1PodHandler podHandler = (V1PodHandler) ResourceHandlers.getHandlerOf(ResourceKind.POD.getKind());
				podHandler.deleteBySelector(apiClient, getPodSelector(serviceName), true, namespace, false);
			}
		}
		WorkflowLogger.endActivity(Status.DONE);
		return true;
	}
Also deletes previous pods if they are in error state
deployer/deployer-services/src/main/java/io/hyscale/deployer/services/handler/impl/V1beta2StatefulSetHandler.java