本文整理汇总了Java中io.fabric8.kubernetes.api.model.HasMetadata类的典型用法代码示例。如果您正苦于以下问题:Java HasMetadata类的具体用法?Java HasMetadata怎么用?Java HasMetadata使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HasMetadata类属于io.fabric8.kubernetes.api.model包,在下文中一共展示了HasMetadata类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
public synchronized void close() {
if (ghostDriverPod != null) {
Predicate<HasMetadata> isPhantomJs = resource -> "phantomjs".equals(resource.getMetadata().getLabels().get("name"));
OpenshiftUtil.getInstance().getPods().stream().filter(isPhantomJs).forEach(OpenshiftUtil.getInstance()::deletePod);
//FIXME OpenshiftUtil.getInstance().getRoutes().stream().filter(isPhantomJs).forEach(OpenshiftUtil.getInstance()::deleteResource);
OpenshiftUtil.getInstance().getServices().stream().filter(isPhantomJs).forEach(OpenshiftUtil.getInstance()::deleteService);
ghostDriverPod = null;
try {
podService.close();
} catch (Exception e) {
LOGGER.error("Error closing podService", e);
}
podService = null;
}
}
示例2: build
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
public List<HasMetadata> build() {
List<HasMetadata> result = new LinkedList<>();
// build ImageRepository
result.addAll(buildImageStreams());
// build BuildConfig
result.addAll(buildBuildConfigs());
// build DeploymentConfig
result.addAll(buildDeploymentConfigs());
// build Services
result.addAll(buildServices());
// build Route
result.addAll(buildRoutes());
// build ConfigMap
result.addAll(buildConfigMaps());
// create HPA scale
autoScale.ifPresent(x -> result.add(x.build()));
return result;
}
示例3: addMissingResources
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
@Override
public void addMissingResources(KubernetesListBuilder builder) {
log.info("addMissingResources");
List<HasMetadata> items = builder.getItems();
for (HasMetadata item : items) {
if (item instanceof Deployment) {
Deployment deployment = (Deployment)item;
List<Container> containers = getCandidateContainers(deployment);
for (Container container : containers) {
if (container.getResources() == null) {
ResourceRequirements resourceRequirements = buildResourceRequirements();
log.info(describe(resourceRequirements));
container.setResources(resourceRequirements);
}
}
}
}
builder.withItems(items);
}
示例4: onWatchEvent
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
protected void onWatchEvent(io.fabric8.kubernetes.client.Watcher.Action action, HasMetadata entity, NotifyConfig notifyConfig) {
if (!notifyConfig.isEnabled(action)) {
return;
}
String kind = KubernetesHelper.getKind(entity);
String name = KubernetesHelper.getName(entity);
String namespace = getNamespace();
String actionText = action.toString().toLowerCase();
String room = this.roomExpression.replace("${namespace}", namespace).replace("${kind}", kind).replace("${name}", name);
String postfix = "";
if (action.equals(Watcher.Action.ADDED) || action.equals(Watcher.Action.MODIFIED)) {
if (Strings.isNotBlank(consoleLink)) {
postfix += " " + consoleLink + "/kubernetes/namespace/" + namespace + "/" + kind.toLowerCase() + "s/" + name;
}
}
String message = actionText + " " + decapitalize(kind) + " " + namespace + " / " + name + postfix;
notifier.notifyRoom(room, message);
}
示例5: createFromUri
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private void createFromUri(String prjName, String uri) throws OpenShiftClientException {
URL url = toUrl(uri);
if (url != null) {
KubernetesList kubeList = delegate.lists().load(url).get();
List<HasMetadata> items = kubeList.getItems();
if (items.size() > 0) {
for (HasMetadata item : items) {
String name = item.getMetadata().getName();
if (item instanceof ServiceAccount) {
if (delegate.serviceAccounts().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
} else if (item instanceof Secret) {
if (delegate.secrets().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
} else if (item instanceof ImageStream) {
if (delegate.imageStreams().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
}
}
delegate.lists().inNamespace(prjName).create(kubeList);
}
}
}
示例6: podsOf
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
/**
* Finds the pod that correspond to the specified resource.
*
* @param resource The resource.
* @return The podList with the matching pods.
*/
public static <T extends HasMetadata> PodList podsOf(KubernetesClient client, T resource) {
if (resource instanceof Pod) {
return new PodListBuilder().withItems((Pod) resource).build();
} else if (resource instanceof Endpoints) {
return podsOf(client, client.services()
.inNamespace(resource.getMetadata().getNamespace())
.withName(resource.getMetadata().getName())
.get());
} else if (resource instanceof Service) {
return client.pods()
.inNamespace(resource.getMetadata().getNamespace())
.withLabels(((Service) resource).getSpec().getSelector())
.list();
} else if (resource instanceof ReplicationController) {
return client.pods()
.inNamespace(resource.getMetadata().getNamespace())
.withLabels(((ReplicationController) resource).getSpec().getSelector())
.list();
} else if (resource instanceof Deployment) {
return findMatching(client, (Deployment) resource);
} else if (resource instanceof DeploymentConfig) {
return client.pods().inNamespace(resource.getMetadata().getNamespace()).withLabel("deploymentconfig",
resource.getMetadata().getName()).list();
} else {
return new PodListBuilder().build();
}
}
示例7: findMainResource
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private <T extends HasMetadata> T findMainResource(Collection<T> resources, String defaultName) {
if (resources.size() == 1) {
return resources.iterator().next();
} else {
// try finding default resource
Optional<T> match = resources.stream().filter(resource -> defaultName.equals(resource.getMetadata().getName())).findFirst();
if (match.isPresent()) {
return match.get();
} else {
LOGGER.debug("No default resource found '{}'", defaultName);
return null;
}
}
}
示例8: findMainResourceWithPrefix
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private <T extends HasMetadata> T findMainResourceWithPrefix(Collection<T> resources, String defaultName) {
if (resources.size() == 1) {
return resources.iterator().next();
} else {
// try finding default resource
Optional<T> match = resources.stream().filter(resource -> resource.getMetadata().getName().startsWith(defaultName)).findFirst();
if (match.isPresent()) {
return match.get();
} else {
LOGGER.debug("No default resource found '{}'", defaultName);
return null;
}
}
}
示例9: close
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
@Override
public synchronized void close() throws Exception {
if (isStarted()) {
final Predicate<HasMetadata> hasZipkinLabel = resource -> resource.getMetadata()
.getLabels() != null && ZIPKIN_LABEL_VALUE.equals(resource.getMetadata()
.getLabels()
.get(ZIPKIN_LABEL_KEY));
deleteRoute(hasZipkinLabel);
deleteService(hasZipkinLabel);
deletePod(hasZipkinLabel);
this.started = false;
}
}
示例10: deletePod
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private void deletePod(final Predicate<HasMetadata> hasZipkinLabel) {
OpenshiftUtil.getInstance()
.getPods()
.stream()
.filter(hasZipkinLabel)
.forEach(OpenshiftUtil.getInstance()::deletePod);
}
示例11: deleteService
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private void deleteService(final Predicate<HasMetadata> hasZipkinLabel) {
OpenshiftUtil.getInstance()
.getServices()
.stream()
.filter(hasZipkinLabel)
.forEach(OpenshiftUtil.getInstance()::deleteService);
}
示例12: deleteRoute
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private void deleteRoute(final Predicate<HasMetadata> hasZipkinLabel) {
OpenshiftUtil.getInstance()
.getRoutes()
.stream()
.filter(hasZipkinLabel)
.forEach(OpenshiftUtil.getInstance()::deleteRoute);
}
示例13: convertUnsupportedItems
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private List<HasMetadata> convertUnsupportedItems(Platform platform, List<HasMetadata> items) {
List<HasMetadata> unsupported = new ArrayList<>(extractUnsupportedItems(platform, items));
List<HasMetadata> converted = new ArrayList<>();
for (Enricher<P> enricher : enrichers) {
List<HasMetadata> c = enricher.convert(platform, createEnricherContext(enricher), unsupported);
if (c != null) {
converted.addAll(c);
}
}
return converted;
}
示例14: extractSupportedItems
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private List<HasMetadata> extractSupportedItems(Platform platform, List<HasMetadata> items) {
List<HasMetadata> ret = new ArrayList<>();
for (HasMetadata item : items) {
if (platform.supportsKind(item.getKind())) {
ret.add(item);
}
}
return ret;
}
示例15: extractUnsupportedItems
import io.fabric8.kubernetes.api.model.HasMetadata; //导入依赖的package包/类
private List<HasMetadata> extractUnsupportedItems(Platform platform, List<HasMetadata> items) {
List<HasMetadata> ret = new ArrayList<>();
for (HasMetadata item : items) {
if (!platform.supportsKind(item.getKind())) {
ret.add(item);
}
}
return ret;
}