本文整理汇总了Java中io.fabric8.kubernetes.api.model.PersistentVolumeClaim类的典型用法代码示例。如果您正苦于以下问题:Java PersistentVolumeClaim类的具体用法?Java PersistentVolumeClaim怎么用?Java PersistentVolumeClaim使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PersistentVolumeClaim类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了PersistentVolumeClaim类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: volumeMountInfo
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
private VolumeMountInfo volumeMountInfo(PersistentVolumeClaim claim, VolumeMount volumeMount) {
final String claimName = claim.getMetadata().getName();
final Volume volume = new VolumeBuilder()
.withName(claimName)
.withNewPersistentVolumeClaim(claimName, volumeMount.readOnly())
.build();
final io.fabric8.kubernetes.api.model.VolumeMount mount = new VolumeMountBuilder()
.withName(claimName)
.withMountPath(volumeMount.mountPath())
.withReadOnly(volumeMount.readOnly())
.build();
final String ro = volumeMount.readOnly() ? "readOnly" : "readWrite";
LOG.info("Mounting {} {} at {}", claimName, ro, volumeMount.mountPath());
return new VolumeMountInfoBuilder()
.persistentVolumeClaim(claim)
.volume(volume)
.volumeMount(mount)
.build();
}
开发者ID:spotify,项目名称:hype,代码行数:24,代码来源:KubernetesDockerRunner.java
示例2: build
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Override
public PersistentVolumeClaim build() {
ObjectMetaBuilder meta = new ObjectMetaBuilder()
.withName(getName());
return new PersistentVolumeClaimBuilder()
.withMetadata(metadataBuilder().build())
// spec
.withNewSpec()
.withAccessModes(accessMode.toString())
.withNewResources()
.withRequests(Collections.singletonMap("storage", new Quantity(storageRequest)))
.endResources()
.endSpec()
// build
.build();
}
开发者ID:xtf-cz,项目名称:xtf,代码行数:20,代码来源:PVCBuilder.java
示例3: doGetPersistentVolumeClaim
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
protected void doGetPersistentVolumeClaim(Exchange exchange,
String operation) throws Exception {
PersistentVolumeClaim pvc = null;
String pvcName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME,
String.class);
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
if (ObjectHelper.isEmpty(pvcName)) {
LOG.error("Get a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
throw new IllegalArgumentException(
"Get a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Get a specific Persistent Volume Claim require specify a namespace name");
throw new IllegalArgumentException(
"Get a specific Persistent Volume Claim require specify a namespace name");
}
pvc = getEndpoint().getKubernetesClient().persistentVolumeClaims()
.inNamespace(namespaceName).withName(pvcName).get();
exchange.getOut().setBody(pvc);
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:KubernetesPersistentVolumesClaimsProducer.java
示例4: provision
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
throws InfrastructureException {
final String workspaceId = identity.getWorkspaceId();
final Set<String> subPaths = new HashSet<>();
final PersistentVolumeClaim pvc = newPVC(pvcName, pvcAccessMode, pvcQuantity);
osEnv.getPersistentVolumeClaims().put(pvcName, pvc);
for (Pod pod : osEnv.getPods().values()) {
PodSpec podSpec = pod.getSpec();
for (Container container : podSpec.getContainers()) {
String machineName = Names.machineName(pod, container);
InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
addMachineVolumes(workspaceId, subPaths, podSpec, container, machineConfig);
}
}
if (preCreateDirs && !subPaths.isEmpty()) {
pvc.setAdditionalProperty(
format(SUBPATHS_PROPERTY_FMT, workspaceId),
subPaths.toArray(new String[subPaths.size()]));
}
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:CommonPVCStrategy.java
示例5: prepare
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Override
public void prepare(OpenShiftEnvironment osEnv, String workspaceId)
throws InfrastructureException {
final Collection<PersistentVolumeClaim> claims = osEnv.getPersistentVolumeClaims().values();
if (!claims.isEmpty()) {
final OpenShiftProject project = factory.create(workspaceId);
final OpenShiftPersistentVolumeClaims pvcs = project.persistentVolumeClaims();
final Set<String> existing =
pvcs.get().stream().map(p -> p.getMetadata().getName()).collect(toSet());
for (PersistentVolumeClaim pvc : claims) {
final String[] subpaths =
(String[])
pvc.getAdditionalProperties().remove(format(SUBPATHS_PROPERTY_FMT, workspaceId));
if (!existing.contains(pvc.getMetadata().getName())) {
pvcs.create(pvc);
}
if (preCreateDirs && subpaths != null) {
pvcSubPathHelper.createDirs(workspaceId, subpaths);
}
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:CommonPVCStrategy.java
示例6: addMachineVolumes
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
private void addMachineVolumes(
String workspaceId,
Map<String, PersistentVolumeClaim> claims,
PodSpec podSpec,
Container container,
InternalMachineConfig machineConfig) {
if (machineConfig.getVolumes().isEmpty()) {
return;
}
for (Entry<String, Volume> volumeEntry : machineConfig.getVolumes().entrySet()) {
String volumeName = volumeEntry.getKey();
String volumePath = volumeEntry.getValue().getPath();
String subPath = workspaceId + '/' + volumeName;
String pvcUniqueName = pvcNamePrefix + '-' + workspaceId + '-' + volumeName;
PersistentVolumeClaim newPVC = newPVC(pvcUniqueName, pvcAccessMode, pvcQuantity);
putLabel(newPVC, CHE_WORKSPACE_ID_LABEL, workspaceId);
claims.put(pvcUniqueName, newPVC);
container.getVolumeMounts().add(newVolumeMount(pvcUniqueName, volumePath, subPath));
addVolumeIfAbsent(podSpec, pvcUniqueName);
}
}
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:UniqueWorkspacePVCStrategy.java
示例7: testProvisionPVCWithUniqueName
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void testProvisionPVCWithUniqueName() throws Exception {
when(osEnv.getPersistentVolumeClaims()).thenReturn(new HashMap<>());
strategy.provision(osEnv, IDENTITY);
assertEquals(podSpec.getVolumes().size(), 2);
assertEquals(podSpec2.getVolumes().size(), 1);
assertEquals(container.getVolumeMounts().size(), 2);
assertEquals(container2.getVolumeMounts().size(), 1);
assertEquals(container3.getVolumeMounts().size(), 1);
assertEquals(osEnv.getPersistentVolumeClaims().size(), 2);
PersistentVolumeClaim pvc1 =
osEnv.getPersistentVolumeClaims().get(PVC_UNIQUE_NAME + '-' + VOLUME_1_NAME);
assertNotNull(pvc1);
assertEquals(pvc1.getMetadata().getLabels().get(CHE_WORKSPACE_ID_LABEL), WORKSPACE_ID);
PersistentVolumeClaim pvc2 =
osEnv.getPersistentVolumeClaims().get(PVC_UNIQUE_NAME + '-' + VOLUME_2_NAME);
assertNotNull(pvc2);
assertEquals(pvc2.getMetadata().getLabels().get(CHE_WORKSPACE_ID_LABEL), WORKSPACE_ID);
}
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:UniqueWorkspacePVCStrategyTest.java
示例8: testDoNotAddsSubpathsWhenPreCreationIsNotNeeded
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void testDoNotAddsSubpathsWhenPreCreationIsNotNeeded() throws Exception {
commonPVCStrategy =
new CommonPVCStrategy(
PVC_NAME, PVC_QUANTITY, PVC_ACCESS_MODE, false, pvcSubPathHelper, factory);
commonPVCStrategy.provision(osEnv, IDENTITY);
final Map<String, PersistentVolumeClaim> actual = osEnv.getPersistentVolumeClaims();
assertFalse(actual.isEmpty());
assertTrue(actual.containsKey(PVC_NAME));
assertFalse(
actual
.get(PVC_NAME)
.getAdditionalProperties()
.containsKey(format(SUBPATHS_PROPERTY_FMT, WORKSPACE_ID)));
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:CommonPVCStrategyTest.java
示例9: createClaim
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
private PersistentVolumeClaim createClaim(VolumeRequest volumeRequest) {
final ClaimRequest spec = volumeRequest.spec();
if (spec.useExisting()) {
final String claimName = volumeRequest.id();
final PersistentVolumeClaim existingClaim =
client.persistentVolumeClaims().withName(claimName).get();
if (existingClaim != null) {
return existingClaim;
}
}
final ResourceRequirements resources = new ResourceRequirementsBuilder()
.addToRequests("storage", new Quantity(spec.size()))
.build();
final PersistentVolumeClaim claimTemplate = new PersistentVolumeClaimBuilder()
.withNewMetadata()
.withName(volumeRequest.id())
.addToAnnotations(STORAGE_CLASS_ANNOTATION, spec.storageClass())
.endMetadata()
.withNewSpec()
// todo: storageClassName: <class> // in 1.6
.withAccessModes(READ_WRITE_ONCE, READ_ONLY_MANY)
.withResources(resources)
.endSpec()
.build();
final PersistentVolumeClaim claim = client.persistentVolumeClaims().create(claimTemplate);
LOG.info("Created PersistentVolumeClaim {} for {}",
claim.getMetadata().getName(),
volumeRequest);
return claim;
}
开发者ID:spotify,项目名称:hype,代码行数:37,代码来源:VolumeRepository.java
示例10: close
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Override
public void close() throws IOException {
final List<PersistentVolumeClaim> toDelete = claims.entrySet().stream()
.filter(e -> !e.getKey().keep())
.map(Map.Entry::getValue)
.collect(toList());
client.persistentVolumeClaims().delete(toDelete);
}
开发者ID:spotify,项目名称:hype,代码行数:10,代码来源:VolumeRepository.java
示例11: volumeMountInfos
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
private List<VolumeMountInfo> volumeMountInfos(List<VolumeMount> volumeMounts) {
final Map<VolumeRequest, PersistentVolumeClaim> claims = volumeMounts.stream()
.map(VolumeMount::volumeRequest)
.distinct()
.collect(toMap(identity(), volumeRepository::getClaim));
return volumeMounts.stream()
.map(volumeMount -> volumeMountInfo(claims.get(volumeMount.volumeRequest()), volumeMount))
.collect(toList());
}
开发者ID:spotify,项目名称:hype,代码行数:11,代码来源:KubernetesDockerRunner.java
示例12: createsNewVolumeClaim
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void createsNewVolumeClaim() throws Exception {
VolumeRequest request = VolumeRequest.volumeRequest("storage-class-name", "16Gi");
PersistentVolumeClaim claim = volumeRepository.getClaim(request);
assertThat(claim.getMetadata().getName(), equalTo(request.id()));
assertThat(
claim.getMetadata().getAnnotations(),
hasEntry(VolumeRepository.STORAGE_CLASS_ANNOTATION, "storage-class-name"));
assertThat(claim.getSpec().getAccessModes(), contains("ReadWriteOnce", "ReadOnlyMany"));
assertThat(
claim.getSpec().getResources().getRequests(),
hasEntry("storage", new Quantity("16Gi")));
}
开发者ID:spotify,项目名称:hype,代码行数:15,代码来源:VolumeRepositoryTest.java
示例13: returnsExistingClaim
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void returnsExistingClaim() throws Exception {
VolumeRequest request = VolumeRequest.createIfNotExists("name", "class", "16Gi");
PersistentVolumeClaim claim = volumeRepository.getClaim(request);
assertThat(claim, is(mockPvc));
}
开发者ID:spotify,项目名称:hype,代码行数:8,代码来源:VolumeRepositoryTest.java
示例14: createWhenExistingClaimNotFound
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void createWhenExistingClaimNotFound() throws Exception {
VolumeRequest request = VolumeRequest.createIfNotExists("new-claim", "class", "16Gi");
PersistentVolumeClaim claim = volumeRepository.getClaim(request);
assertThat(claim, not(mockPvc));
assertThat(
claim.getSpec().getResources().getRequests(),
hasEntry("storage", new Quantity("16Gi")));
}
开发者ID:spotify,项目名称:hype,代码行数:11,代码来源:VolumeRepositoryTest.java
示例15: deletesClaimsOnClose
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void deletesClaimsOnClose() throws Exception {
VolumeRequest request1 = VolumeRequest.volumeRequest("storage-class-name", "16Gi").keepOnExit();
VolumeRequest request2 = VolumeRequest.volumeRequest("storage-class-name", "16Gi");
PersistentVolumeClaim claim1 = volumeRepository.getClaim(request1);
PersistentVolumeClaim claim2 = volumeRepository.getClaim(request2);
volumeRepository.close();
assertThat(deletedPvcs.getValue(), contains(claim2));
}
开发者ID:spotify,项目名称:hype,代码行数:11,代码来源:VolumeRepositoryTest.java
示例16: doCreatePersistentVolumeClaim
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
protected void doCreatePersistentVolumeClaim(Exchange exchange,
String operation) throws Exception {
PersistentVolumeClaim pvc = null;
String pvcName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_NAME,
String.class);
String namespaceName = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
PersistentVolumeClaimSpec pvcSpec = exchange.getIn().getHeader(
KubernetesConstants.KUBERNETES_PERSISTENT_VOLUME_CLAIM_SPEC,
PersistentVolumeClaimSpec.class);
if (ObjectHelper.isEmpty(pvcName)) {
LOG.error("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
throw new IllegalArgumentException(
"Create a specific Persistent Volume Claim require specify a Persistent Volume Claim name");
}
if (ObjectHelper.isEmpty(namespaceName)) {
LOG.error("Create a specific Persistent Volume Claim require specify a namespace name");
throw new IllegalArgumentException(
"Create a specific Persistent Volume Claim require specify a namespace name");
}
if (ObjectHelper.isEmpty(pvcSpec)) {
LOG.error("Create a specific Persistent Volume Claim require specify a Persistent Volume Claim spec bean");
throw new IllegalArgumentException(
"Create a specific Persistent Volume Claim require specify a Persistent Volume Claim spec bean");
}
Map<String, String> labels = exchange
.getIn()
.getHeader(
KubernetesConstants.KUBERNETES_PERSISTENT_VOLUMES_CLAIMS_LABELS,
Map.class);
EditablePersistentVolumeClaim pvcCreating = new PersistentVolumeClaimBuilder()
.withNewMetadata().withName(pvcName).withLabels(labels)
.endMetadata().withSpec(pvcSpec).build();
pvc = getEndpoint().getKubernetesClient().persistentVolumeClaims()
.inNamespace(namespaceName).create(pvcCreating);
exchange.getOut().setBody(pvc);
}
开发者ID:HydAu,项目名称:Camel,代码行数:39,代码来源:KubernetesPersistentVolumesClaimsProducer.java
示例17: listTest
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Test
public void listTest() throws Exception {
if (ObjectHelper.isEmpty(authToken)) {
return;
}
List<PersistentVolumeClaim> result = template.requestBody(
"direct:list", "", List.class);
assertTrue(result.size() == 0);
}
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:KubernetesPersistentVolumesClaimsProducerTest.java
示例18: provision
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
throws InfrastructureException {
final Map<String, PersistentVolumeClaim> claims = osEnv.getPersistentVolumeClaims();
for (Pod pod : osEnv.getPods().values()) {
final PodSpec podSpec = pod.getSpec();
for (Container container : podSpec.getContainers()) {
final String machineName = Names.machineName(pod, container);
InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
addMachineVolumes(identity.getWorkspaceId(), claims, podSpec, container, machineConfig);
}
}
}
开发者ID:eclipse,项目名称:che,代码行数:14,代码来源:UniqueWorkspacePVCStrategy.java
示例19: newPVC
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
/**
* Returns new instance of {@link PersistentVolumeClaim} with specified name, accessMode and
* quantity.
*/
public static PersistentVolumeClaim newPVC(String name, String accessMode, String quantity) {
return new PersistentVolumeClaimBuilder()
.withNewMetadata()
.withName(name)
.endMetadata()
.withNewSpec()
.withAccessModes(accessMode)
.withNewResources()
.withRequests(ImmutableMap.of(STORAGE_PARAM, new Quantity(quantity)))
.endResources()
.endSpec()
.build();
}
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:OpenShiftObjectUtil.java
示例20: create
import io.fabric8.kubernetes.api.model.PersistentVolumeClaim; //导入依赖的package包/类
/**
* Creates specified persistent volume claim.
*
* @param pvc persistent volume claim to create
* @return created persistent volume claim
* @throws InfrastructureException when any exception occurs
*/
public PersistentVolumeClaim create(PersistentVolumeClaim pvc) throws InfrastructureException {
try {
return clientFactory.create().persistentVolumeClaims().inNamespace(namespace).create(pvc);
} catch (KubernetesClientException e) {
throw new InfrastructureException(e.getMessage(), e);
}
}
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:OpenShiftPersistentVolumeClaims.java
注:本文中的io.fabric8.kubernetes.api.model.PersistentVolumeClaim类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论