当前位置: 首页>>代码示例>>Java>>正文


Java PodSpec.getContainers方法代码示例

本文整理汇总了Java中io.fabric8.kubernetes.api.model.PodSpec.getContainers方法的典型用法代码示例。如果您正苦于以下问题:Java PodSpec.getContainers方法的具体用法?Java PodSpec.getContainers怎么用?Java PodSpec.getContainers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.fabric8.kubernetes.api.model.PodSpec的用法示例。


在下文中一共展示了PodSpec.getContainers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的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

示例2: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {

  for (Pod podConfig : osEnv.getPods().values()) {
    final PodSpec podSpec = podConfig.getSpec();
    for (Container containerConfig : podSpec.getContainers()) {
      String machineName = Names.machineName(podConfig, containerConfig);
      InternalMachineConfig machineConfig = osEnv.getMachines().get(machineName);
      if (!machineConfig.getServers().isEmpty()) {
        ServerExposer serverExposer =
            new ServerExposer(machineName, podConfig, containerConfig, osEnv);
        serverExposer.expose(machineConfig.getServers());
      }
    }
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:ServersConverter.java

示例3: podsAsTable

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的package包/类
protected TablePrinter podsAsTable(PodList pods) {
    TablePrinter table = new TablePrinter();
    table.columns("id", "image(s)", "host", "labels", "status");
    List<Pod> items = pods.getItems();
    if (items == null) {
        items = Collections.EMPTY_LIST;
    }
    Filter<Pod> filter = KubernetesHelper.createPodFilter(filterText.getValue());
    for (Pod item : items) {
        if (filter.matches(item)) {
            String id = KubernetesHelper.getName(item);
            PodStatus podStatus = item.getStatus();
            String status = "";
            String host = "";
            if (podStatus != null) {
                status = KubernetesHelper.getStatusText(podStatus);
                host = podStatus.getHostIP();
            }
            Map<String, String> labelMap = item.getMetadata().getLabels();
            String labels = KubernetesHelper.toLabelsString(labelMap);
            PodSpec spec = item.getSpec();
            if (spec != null) {
                List<Container> containerList = spec.getContainers();
                for (Container container : containerList) {
                    String image = container.getImage();
                    table.row(id, image, host, labels, status);

                    id = "";
                    host = "";
                    status = "";
                    labels = "";
                }
            }
        }
    }
    return table;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:38,代码来源:PodsList.java

示例4: provision

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的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

示例5: getOrCreatePodDesiredContainers

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的package包/类
public static List<Container> getOrCreatePodDesiredContainers(Pod pod) {
    PodSpec podSpec = NodeHelper.getOrCreatePodSpec(pod);
    List<Container> containers = podSpec.getContainers();
    if (containers == null) {
        containers = new ArrayList<>();
        podSpec.setContainers(containers);
    }
    return containers;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:10,代码来源:NodeHelper.java

示例6: executePod

import io.fabric8.kubernetes.api.model.PodSpec; //导入方法依赖的package包/类
@Override
protected void executePod(Pod podInfo, String podId) {
    System.out.println("Created: " + podInfo.getMetadata().getCreationTimestamp());
    System.out.println("Labels: ");
    Map<String, String> labels = podInfo.getMetadata().getLabels();
    for (Map.Entry<String, String> entry : labels.entrySet()) {
        System.out.println(indent + entry.getKey() + " = " + entry.getValue());
    }
    PodStatus currentState = podInfo.getStatus();
    if (currentState != null) {
        printValue("Host", currentState.getHostIP());
        printValue("IP", currentState.getPodIP());
        printValue("Status", getStatusText(currentState));
    }
    PodSpec spec = podInfo.getSpec();
    if (spec != null) {
        List<Container> containers = spec.getContainers();
        if (notEmpty(containers)) {
            System.out.println("Containers:");
            indentCount++;
            for (Container container : containers) {
                printValue("Name", container.getName());
                printValue("Image", container.getImage());
                printValue("Working Dir", container.getWorkingDir());
                printValue("Command", container.getCommand());

                List<ContainerPort> ports = container.getPorts();
                if (notEmpty(ports)) {
                    println("Ports:");
                    indentCount++;
                    for (ContainerPort port : ports) {
                        printValue("Name", port.getName());
                        printValue("Protocol", port.getProtocol());
                        printValue("Host Port", port.getHostPort());
                        printValue("Container Port", port.getContainerPort());
                    }
                    indentCount--;
                }

                List<EnvVar> envList = container.getEnv();
                if (notEmpty(envList)) {
                    println("Environment:");
                    indentCount++;
                    for (EnvVar env : envList) {
                        printValue(env.getName(), env.getValue());
                    }
                    indentCount--;
                }
                List<VolumeMount> volumeMounts = container.getVolumeMounts();
                if (notEmpty(volumeMounts)) {
                    println("Volume Mounts:");
                    indentCount++;
                    for (VolumeMount volumeMount : volumeMounts) {
                        printValue("Name", volumeMount.getName());
                        printValue("Mount Path", volumeMount.getMountPath());
                        printValue("Read Only", volumeMount.getReadOnly());
                    }
                    indentCount--;
                }
            }
        }

        List<Volume> volumes = spec.getVolumes();
        if (volumes != null) {
            System.out.println("Volumes: ");
            for (Volume volume : volumes) {
                System.out.println(indent + volume.getName());
            }
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:72,代码来源:PodInfo.java


注:本文中的io.fabric8.kubernetes.api.model.PodSpec.getContainers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。