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

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

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

Deployment.getSpec介绍

暂无

代码示例

代码示例来源: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: 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: strimzi/strimzi-kafka-operator

@Override
protected Integer currentScale(String namespace, String name) {
  Deployment deployment = get(namespace, name);
  if (deployment != null) {
    return deployment.getSpec().getReplicas();
  } else {
    return null;
  }
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

private int getDeploymentCaCertGeneration(Deployment dep, Ca ca) {
  int caCertGeneration = 0;
  if (dep != null) {
    caCertGeneration =
        Annotations.intAnnotation(
            dep.getSpec().getTemplate(), getCaCertAnnotation(ca), 0);
  }
  return caCertGeneration;
}

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

private int findReplicas(List<HasMetadata> items) {
  for (HasMetadata item : items) {
    if (item instanceof StatefulSet) {
      return ((StatefulSet)item).getSpec().getReplicas();
    } else if (item instanceof Deployment) {
      return ((Deployment)item).getSpec().getReplicas();
    }
  }
  return 0;
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

this.toDeployment = topicOperator.generateDeployment(isOpenShift);
this.toMetricsAndLogsConfigMap = logAndMetricsConfigMap;
Annotations.annotations(this.toDeployment.getSpec().getTemplate()).put(
    ANNO_STRIMZI_IO_LOGGING,
    this.toMetricsAndLogsConfigMap.getData().get("log4j2.properties"));

代码示例来源:origin: strimzi/strimzi-kafka-operator

Future<ReconciliationState> entityOperatorDeployment(Supplier<Date> dateSupplier) {
  if (this.entityOperator != null) {
    Future<Deployment> future = deploymentOperations.getAsync(namespace, this.entityOperator.getName());
    if (future != null) {
      return future.compose(dep -> {
        // getting the current cluster CA generation from the current deployment, if exists
        int clusterCaCertGeneration = getDeploymentCaCertGeneration(dep, this.clusterCa);
        int clientsCaCertGeneration = getDeploymentCaCertGeneration(dep, this.clientsCa);
        // if maintenance windows are satisfied, the cluster CA generation could be changed
        // and EO needs a rolling update updating the related annotation
        boolean isSatisfiedBy = isMaintenanceTimeWindowsSatisfied(dateSupplier);
        if (isSatisfiedBy) {
          clusterCaCertGeneration = getCaCertGeneration(this.clusterCa);
          clientsCaCertGeneration = getCaCertGeneration(this.clientsCa);
        }
        Annotations.annotations(eoDeployment.getSpec().getTemplate()).put(
            Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, String.valueOf(clusterCaCertGeneration));
        Annotations.annotations(eoDeployment.getSpec().getTemplate()).put(
            Ca.ANNO_STRIMZI_IO_CLIENTS_CA_CERT_GENERATION, String.valueOf(clientsCaCertGeneration));
        return withVoid(deploymentOperations.reconcile(namespace, EntityOperator.entityOperatorName(name), eoDeployment));
      }).map(i -> this);
    }
  }
  return Future.succeededFuture(this);
}

代码示例来源:origin: strimzi/strimzi-kafka-operator

Future<ReconciliationState> topicOperatorDeployment(Supplier<Date> dateSupplier) {
  if (this.topicOperator != null) {
    Future<Deployment> future = deploymentOperations.getAsync(namespace, this.topicOperator.getName());
    if (future != null) {
      return future.compose(dep -> {
        // getting the current cluster CA generation from the current deployment, if exists
        int caCertGeneration = getDeploymentCaCertGeneration(dep, this.clusterCa);
        // if maintenance windows are satisfied, the cluster CA generation could be changed
        // and EO needs a rolling update updating the related annotation
        boolean isSatisfiedBy = isMaintenanceTimeWindowsSatisfied(dateSupplier);
        if (isSatisfiedBy) {
          caCertGeneration = getCaCertGeneration(this.clusterCa);
        }
        Annotations.annotations(toDeployment.getSpec().getTemplate()).put(
            Ca.ANNO_STRIMZI_IO_CLUSTER_CA_CERT_GENERATION, String.valueOf(caCertGeneration));
        return withVoid(deploymentOperations.reconcile(namespace, TopicOperator.topicOperatorName(name), toDeployment));
      }).map(i -> this);
    }
  }
  return Future.succeededFuture(this);
}

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

} else if (item instanceof Deployment) {
  Deployment deployment = (Deployment) item;
  deployment.getSpec().setReplicas(numReplicas);

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

private boolean enableDebug(HasMetadata entity) {
  if (entity instanceof Deployment) {
    Deployment resource = (Deployment) entity;
    DeploymentSpec spec = resource.getSpec();
    if (spec != null) {
      return enableDebugging(entity, spec.getTemplate());
    }
  } else if (entity instanceof ReplicaSet) {
    ReplicaSet resource = (ReplicaSet) entity;
    ReplicaSetSpec spec = resource.getSpec();
    if (spec != null) {
      return enableDebugging(entity, spec.getTemplate());
    }
  } else if (entity instanceof ReplicationController) {
    ReplicationController resource = (ReplicationController) entity;
    ReplicationControllerSpec spec = resource.getSpec();
    if (spec != null) {
      return enableDebugging(entity, spec.getTemplate());
    }
  } else if (entity instanceof DeploymentConfig) {
    DeploymentConfig resource = (DeploymentConfig) entity;
    DeploymentConfigSpec spec = resource.getSpec();
    if (spec != null) {
      return enableDebugging(entity, spec.getTemplate());
    }
  }
  return false;
}

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

DeploymentConfigBuilder builder = new DeploymentConfigBuilder();
builder.withMetadata(resource.getMetadata());
DeploymentSpec spec = resource.getSpec();
if (spec != null) {
  DeploymentConfigFluent.SpecNested<DeploymentConfigBuilder> specBuilder = builder.withNewSpec();

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

if (entity instanceof Deployment) {
  Deployment resource = (Deployment) entity;
  DeploymentSpec spec = resource.getSpec();
  if (spec != null) {
    if (enableDebugging(entity, spec.getTemplate())) {

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

DeploymentSpec spec1 = resource1OrCopy.getSpec();
DeploymentSpec spec2 = resource2.getSpec();
if (spec1 == null) {
  resource1OrCopy.setSpec(spec2);

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

if (entity instanceof Deployment) {
  Deployment resource = (Deployment) entity;
  DeploymentSpec spec = resource.getSpec();
  if (spec != null) {
    selector = spec.getSelector();

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

final DeploymentSpec spec = deployHandler.getDeployment(config, images).getSpec();
if (spec != null) {
  builder.accept(new TypedVisitor<DeploymentBuilder>() {

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

if (entity instanceof Deployment) {
  Deployment resource = (Deployment) entity;
  DeploymentSpec spec = resource.getSpec();
  if (spec != null) {
    if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) {

相关文章