use of io.fabric8.kubernetes.api.model.DoneablePersistentVolume in project camel by apache.
the class KubernetesPersistentVolumesProducer method doListPersistentVolumesByLabels.
protected void doListPersistentVolumesByLabels(Exchange exchange, String operation) throws Exception {
PersistentVolumeList pvList = null;
Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_LABELS, Map.class);
NonNamespaceOperation<PersistentVolume, PersistentVolumeList, DoneablePersistentVolume, Resource<PersistentVolume, DoneablePersistentVolume>> pvs;
pvs = getEndpoint().getKubernetesClient().persistentVolumes();
for (Map.Entry<String, String> entry : labels.entrySet()) {
pvs.withLabel(entry.getKey(), entry.getValue());
}
pvList = pvs.list();
MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
exchange.getOut().setBody(pvList.getItems());
}
use of io.fabric8.kubernetes.api.model.DoneablePersistentVolume in project syndesis-qe by syndesisio.
the class OperatorValidationSteps method createPv.
@Given("create test persistent volumes with {string} storage class name")
public void createPv(String className) {
// Create 3 PVs, two with higher capacity that will be used by meta and prometheus, because the binding of PV is FCFS,
// so they theoretically can steal the test-pv from db
// These volumes won't work, but they will be available to bind
Map<String, Quantity> capacity = new HashMap<>();
capacity.put("storage", new Quantity("3Gi"));
if (!"".equals(className) && OpenShiftUtils.getInstance().storage().storageClasses().withName(className).get() == null) {
log.info("Creating storage class " + className);
OpenShiftUtils.getInstance().storage().storageClasses().createOrReplaceWithNew().withNewMetadata().withName(className).endMetadata().withProvisioner("kubernetes.io/cinder").done();
}
PersistentVolumeFluent.SpecNested<DoneablePersistentVolume> pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME).withLabels(TestUtils.map("operator", "test")).endMetadata().withNewSpec().withAccessModes("ReadOnlyMany", "ReadWriteOnce", "ReadWriteMany").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
// The default storage class for OCP3 is empty, for OCP4 is "standard", so if the className is empty, we should use the default one
if ("".equals(className)) {
if (!OpenShiftUtils.isOpenshift3()) {
if (OpenShiftUtils.isOSD()) {
pv.withStorageClassName("gp2");
} else {
pv.withStorageClassName("standard");
}
}
} else {
pv.withStorageClassName(className);
}
pv.endSpec().done();
capacity.put("storage", new Quantity("5Gi"));
for (int i = 1; i < 3; i++) {
pv = OpenShiftUtils.getInstance().persistentVolumes().createOrReplaceWithNew().withNewMetadata().withName(TEST_PV_NAME + "-" + i).endMetadata().withNewSpec().withAccessModes("ReadWriteOnce").withCapacity(capacity).withNewNfs().withNewServer("testServer").withNewPath("/testPath").endNfs();
if (!OpenShiftUtils.isOpenshift3()) {
// This should always be the default value despite the actual value of className - that is used only in "test-pv" intentionally
if (OpenShiftUtils.isOSD()) {
pv.withStorageClassName("gp2");
} else {
pv.withStorageClassName("standard");
}
}
pv.endSpec().done();
}
}
Aggregations