@Override
    public boolean update(ApiClient apiClient, V1HorizontalPodAutoscaler resource, String namespace) throws HyscaleException {
        if (resource == null) {
            logger.debug("Cannot update null HorizontalPodAutoScaler");
            return false;
        }
        AutoscalingV1Api autoscalingV1Api = new AutoscalingV1Api(apiClient);
        String name = resource.getMetadata().getName();
        V1HorizontalPodAutoscaler existingHorizontalPodAutoscaler = null;
        try {
            existingHorizontalPodAutoscaler = get(apiClient, name, namespace);
        } catch (HyscaleException ex) {
            logger.debug("Error while getting HorizontalPodAutoScaler  {} in namespace {} for Update, creating new", name, namespace);
            V1HorizontalPodAutoscaler horizontalPodAutoscaler = create(apiClient, resource, namespace);
            return horizontalPodAutoscaler != null;
        }
        WorkflowLogger.startActivity(DeployerActivity.DEPLOYING_HORIZONTAL_AUTO_SCALER);
        try {
            String resourceVersion = existingHorizontalPodAutoscaler.getMetadata().getResourceVersion();
            resource.getMetadata().setResourceVersion(resourceVersion);
            autoscalingV1Api.replaceNamespacedHorizontalPodAutoscaler(name, namespace, resource, DeployerConstants.TRUE, null, null);
        } catch (ApiException e) {
            HyscaleException ex = new HyscaleException(e, DeployerErrorCodes.FAILED_TO_UPDATE_RESOURCE,
                    ExceptionHelper.getExceptionMessage(getKind(), e, ResourceOperation.UPDATE));
            logger.error("Error while updating 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