io.fabric8.kubernetes.api.model.apps.Deployment.getMetadata()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中io.fabric8.kubernetes.api.model.apps.Deployment.getMetadata()方法的一些代码示例,展示了Deployment.getMetadata()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Deployment.getMetadata()方法的具体详情如下:
包路径:io.fabric8.kubernetes.api.model.apps.Deployment
类名称:Deployment
方法名:getMetadata

Deployment.getMetadata介绍

暂无

代码示例

代码示例来源:origin: fabric8io/kubernetes-client

public void run() {
  try {
   Deployment deployment = get();
   //If the deployment is gone, we shouldn't wait.
   if (deployment == null) {
    if (count == 0) {
     queue.put(true);
     return;
    } else {
     queue.put(new IllegalStateException("Can't wait for Deployment: " + checkName(getItem()) + " in namespace: " + checkName(getItem()) + " to scale. Resource is no longer available."));
     return;
    }
   }
   replicasRef.set(deployment.getStatus().getReplicas());
   int currentReplicas = deployment.getStatus().getReplicas() != null ? deployment.getStatus().getReplicas() : 0;
   long generation = deployment.getMetadata().getGeneration() != null ? deployment.getMetadata().getGeneration() : 0;
   long observedGeneration = deployment.getStatus() != null && deployment.getStatus().getObservedGeneration() != null ? deployment.getStatus().getObservedGeneration() : -1;
   if (observedGeneration >= generation && Objects.equals(deployment.getSpec().getReplicas(), currentReplicas)) {
    queue.put(true);
   } else {
    LOG.debug("Only {}/{} pods scheduled for Deployment: {} in namespace: {} seconds so waiting...",
     deployment.getStatus().getReplicas(), deployment.getSpec().getReplicas(), deployment.getMetadata().getName(), namespace);
   }
  } catch (Throwable t) {
   LOG.error("Error while waiting for Deployment to be scaled.", t);
  }
 }
};

代码示例来源:origin: fabric8io/kubernetes-client

log("Created deployment", deployment);
System.err.println("Scaling up:" + deployment.getMetadata().getName());
client.apps().deployments().inNamespace("thisisatest").withName("nginx").scale(2, true);
log("Created replica sets:", client.apps().replicaSets().inNamespace("thisisatest").list().getItems());
System.err.println("Deleting:" + deployment.getMetadata().getName());
client.resource(deployment).delete();

代码示例来源:origin: EnMasseProject/enmasse

/***
 * Check if deployment exists
 * @param namespace kuberntes namespace name
 * @param appName name of deployment
 * @return true if deployment exists
 */
public boolean deploymentExists(String namespace, String appName) {
  return client.apps().deployments().inNamespace(namespace).list().getItems().stream()
      .map(deployment -> deployment.getMetadata().getName()).collect(Collectors.toList()).contains(appName);
}

代码示例来源:origin: EnMasseProject/enmasse

private void checkDeploymentsReady(AddressSpace addressSpace, List<HasMetadata> requiredResources) {
  Set<String> readyDeployments = kubernetes.getReadyDeployments(addressSpace).stream()
      .map(deployment -> deployment.getMetadata().getName())
      .collect(Collectors.toSet());
  Set<String> requiredDeployments = requiredResources.stream()
      .filter(KubernetesHelper::isDeployment)
      .map(item -> item.getMetadata().getName())
      .collect(Collectors.toSet());
  boolean isReady = readyDeployments.containsAll(requiredDeployments);
  if (!isReady) {
    Set<String> missing = new HashSet<>(requiredDeployments);
    missing.removeAll(readyDeployments);
    addressSpace.getStatus().setReady(false);
    addressSpace.getStatus().appendMessage("The following deployments are not ready: " + missing);
  }
}

代码示例来源:origin: EnMasseProject/enmasse

/***
 * Creates application from resources
 * @param namespace
 * @param resources
 * @return String name of application
 * @throws Exception
 */
public String createDeploymentFromResource(String namespace, Deployment resources) throws Exception {
  Deployment depRes = client.apps().deployments().inNamespace(namespace).create(resources);
  Deployment result = client.apps().deployments().inNamespace(namespace)
      .withName(depRes.getMetadata().getName()).waitUntilReady(2, TimeUnit.MINUTES);
  log.info("Deployment {} created", result.getMetadata().getName());
  return result.getMetadata().getName();
}

代码示例来源:origin: org.eclipse.che.infrastructure/infrastructure-openshift

} else if (object instanceof Deployment) {
 Deployment deployment = (Deployment) object;
 deployments.put(deployment.getMetadata().getName(), deployment);
} else if (object instanceof Service) {
 Service service = (Service) object;

代码示例来源:origin: fabric8io/fabric8-maven-plugin

@Override
  public void adapt(KubernetesListBuilder builder) {
    super.adapt(builder);

    List<HasMetadata> items = builder.getItems();
    for (HasMetadata item : items) {
      if (item instanceof Deployment) {
        Deployment deployment = (Deployment) item;
        ObjectMeta metadata = deployment.getMetadata();
        DeploymentSpec spec = deployment.getSpec();
        if (metadata != null && spec != null) {
          PodTemplateSpec template = spec.getTemplate();
          if (template != null) {
            ObjectMeta templateMetadata = template.getMetadata();
            if (templateMetadata == null) {
              templateMetadata = new ObjectMeta();
              template.setMetadata(templateMetadata);
            }
            templateMetadata.setAnnotations(MapUtil.mergeMaps(templateMetadata.getAnnotations(), metadata.getAnnotations()));
          }
        }
      }
    }
    builder.withItems(items);
  }
}

代码示例来源:origin: fabric8io/fabric8-maven-plugin

Deployment resource = (Deployment) item;
DeploymentConfigBuilder builder = new DeploymentConfigBuilder();
builder.withMetadata(resource.getMetadata());
DeploymentSpec spec = resource.getSpec();
if (spec != null) {

相关文章