@Override
	public void preHook(WorkflowContext context) throws HyscaleException {
		logger.info("Starting stale kubernetes resource cleanup");
		ApiClient apiClient = clientProvider.get((K8sAuthorisation) context.getAuthConfig());
		String serviceName = context.getServiceName();
		String appName = context.getAppName();
		String namespace = context.getNamespace();
		String envName = context.getEnvName();
		List<Manifest> manifestList = (List<Manifest>) context.getAttribute(WorkflowConstants.GENERATED_MANIFESTS);

		if (manifestList == null || manifestList.isEmpty()) {
			logger.debug("No resources to cleanup");
			return;
		}
		boolean isMsgPrinted = false;
		String selector = ResourceSelectorUtil.getSelector(appName, envName, serviceName);
		try{
			MultiValueMap<String,String> kindVsResourcesManifestMap = getResourcesMap(manifestList);
			PodParentUtil podParentUtil = new PodParentUtil(apiClient,namespace);
			PodParent podParent = podParentUtil.getPodParentForService(serviceName);
			if(podParent == null){
				return;
			}
			List<CustomResourceKind> appliedKindsList = podParentUtil.getAppliedKindsList(podParent);
			for(CustomResourceKind customResourceKind : appliedKindsList){
				if(ResourceKind.PERSISTENT_VOLUME_CLAIM.getKind().equalsIgnoreCase(customResourceKind.getKind())){
					continue;
				}
				GenericK8sClient genericK8sClient = new K8sResourceClient(apiClient).withNamespace(namespace)
						.forKind(customResourceKind);
				List<CustomObject> existingResources = genericK8sClient.getBySelector(selector);
				if(existingResources == null || existingResources.isEmpty()){
					continue;
				}
				List<String> newResources = kindVsResourcesManifestMap.get(customResourceKind.getKind()) != null
						? kindVsResourcesManifestMap.get(customResourceKind.getKind())
						: new ArrayList<String>();

				//TODO implement Lazy Deletion
				for(CustomObject existingResource : existingResources){
					try{
						String name = existingResource.getMetadata().getName();
						if (!newResources.contains(name)) {
							if (!isMsgPrinted) {
								WorkflowLogger.header(ControllerActivity.CLEANING_UP_RESOURCES);
								isMsgPrinted = true;
							}
							genericK8sClient.delete(existingResource);
						}
					}catch (Exception e){
						logger.error("Error while cleaning up stale resource: {}, error: {}", customResourceKind.getKind(),
								e.getMessage());
					}
				}
			}
			if(isMsgPrinted){
				WorkflowLogger.footer();
			}
		}catch (Exception e){
			HyscaleException ex = new HyscaleException(e, DeployerErrorCodes.FAILED_TO_READ_MANIFEST);
			logger.error("Error while cleaning stale kubernetes resources, error: {}", ex.getMessage());
			return;
		}
	}
Clean up old resources
1.	Create map of resources in manifest
2.	For each Resource where clean up is enabled except PVC:
		1. Fetch resource from K8s based on selector
		2. if does not exist in map delete
workflow-controller/controller-service/src/main/java/io/hyscale/controller/hooks/K8SResourcesCleanUpHook.java