use of io.kubernetes.client.openapi.models.V1ObjectMeta in project twister2 by DSC-SPIDAL.
the class JobMasterRequestObject method createStatefulSetObject.
/**
* create StatefulSet object for a job
*/
public static V1StatefulSet createStatefulSetObject() {
if (config == null) {
LOG.severe("JobMasterRequestObject.init method has not been called.");
return null;
}
V1StatefulSet statefulSet = new V1StatefulSet();
String statefulSetName = KubernetesUtils.createJobMasterStatefulSetName(jobID);
// set labels for the jm stateful set
HashMap<String, String> labels = KubernetesUtils.createJobLabels(jobID);
// job master statefulset
labels.put("t2-mss", jobID);
// construct metadata and set for jobID setting
V1ObjectMeta meta = new V1ObjectMeta();
meta.setName(statefulSetName);
meta.setLabels(labels);
statefulSet.setMetadata(meta);
// construct JobSpec and set
V1StatefulSetSpec setSpec = new V1StatefulSetSpec();
setSpec.serviceName(KubernetesUtils.createJobMasterServiceName(jobID));
setSpec.setReplicas(1);
// add selector for the job
V1LabelSelector selector = new V1LabelSelector();
selector.putMatchLabelsItem("t2-mp", jobID);
setSpec.setSelector(selector);
// construct the pod template
V1PodTemplateSpec template = constructPodTemplate();
setSpec.setTemplate(template);
statefulSet.setSpec(setSpec);
return statefulSet;
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method createPersistentVolumeObject.
/**
* we initially used this method to create PersistentVolumes
* we no longer use this method
* it is just here in case we may need it for some reason at one point
*/
public static V1PersistentVolume createPersistentVolumeObject(String pvName) {
V1PersistentVolume pv = new V1PersistentVolume();
pv.setApiVersion("v1");
// set pv name
V1ObjectMeta meta = new V1ObjectMeta();
meta.setName(pvName);
pv.setMetadata(meta);
// double volumeSize = SchedulerContext.persistentVolumeTotal(config);
V1PersistentVolumeSpec pvSpec = new V1PersistentVolumeSpec();
HashMap<String, Quantity> capacity = new HashMap<>();
// capacity.put("storage", new Quantity(volumeSize + "Gi"));
pvSpec.setCapacity(capacity);
String storageClass = KubernetesContext.persistentStorageClass(config);
String accessMode = KubernetesContext.storageAccessMode(config);
// String reclaimPolicy = KubernetesContext.storageReclaimPolicy(config);
pvSpec.setStorageClassName(storageClass);
pvSpec.setAccessModes(Arrays.asList(accessMode));
// pvSpec.setPersistentVolumeReclaimPolicy(reclaimPolicy);
// pvSpec.setMountOptions(Arrays.asList("hard", "nfsvers=4.1"));
V1NFSVolumeSource nfsVolumeSource = new V1NFSVolumeSource();
nfsVolumeSource.setServer(SchedulerContext.nfsServerAddress(config));
nfsVolumeSource.setPath(SchedulerContext.nfsServerPath(config));
pvSpec.setNfs(nfsVolumeSource);
pv.setSpec(pvSpec);
return pv;
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project twister2 by DSC-SPIDAL.
the class RequestObjectBuilder method createNodePortServiceObject.
/**
* create service for NodePort
* @return
*/
public static V1Service createNodePortServiceObject() {
String serviceName = KubernetesUtils.createServiceName(jobID);
int workerPort = KubernetesContext.workerBasePort(config);
int nodePort = KubernetesContext.serviceNodePort(config);
String protocol = KubernetesContext.workerTransportProtocol(config);
V1Service service = new V1Service();
service.setKind("Service");
service.setApiVersion("v1");
// set labels for the worker services
HashMap<String, String> labels = KubernetesUtils.createJobLabels(jobID);
// construct and set metadata
V1ObjectMeta meta = new V1ObjectMeta();
meta.setName(serviceName);
meta.setLabels(labels);
service.setMetadata(meta);
// construct and set service spec
V1ServiceSpec serviceSpec = new V1ServiceSpec();
// ClusterIP needs to be None for headless service
serviceSpec.setType("NodePort");
// set selector
HashMap<String, String> selectors = new HashMap<String, String>();
selectors.put("t2-wp", jobID);
serviceSpec.setSelector(selectors);
ArrayList<V1ServicePort> ports = new ArrayList<V1ServicePort>();
V1ServicePort servicePort = new V1ServicePort();
servicePort.setPort(workerPort);
servicePort.setProtocol(protocol);
// servicePort.setTargetPort(new IntOrString("port11"));
if (nodePort != 0) {
servicePort.nodePort(nodePort);
}
ports.add(servicePort);
serviceSpec.setPorts(ports);
service.setSpec(serviceSpec);
return service;
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project heron by twitter.
the class V1Controller method createTopologyService.
/**
* Creates a headless <code>Service</code> to facilitate communication between Pods in a <code>topology</code>.
* @return A fully configured <code>Service</code> to be used by a <code>topology</code>.
*/
private V1Service createTopologyService() {
final String topologyName = getTopologyName();
final V1Service service = new V1Service();
// Setup service metadata.
final V1ObjectMeta objectMeta = new V1ObjectMeta().name(topologyName).annotations(getServiceAnnotations()).labels(getServiceLabels());
service.setMetadata(objectMeta);
// Create the headless service.
final V1ServiceSpec serviceSpec = new V1ServiceSpec().clusterIP("None").selector(getPodMatchLabels(topologyName));
service.setSpec(serviceSpec);
return service;
}
use of io.kubernetes.client.openapi.models.V1ObjectMeta in project pravega by pravega.
the class AbstractService method authSecret.
private V1Secret authSecret() {
Map<String, String> dataMap = new HashMap<>();
dataMap.put("password.txt", "YWRtaW46MzUzMDMwMzAzYTM4MzYzNTM0MzE2MTYxNjQ2NDMyMzE2MTM4MzkzMjM4NjQzNzYxMzgzMTMxMzQzOTYxMzA2MTM4NjQ2NDM3MzQ2MjM2NjU2MjM0NjIzMTMwMzgzNTYzNjIzMDMyMzE2NjY2NjQzNzY0NjMzMjM1NjMzMDM0MzA2MzM0NjE2MjY1M2E2MTY1MzEzNDM4MzkzNDM5MzQzMzMyMzczOTMyMzgzNzMyNjU2MTYxNjQ2NjMyNjEzNDM5NjQzMzY2NjM2MTY0MzkzNDY2NjU2MjY1NjE2NTY0MzA2NDYxMzMzNDM2NjIzNzMxMzE2MzM5MzIzOTM1MzQzMzM1NjI2MzY2NjY2NTY1MzUzNjMzNjM2NjM1NjEzNzM0MzQ2MTY2MzczMzYxMzEzMTMxNjYzMDM4MzAzNjM1MzkzMDM0MzQ2NjM0Mzc2NDMyMzYzOTM5MzA2NDM5Mzk2NTM4NjUzMTYyMzMzNDM4MzU2NDY1MzE2MzMxMzgzMjYzMzMzMTY2NjQ2MTMxOiosUkVBRF9VUERBVEUKdGVzdHJlYWQ6MzUzMDMwMzAzYTYxMzM2MTM2NjYzOTMwMzg2NjMxMzg2MjMxMzIzOTY1NjMzMTM5NjMzNjMyNjM2MzMxMzYzNzM5MzQ2MTY1NjUzNzYzNjQzOTYzNjUzNjYzMzMzNDMwNjIzNjMxMzM2NjM0NjIzNDMxNjIzNTMxNjQzNTY0MzY2NDY1NjY2MzYyM2E2NTYzNjYzNzY1NjE2MjM4NjYzMzY2NjQzMDMzMzI2NjMwNjQ2NDM1NjQzOTYyMzczNjM3Mzg2NTYyMzY2MzY2NjUzMDM4MzgzNDYxMzAzMDM2NjMzODMzNjUzMjYxMzc2MTYzMzIzODMyNjMzNDMzMzc2NjMyNjIzNTY2NjMzNjMyMzc2NDYyNjUzODM4MzEzMjM5MzAzNzM2MzgzOTM1MzAzMjM2NjE2NjYzMzczNzMwMzk2NjMwMzAzNDM4MzMzMDMxNjQzOTYyMzk2NTM5NjMzMjY1NjQzODM4MzY2MTYxMzAzNjMxMzU2MTM1NjIzNDMxMzIzOTM1NjUzMDY1OiosUkVBRAoK");
return new V1SecretBuilder().withStringData(dataMap).withApiVersion("v1").withKind("Secret").withMetadata(new V1ObjectMeta().name(SECRET_NAME_USED_FOR_AUTH)).withType("Opaque").withStringData(dataMap).build();
}
Aggregations