use of io.fabric8.kubernetes.client.dsl.ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable in project zeppelin by apache.
the class K8sRemoteInterpreterProcess method apply.
/**
* Apply spec file(s) in the path.
* @param path Path to the K8s resources
* @param delete set to true, the K8s resources are deleted
* @param templateProperties properties to enrich the template
*/
void apply(File path, boolean delete, Properties templateProperties) throws IOException {
if (path.getName().startsWith(".") || path.isHidden() || path.getName().endsWith("~")) {
LOGGER.info("Skip {}", path.getAbsolutePath());
return;
}
if (path.isDirectory()) {
File[] files = path.listFiles();
Arrays.sort(files);
if (delete) {
ArrayUtils.reverse(files);
}
for (File f : files) {
apply(f, delete, templateProperties);
}
} else if (path.isFile()) {
K8sSpecTemplate specTemplate = new K8sSpecTemplate();
specTemplate.loadProperties(templateProperties);
String template = specTemplate.render(path);
ParameterNamespaceListVisitFromServerGetDeleteRecreateWaitApplicable<HasMetadata> k8sObjects = client.load(IOUtils.toInputStream(template, StandardCharsets.UTF_8));
LOGGER.info("Apply {} with {} K8s Objects", path.getAbsolutePath(), k8sObjects.get().size());
LOGGER.debug(template);
if (delete) {
k8sObjects.inNamespace(interpreterNamespace).delete();
} else {
k8sObjects.inNamespace(interpreterNamespace).createOrReplace();
}
} else {
LOGGER.error("Can't apply {}", path.getAbsolutePath());
}
}
Aggregations