use of io.fabric8.kubernetes.api.model.batch.Job in project fabric8-maven-plugin by fabric8io.
the class KubernetesResourceUtil method getPodLabelSelector.
public static LabelSelector getPodLabelSelector(HasMetadata entity) {
LabelSelector selector = null;
if (entity instanceof Deployment) {
Deployment resource = (Deployment) entity;
DeploymentSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof ReplicaSet) {
ReplicaSet resource = (ReplicaSet) entity;
ReplicaSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) entity;
DeploymentConfigSpec spec = resource.getSpec();
if (spec != null) {
selector = toLabelSelector(spec.getSelector());
}
} else if (entity instanceof ReplicationController) {
ReplicationController resource = (ReplicationController) entity;
ReplicationControllerSpec spec = resource.getSpec();
if (spec != null) {
selector = toLabelSelector(spec.getSelector());
}
} else if (entity instanceof DaemonSet) {
DaemonSet resource = (DaemonSet) entity;
DaemonSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof StatefulSet) {
StatefulSet resource = (StatefulSet) entity;
StatefulSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof Job) {
Job resource = (Job) entity;
JobSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
}
return selector;
}
use of io.fabric8.kubernetes.api.model.batch.Job in project fabric8-maven-plugin by fabric8io.
the class JobHandlerTest method jobHandlerTest.
@Test
public void jobHandlerTest() {
ContainerHandler containerHandler = new ContainerHandler(project, envVarHandler, probeHandler);
PodTemplateHandler podTemplateHandler = new PodTemplateHandler(containerHandler);
JobHandler jobHandler = new JobHandler(podTemplateHandler);
ResourceConfig config = new ResourceConfig.Builder().imagePullPolicy("IfNotPresent").controllerName("testing").withServiceAccount("test-account").volumes(volumes1).build();
Job job = jobHandler.getJob(config, images);
// Assertion
assertNotNull(job.getSpec());
assertNotNull(job.getMetadata());
assertNotNull(job.getSpec().getTemplate());
assertEquals("testing", job.getMetadata().getName());
assertEquals("test-account", job.getSpec().getTemplate().getSpec().getServiceAccountName());
assertFalse(job.getSpec().getTemplate().getSpec().getVolumes().isEmpty());
assertEquals("test", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getName());
assertEquals("/test/path", job.getSpec().getTemplate().getSpec().getVolumes().get(0).getHostPath().getPath());
assertNotNull(job.getSpec().getTemplate().getSpec().getContainers());
}
use of io.fabric8.kubernetes.api.model.batch.Job in project fabric8-maven-plugin by fabric8io.
the class KubernetesResourceUtilTest method job.
@Test
public void job() throws Exception {
HasMetadata ret = getResource(DEFAULT_RESOURCE_VERSIONING, new File(fabric8Dir, "job.yml"), "app");
assertEquals("Job", ret.getKind());
assertEquals(JOB_VERSION, ret.getApiVersion());
}
use of io.fabric8.kubernetes.api.model.batch.Job in project flink by apache.
the class InternalServiceDecorator method buildAccompanyingKubernetesResources.
@Override
public List<HasMetadata> buildAccompanyingKubernetesResources() throws IOException {
if (!kubernetesJobManagerParameters.isInternalServiceEnabled()) {
return Collections.emptyList();
}
final String serviceName = getInternalServiceName(kubernetesJobManagerParameters.getClusterId());
final Service headlessService = HeadlessClusterIPService.INSTANCE.buildUpInternalService(kubernetesJobManagerParameters);
// Set job manager address to namespaced service name
final String namespace = kubernetesJobManagerParameters.getNamespace();
kubernetesJobManagerParameters.getFlinkConfiguration().setString(JobManagerOptions.ADDRESS, getNamespacedInternalServiceName(serviceName, namespace));
return Collections.singletonList(headlessService);
}
use of io.fabric8.kubernetes.api.model.batch.Job in project fabric8 by fabric8io.
the class ViewPipeline method main.
public static void main(String[] args) {
if (args.length == 0) {
System.err.println("Usage: ViewPipeline jobName [branchName] [gitUrl]");
return;
}
String jobName = args[0];
String branchName = "master";
String gitUrl = null;
if (args.length > 1) {
branchName = args[1];
}
if (args.length > 2) {
gitUrl = args[2];
}
try {
JobEnvironment environment = new JobEnvironment();
environment.setJobName(jobName);
environment.setBranchName(branchName);
environment.setGitUrl(gitUrl);
KubernetesClient kubernetesClient = new DefaultKubernetesClient();
String namespace = kubernetesClient.getNamespace();
if (Strings.isNullOrBlank(namespace)) {
namespace = KubernetesHelper.defaultNamespace();
}
Pipeline pipeline = Pipelines.getPipeline(kubernetesClient, namespace, environment);
System.out.println("Found pipeline for job: " + pipeline.getJobName() + " of kind: " + pipeline.getKind());
} catch (IntrospectionException e) {
System.out.println("Failed with: " + e);
e.printStackTrace();
}
}
Aggregations