@Override
    public boolean patch(ApiClient apiClient, String name, String namespace, V1HorizontalPodAutoscaler target) throws HyscaleException {
        if (target == null) {
            logger.debug("Cannot patch null HorizontalPodAutoScaler");
            return false;
        }
        AutoscalingV1Api autoscalingV1Api = new AutoscalingV1Api(apiClient);
        target.getMetadata().putAnnotationsItem(AnnotationKey.K8S_HYSCALE_LAST_APPLIED_CONFIGURATION.getAnnotation(),
                GsonProviderUtil.getPrettyGsonBuilder().toJson(target));
        V1HorizontalPodAutoscaler sourceHorizontalPodAutoScaler = null;
        try {
            sourceHorizontalPodAutoScaler = get(apiClient, name, namespace);
        } catch (HyscaleException e) {
            logger.debug("Error while getting HorizontalPodAutoScaler {} in namespace {} for Patch, creating new", name, namespace);
            V1HorizontalPodAutoscaler horizontalPodAutoscaler = create(apiClient, target, namespace);
            return horizontalPodAutoscaler != null;
        }
        WorkflowLogger.startActivity(DeployerActivity.DEPLOYING_HORIZONTAL_AUTO_SCALER);
        Object patchObject = null;
        String lastAppliedConfig = sourceHorizontalPodAutoScaler.getMetadata().getAnnotations()
                .get(AnnotationKey.K8S_HYSCALE_LAST_APPLIED_CONFIGURATION.getAnnotation());
        try {
            patchObject = K8sResourcePatchUtil.getJsonPatch(GsonProviderUtil.getPrettyGsonBuilder().fromJson(lastAppliedConfig, V1HorizontalPodAutoscaler.class),
                    target, V1HorizontalPodAutoscaler.class);
            V1Patch v1Patch = new V1Patch(patchObject.toString());
            autoscalingV1Api.patchNamespacedHorizontalPodAutoscaler(name, namespace, v1Patch, DeployerConstants.TRUE, null, null, null);
        } catch (HyscaleException e) {
            logger.error("Error while creating patch for HorizontalPodAutoScaler {}, source {}, target {}", name, sourceHorizontalPodAutoScaler,
                    target);
            WorkflowLogger.endActivity(Status.FAILED);
            throw e;
        } catch (ApiException e) {
            HyscaleException ex = new HyscaleException(e, DeployerErrorCodes.FAILED_TO_PATCH_RESOURCE,
                    ExceptionHelper.getExceptionMessage(getKind(), e, ResourceOperation.PATCH));
            logger.error("Error while patching HorizontalPodAutoScaler {} in namespace {} , error {}", name, namespace,
                    ex.toString());
            WorkflowLogger.endActivity(Status.FAILED);
            throw ex;
        }
        WorkflowLogger.endActivity(Status.DONE);
        return true;
    }
This class is responsible for the lifecycle operations of resource
HorizontalPodAutoScaler in kubernetes cluster. It creates resource of
apiVersion: autoscaling/v1
kind: HorizontalPodAutoScaler
deployer/deployer-services/src/main/java/io/hyscale/deployer/services/handler/impl/V1HorizontalPodAutoScalerHandler.java