use of io.fabric8.openshift.api.model.Template in project flink by apache.
the class DecoratorWithPodTemplateTestBase method testPodTolerationsMerging.
@Test
public void testPodTolerationsMerging() {
final List<Toleration> expectedTolerations = Arrays.asList(new Toleration("NoSchedule", "key1", "Equal", null, "value1"), // The toleration from pod template
new Toleration("NoExecute", "key2-of-pod-template", "Exists", 6000L, null));
assertThat(this.resultPod.getPodWithoutMainContainer().getSpec().getTolerations(), Matchers.containsInAnyOrder(expectedTolerations.toArray()));
}
use of io.fabric8.openshift.api.model.Template 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());
}
}
use of io.fabric8.openshift.api.model.Template in project fabric8 by fabric8io.
the class SessionListener method expandTemplate.
protected Object expandTemplate(Controller controller, Configuration configuration, Logger log, String namespace, String sourceName, Object dto) {
if (dto instanceof Template) {
Template template = (Template) dto;
KubernetesHelper.setNamespace(template, namespace);
String parameterNamePrefix = "";
overrideTemplateParameters(template, configuration.getProperties(), parameterNamePrefix);
log.status("Applying template in namespace " + namespace);
controller.installTemplate(template, sourceName);
dto = controller.processTemplate(template, sourceName);
if (dto == null) {
throw new IllegalArgumentException("Failed to process Template!");
}
}
return dto;
}
use of io.fabric8.openshift.api.model.Template in project fabric8 by fabric8io.
the class ParseTest method testParseTemplate.
@Test
public void testParseTemplate() throws Exception {
Template template = assertParseExampleFile("template.json", Template.class);
List<HasMetadata> objects = template.getObjects();
assertNotEmpty("objects", objects);
assertTrue("size is " + objects.size(), objects.size() == 2);
Object service = objects.get(0);
assertThat(service).isInstanceOf(Service.class);
Object rc = objects.get(1);
assertThat(rc).isInstanceOf(ReplicationController.class);
System.out.println("Generated JSON: " + toJson(template));
}
use of io.fabric8.openshift.api.model.Template in project keycloak by keycloak.
the class KeycloakDeployment method getReconciledResource.
@Override
public Optional<HasMetadata> getReconciledResource() {
// clone not to change the base template
Deployment baseDeployment = new DeploymentBuilder(this.baseDeployment).build();
Deployment reconciledDeployment;
if (existingDeployment == null) {
Log.info("No existing Deployment found, using the default");
reconciledDeployment = baseDeployment;
} else {
Log.info("Existing Deployment found, updating specs");
reconciledDeployment = existingDeployment;
// don't override metadata, just specs
reconciledDeployment.setSpec(baseDeployment.getSpec());
}
return Optional.of(reconciledDeployment);
}
Aggregations