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

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

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

Deployment.getStatus介绍

暂无

代码示例

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

public void run() {
  Deployment deployment = oper.getMandatory();
  if (observedGeneration <= deployment.getStatus().getObservedGeneration()) {
   countDownLatch.countDown();
  }
 }
};

代码示例来源: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

public static boolean isDeploymentReady(Deployment d) {
 Utils.checkNotNull(d, "Deployment can't be null.");
 DeploymentSpec spec = d.getSpec();
 DeploymentStatus status = d.getStatus();
 if (status == null || status.getReplicas() == null || status.getAvailableReplicas() == null) {
  return false;
 }
 //Can be true in testing, so handle it to make test writing easier.
 if (spec == null || spec.getReplicas() == null) {
  return false;
 }
 return spec.getReplicas().intValue() == status.getReplicas() &&
  spec.getReplicas().intValue() <= status.getAvailableReplicas();
}

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

@Override
public boolean reap() {
 Deployment deployment = oper.cascading(false).edit().editSpec().withReplicas(0).endSpec().done();
 //TODO: These checks shouldn't be used as they are not realistic. We just use them to support mock/crud tests. Need to find a cleaner way to do so.
 if (deployment.getStatus() != null) {
  waitForObservedGeneration(deployment.getStatus().getObservedGeneration());
 }
 if (deployment.getSpec().getSelector() != null) {
  reapMatchingReplicaSets(deployment.getSpec().getSelector());
 }
 return false;
}

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

private static boolean isReady(Deployment deployment) {
  // TODO: Assuming at least one replica is ok
  Integer readyReplicas = deployment.getStatus().getReadyReplicas();
  return readyReplicas != null && readyReplicas >= 1;
}

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

private int findReadyReplicas(List<HasMetadata> items) {
  for (HasMetadata item : items) {
    if (item instanceof StatefulSet) {
      return Optional.ofNullable(((StatefulSet)item).getStatus()).map(StatefulSetStatus::getReadyReplicas).orElse(0);
    } else if (item instanceof Deployment) {
      return Optional.ofNullable(((Deployment)item).getStatus()).map(DeploymentStatus::getReadyReplicas).orElse(0);
    }
  }
  return 0;
}

代码示例来源:origin: org.apache.camel/camel-kubernetes

protected void doScaleDeployment(Exchange exchange, String operation) throws Exception {
    String deploymentName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENT_NAME, String.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    Integer replicasNumber = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_DEPLOYMENT_REPLICAS, Integer.class);
    if (ObjectHelper.isEmpty(deploymentName)) {
      LOG.error("Scale a specific deployment require specify a deployment name");
      throw new IllegalArgumentException("Scale a specific deployment require specify a deployment name");
    }
    if (ObjectHelper.isEmpty(namespaceName)) {
      LOG.error("Scale a specific deployment require specify a namespace name");
      throw new IllegalArgumentException("Scale a specific deployment require specify a namespace name");
    }
    if (ObjectHelper.isEmpty(replicasNumber)) {
      LOG.error("Scale a specific deployment require specify a replicas number");
      throw new IllegalArgumentException("Scale a specific deployment require specify a replicas number");
    }
    Deployment deploymentScaled = getEndpoint().getKubernetesClient().apps().deployments().inNamespace(namespaceName).withName(deploymentName).scale(replicasNumber, false);

    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(deploymentScaled.getStatus().getReplicas());
  }
}

相关文章