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

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

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

Deployment.getStatus介绍

暂无

代码示例

代码示例来源:origin: org.domeos/kubernetes-client

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

代码示例来源:origin: logzio/apollo

public int getScalingFactor(Service service, String groupName) throws ApolloNotFoundException {
  io.fabric8.kubernetes.api.model.extensions.Deployment kubernetesDeployment = getKubernetesDeployment(service, Optional.of(groupName));
  if (kubernetesDeployment == null) {
    throw new ApolloNotFoundException("Could not find deployment for environment " + environment.getId() + ", service "
        + service.getId() + " and group " + groupName + ", can't return the status!");
  }
  return Optional.ofNullable(kubernetesDeployment.getStatus().getAvailableReplicas()).orElse(0);
}

代码示例来源:origin: org.domeos/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: org.apache.brooklyn/brooklyn-locations-container

@Override
public Boolean call() {
  Deployment dep = client.extensions().deployments().inNamespace(namespace).withName(deploymentName).get();
  DeploymentStatus status = (dep == null) ? null : dep.getStatus();
  Integer replicas = (status == null) ? null : status.getAvailableReplicas();
  return replicas != null && replicas.intValue() == replicas;
}

代码示例来源:origin: org.domeos/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: org.apache.brooklyn/brooklyn-locations-container

@Override
  public String getFailureMessage() {
    Deployment dep = client.extensions().deployments().inNamespace(namespace).withName(deploymentName).get();
    DeploymentStatus status = (dep == null) ? null : dep.getStatus();
    return "Namespace=" + namespace + "; deploymentName= " + deploymentName + "; Deployment=" + dep
        + "; status=" + status
        + "; availableReplicas=" + (status == null ? "null" : status.getAvailableReplicas());
  }
};

代码示例来源:origin: logzio/apollo

public KubernetesDeploymentStatus getCurrentStatus(Service service, Optional<String> groupName) {
  io.fabric8.kubernetes.api.model.extensions.Deployment deployment = getKubernetesDeployment(service, groupName);
  if (deployment == null) {
    logger.warn("Could not find deployment for environment {} and service {}, can't return the status!", environment.getId(), service.getId());
    return null;
  }
  List<PodStatus> podStatusList = kubernetesClient
      .pods()
      .inNamespace(environment.getKubernetesNamespace())
      .withLabel(ApolloToKubernetes.getApolloDeploymentUniqueIdentifierKey(),
          ApolloToKubernetes.getApolloPodUniqueIdentifier(environment, service, groupName))
      .list()
      .getItems()
      .stream()
      .map(pod -> pod.getMetadata().getName())
      .map(this::getPodStatus)
      .collect(Collectors.toList());
  KubernetesDeploymentStatus kubernetesDeploymentStatus = new KubernetesDeploymentStatus();
  kubernetesDeploymentStatus.setServiceId(service.getId());
  kubernetesDeploymentStatus.setEnvironmentId(environment.getId());
  kubernetesDeploymentStatus.setGitCommitSha(deployment.getMetadata().getLabels().get(ApolloToKubernetes.getApolloCommitShaKey()));
  kubernetesDeploymentStatus.setReplicas(deployment.getStatus().getReplicas());
  kubernetesDeploymentStatus.setAvailableReplicas(deployment.getStatus().getAvailableReplicas());
  kubernetesDeploymentStatus.setUpdatedReplicas(deployment.getStatus().getUpdatedReplicas());
  kubernetesDeploymentStatus.setUnavailableReplicas(deployment.getStatus().getUnavailableReplicas());
  kubernetesDeploymentStatus.setPodStatuses(podStatusList);
  groupName.ifPresent(kubernetesDeploymentStatus::setGroupName);
  return kubernetesDeploymentStatus;
}

代码示例来源:origin: logzio/apollo

io.fabric8.kubernetes.api.model.extensions.DeploymentStatus deploymentStatus = returnedDeployment.get().getStatus();

代码示例来源:origin: org.domeos/kubernetes-model

public DeploymentBuilder(DeploymentFluent<?> fluent,Deployment instance,Boolean validationEnabled){
    this.fluent = fluent; 
    fluent.withApiVersion(instance.getApiVersion()); 
    fluent.withKind(instance.getKind()); 
    fluent.withMetadata(instance.getMetadata()); 
    fluent.withSpec(instance.getSpec()); 
    fluent.withStatus(instance.getStatus()); 
    this.validationEnabled = validationEnabled; 
}
public DeploymentBuilder(Deployment instance){

代码示例来源:origin: org.domeos/kubernetes-model

public DeploymentBuilder(Deployment instance,Boolean validationEnabled){
    this.fluent = this; 
    this.withApiVersion(instance.getApiVersion()); 
    this.withKind(instance.getKind()); 
    this.withMetadata(instance.getMetadata()); 
    this.withSpec(instance.getSpec()); 
    this.withStatus(instance.getStatus()); 
    this.validationEnabled = validationEnabled; 
}

代码示例来源:origin: org.domeos/kubernetes-model

public DeploymentFluentImpl(Deployment instance){
    this.withApiVersion(instance.getApiVersion()); 
    this.withKind(instance.getKind()); 
    this.withMetadata(instance.getMetadata()); 
    this.withSpec(instance.getSpec()); 
    this.withStatus(instance.getStatus()); 
}

代码示例来源:origin: org.domeos/kubernetes-client

@Override
public boolean reap() {
 Deployment deployment = oper.cascading(false).edit().editSpec().withReplicas(0).endSpec().done();
 waitForObservedGeneration(deployment.getStatus().getObservedGeneration());
 reapMatchingReplicaSets(deployment.getSpec().getSelector());
 return false;
}

相关文章