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


Java ObjectMeta.setName方法代码示例

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


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

示例1: createService

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Service createService(final String namespace,
                                final String serviceName,
                                Map<String, String> labels) {
  labels = normalizeLabels(labels);

  final Service service = new Service();
  
  final ObjectMeta metadata = new ObjectMeta();
  metadata.setNamespace(normalizeNamespace(namespace));
  metadata.setName(normalizeServiceName(serviceName));
  metadata.setLabels(labels);
  
  service.setMetadata(metadata);
  service.setSpec(this.createServiceSpec(labels));

  return service;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:18,代码来源:TillerInstaller.java

示例2: createDeployment

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Deployment createDeployment(String namespace,
                                      final String deploymentName,
                                      Map<String, String> labels,
                                      final String serviceAccountName,
                                      final String imageName,
                                      final ImagePullPolicy imagePullPolicy,
                                      final boolean hostNetwork,
                                      final boolean tls,
                                      final boolean verifyTls) {
  namespace = normalizeNamespace(namespace);
  labels = normalizeLabels(labels);

  final Deployment deployment = new Deployment();

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setNamespace(namespace);
  metadata.setName(normalizeDeploymentName(deploymentName));
  metadata.setLabels(labels);
  deployment.setMetadata(metadata);

  deployment.setSpec(this.createDeploymentSpec(labels, serviceAccountName, imageName, imagePullPolicy, namespace, hostNetwork, tls, verifyTls));
  return deployment;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:24,代码来源:TillerInstaller.java

示例3: newPod

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private Pod newPod(String uid, String namespace, String name, String node) {
    Pod pod = new Pod();

    ObjectMeta objMeta = new ObjectMeta();
    objMeta.setName(name);
    objMeta.setNamespace(namespace);
    objMeta.setUid(uid);

    PodSpec spec = new PodSpec();
    spec.setNodeName(node);

    pod.setMetadata(objMeta);
    pod.setSpec(spec);

    return pod;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:17,代码来源:KubernetesPodApiTest.java

示例4: fakeServiceAccountKeySecret

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private static Secret fakeServiceAccountKeySecret(String serviceAccount, long epoch, String jsonKeyId,
    String p12KeyId, String creationTimestamp) {
  final String jsonKeyName = keyName(serviceAccount, jsonKeyId);
  final String p12KeyName = keyName(serviceAccount, p12KeyId);

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setCreationTimestamp(creationTimestamp);
  metadata.setName("styx-wf-sa-keys-" + epoch + "-" + Hashing.sha256().hashString(serviceAccount, UTF_8));
  metadata.setAnnotations(ImmutableMap.of(
      "styx-wf-sa", serviceAccount,
      "styx-wf-sa-json-key-name", jsonKeyName,
      "styx-wf-sa-p12-key-name", p12KeyName));

  return new SecretBuilder()
      .withMetadata(metadata)
      .withData(ImmutableMap.of(
          "styx-wf-sa.json", "json-private-key-data",
          "styx-wf-sa.p12", "p12-private-key-data"))
      .build();
}
 
开发者ID:spotify,项目名称:styx,代码行数:21,代码来源:KubernetesGCPServiceAccountSecretManagerTest.java

示例5: provision

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Override
public void provision(OpenShiftEnvironment osEnv, RuntimeIdentity identity)
    throws InfrastructureException {
  final String workspaceId = identity.getWorkspaceId();
  final Set<Pod> pods = new HashSet<>(osEnv.getPods().values());
  osEnv.getPods().clear();
  for (Pod pod : pods) {
    final ObjectMeta podMeta = pod.getMetadata();
    putLabel(pod, Constants.CHE_ORIGINAL_NAME_LABEL, podMeta.getName());
    final String podName = Names.uniquePodName(podMeta.getName(), workspaceId);
    podMeta.setName(podName);
    osEnv.getPods().put(podName, pod);
  }
  final Set<Route> routes = new HashSet<>(osEnv.getRoutes().values());
  osEnv.getRoutes().clear();
  for (Route route : routes) {
    final ObjectMeta routeMeta = route.getMetadata();
    putLabel(route, Constants.CHE_ORIGINAL_NAME_LABEL, routeMeta.getName());
    final String routeName = Names.uniqueRouteName();
    routeMeta.setName(routeName);
    osEnv.getRoutes().put(routeName, route);
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:UniqueNamesProvisioner.java

示例6: getNodes

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Override
public NodeList getNodes() {
    // TODO we should replace HostNode with Node...
    NodeList answer = new NodeList();
    List<Node> items = new ArrayList<>();
    answer.setItems(items);
    Collection<HostNode> values = getHostNodes().values();
    for (HostNode value : values) {
        Node minion = new Node();
        NodeSpec nodeSpec = new NodeSpec();
        minion.setSpec(nodeSpec);
        ObjectMeta metadata = new ObjectMeta();
        metadata.setName(value.getId());
        minion.setMetadata(metadata);
        // TODO no hostName on a minion
        //minion.setHostIP(value.getHostName());
        items.add(minion);
    }
    return answer;
}
 
开发者ID:fabric8io,项目名称:jube,代码行数:21,代码来源:ApiMasterService.java

示例7: createSecret

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
protected Secret createSecret(final String namespace,
                              final URI tlsKeyUri,
                              final URI tlsCertUri,
                              final URI tlsCaCertUri,
                              final Map<String, String> labels)
  throws IOException {
  
  final Secret secret = new Secret();
  secret.setType("Opaque");

  final Map<String, String> secretData = new HashMap<>();
  
  try (final InputStream tlsKeyStream = read(tlsKeyUri)) {
    if (tlsKeyStream != null) {
      secretData.put("tls.key", Base64.getEncoder().encodeToString(toByteArray(tlsKeyStream)));
    }
  }

  try (final InputStream tlsCertStream = read(tlsCertUri)) {
    if (tlsCertStream != null) {
      secretData.put("tls.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCertStream)));
    }
  }
  
  try (final InputStream tlsCaCertStream = read(tlsCaCertUri)) {
    if (tlsCaCertStream != null) {
      secretData.put("ca.crt", Base64.getEncoder().encodeToString(toByteArray(tlsCaCertStream)));
    }
  }

  secret.setData(secretData);

  final ObjectMeta metadata = new ObjectMeta();
  metadata.setNamespace(normalizeNamespace(namespace));
  metadata.setName(SECRET_NAME);
  metadata.setLabels(normalizeLabels(labels));
  secret.setMetadata(metadata);
  
  return secret;
}
 
开发者ID:microbean,项目名称:microbean-helm,代码行数:41,代码来源:TillerInstaller.java

示例8: newDeployment

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
private Deployment newDeployment(String uid, String namespace, String name, int desiredReplicaCount, String containerImageName) {
    Deployment deployment = new Deployment();

    ObjectMeta objMeta = new ObjectMeta();
    objMeta.setName(name);
    objMeta.setNamespace(namespace);
    objMeta.setUid(uid);

    DeploymentSpec spec = new DeploymentSpec();
    spec.setReplicas(desiredReplicaCount);

    Container container = new Container();
    container.setImage(containerImageName);

    PodSpec podSpec = new PodSpec();
    podSpec.setContainers(Arrays.asList(container));

    PodTemplateSpec podTemplateSpec = new PodTemplateSpec();
    podTemplateSpec.setSpec(podSpec);
    spec.setTemplate(podTemplateSpec);

    deployment.setMetadata(objMeta);
    deployment.setSpec(spec);

    DeploymentStatus deploymentStatus = new DeploymentStatus();
    deploymentStatus.setAvailableReplicas(3);
    deployment.setStatus(deploymentStatus);

    return deployment;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:KubernetesDeploymentApiTest.java

示例9: testGetStartedTime

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@Test
public void testGetStartedTime() throws Exception {
    KubeCloudImage image = m.mock(KubeCloudImage.class);
    ObjectMeta metadata = new ObjectMeta();
    metadata.setName("foo");
    Pod pod = new Pod("1.0", "kind", metadata, new PodSpec(), new PodStatusBuilder().withStartTime("2017-06-12T22:59Z").build());
    m.checking(new Expectations(){{
        allowing(myApi).getPodStatus(with("foo")); will(returnValue(pod.getStatus()));
    }});
    KubeCloudInstanceImpl instance = new KubeCloudInstanceImpl(image, pod, myApi);
    Date startedTime = instance.getStartedTime();
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
    dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
    assertEquals("2017-06-12T22:59Z", dateFormat.format(startedTime));
}
 
开发者ID:JetBrains,项目名称:teamcity-kubernetes-plugin,代码行数:16,代码来源:KubeCloudInstanceImplTest.java

示例10: createPod

import io.fabric8.kubernetes.api.model.ObjectMeta; //导入方法依赖的package包/类
@VisibleForTesting
Pod createPod(RunSpec runSpec) {
  final String podName = HYPE_RUN + "-" + randomAlphaNumeric(8);
  final RunEnvironment env = runSpec.runEnvironment();
  final List<Secret> secrets = env.secretMounts();
  final StagedContinuation stagedContinuation = runSpec.stagedContinuation();
  final List<VolumeMountInfo> volumeMountInfos = volumeMountInfos(env.volumeMounts());

  final Pod basePod = getBasePod(env, runSpec.image());

  // add metadata name
  final ObjectMeta metadata = basePod.getMetadata() != null
                              ? basePod.getMetadata()
                              : new ObjectMeta();
  metadata.setName(podName);
  basePod.setMetadata(metadata);

  final PodSpec spec = basePod.getSpec();

  // add volumes
  secrets.forEach(s ->
      spec.getVolumes()
          .add(new VolumeBuilder()
              .withName(s.name())
              .withNewSecret()
              .withSecretName(s.name())
              .endSecret()
              .build()));
  volumeMountInfos.stream()
      .map(VolumeMountInfo::volume)
      .forEach(spec.getVolumes()::add);

  final Container container = findHypeRunContainer(basePod);

  // add volume mounts
  secrets.forEach(s ->
      container.getVolumeMounts()
          .add(new VolumeMountBuilder()
              .withName(s.name())
              .withMountPath(s.mountPath())
              .withReadOnly(true)
              .build()));
  volumeMountInfos.stream()
      .map(VolumeMountInfo::volumeMount)
      .forEach(container.getVolumeMounts()::add);

  // set args
  if (container.getArgs().size() > 0) {
    LOG.warn("Overriding " + HYPE_RUN + " container args");
  }
  container.setArgs(singletonList(stagedContinuation.manifestPath().toUri().toString()));

  // add env var
  container.getEnv()
      .add(new EnvVarBuilder()
          .withName(EXECUTION_ID)
          .withValue(podName)
          .build());

  // add resource requests
  final ResourceRequirementsBuilder resourceReqsBuilder = container.getResources() != null
                                                          ? new ResourceRequirementsBuilder(
      container.getResources())
                                                          : new ResourceRequirementsBuilder();
  for (Map.Entry<String, String> request : env.resourceRequests().entrySet()) {
    resourceReqsBuilder.addToRequests(request.getKey(), new Quantity(request.getValue()));
  }
  container.setResources(resourceReqsBuilder.build());

  return basePod;
}
 
开发者ID:spotify,项目名称:hype,代码行数:72,代码来源:KubernetesDockerRunner.java


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