当前位置: 首页>>代码示例>>Java>>正文


Java KubernetesClient.getNamespace方法代码示例

本文整理汇总了Java中io.fabric8.kubernetes.client.KubernetesClient.getNamespace方法的典型用法代码示例。如果您正苦于以下问题:Java KubernetesClient.getNamespace方法的具体用法?Java KubernetesClient.getNamespace怎么用?Java KubernetesClient.getNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.fabric8.kubernetes.client.KubernetesClient的用法示例。


在下文中一共展示了KubernetesClient.getNamespace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getApplicationNamespace

import io.fabric8.kubernetes.client.KubernetesClient; //导入方法依赖的package包/类
public static <C extends AbstractConfigProperties> String getApplicationNamespace(KubernetesClient client, Environment env, C config) {
    String namespace = config.getNamespace();
    if (StringUtils.isEmpty(namespace)) {
        LOGGER.debug(config.getConfigurationTarget() + " namespace has not been set, taking it from client (ns={})",
                client.getNamespace());

        namespace = client.getNamespace();
    }

    return namespace;
}
 
开发者ID:fabric8io,项目名称:spring-cloud-kubernetes,代码行数:12,代码来源:ConfigUtils.java

示例2: reporter

import io.fabric8.kubernetes.client.KubernetesClient; //导入方法依赖的package包/类
@Bean
public ZipkinSpanReporter reporter(KubernetesClient client, KubernetesZipkinDiscoveryProperties discoveryProperties, SpanMetricReporter spanMetricReporter, ZipkinProperties zipkin) {
    String serviceName = discoveryProperties.getServiceName();
    String serviceNamespace = Utils.isNotNullOrEmpty(discoveryProperties.getServiceNamespace()) ? discoveryProperties.getServiceNamespace() : client.getNamespace();

    List<ServiceInstance> services = getInstances(client, serviceName, serviceNamespace);
    String serviceUrl = services.stream()
            .findFirst()
            .map(s -> s.getUri().toString())
            .orElse(null);

    return serviceUrl == null || serviceUrl.isEmpty()
            ? new NullZipkinSpanReporter()
            : new HttpZipkinSpanReporter(serviceUrl, zipkin.getFlushInterval(), zipkin.getCompression().isEnabled(), spanMetricReporter);
}
 
开发者ID:fabric8io,项目名称:spring-cloud-kubernetes,代码行数:16,代码来源:ZipkinKubernetesAutoConfiguration.java

示例3: addProvisionedSlave

import io.fabric8.kubernetes.client.KubernetesClient; //导入方法依赖的package包/类
/**
 * Check not too many already running.
 *
 */
private boolean addProvisionedSlave(@Nonnull PodTemplate template, @CheckForNull Label label) throws Exception {
    if (containerCap == 0) {
        return true;
    }

    KubernetesClient client = connect();
    String templateNamespace = template.getNamespace();
    // If template's namespace is not defined, take the
    // Kubernetes Namespace.
    if (Strings.isNullOrEmpty(templateNamespace)) {
        templateNamespace = client.getNamespace();
    }

    PodList slaveList = client.pods().inNamespace(templateNamespace).withLabels(getLabels()).list();
    List<Pod> slaveListItems = slaveList.getItems();

    Map<String, String> labelsMap = getLabelsMap(template.getLabelSet());
    PodList namedList = client.pods().inNamespace(templateNamespace).withLabels(labelsMap).list();
    List<Pod> namedListItems = namedList.getItems();

    if (slaveListItems != null && containerCap <= slaveListItems.size()) {
        LOGGER.log(Level.INFO,
                "Total container cap of {0} reached, not provisioning: {1} running or errored in namespace {2} with Kubernetes labels {3}",
                new Object[] { containerCap, slaveListItems.size(), client.getNamespace(), getLabels() });
        return false;
    }

    if (namedListItems != null && slaveListItems != null && template.getInstanceCap() <= namedListItems.size()) {
        LOGGER.log(Level.INFO,
                "Template instance cap of {0} reached for template {1}, not provisioning: {2} running or errored in namespace {3} with label \"{4}\" and Kubernetes labels {5}",
                new Object[] { template.getInstanceCap(), template.getName(), slaveListItems.size(),
                        client.getNamespace(), label == null ? "" : label.toString(), labelsMap });
        return false; // maxed out
    }
    return true;
}
 
开发者ID:carlossg,项目名称:jenkins-kubernetes-plugin,代码行数:41,代码来源:KubernetesCloud.java

示例4: getResource

import io.fabric8.kubernetes.client.KubernetesClient; //导入方法依赖的package包/类
@Override
public Resource<Address> getResource(ObserverKey observerKey, KubernetesClient client) {
    return new ConfigMapAddressApi(client, addressResolver, client.getNamespace());
}
 
开发者ID:EnMasseProject,项目名称:enmasse,代码行数:5,代码来源:ConfigSubscriptionConfig.java


注:本文中的io.fabric8.kubernetes.client.KubernetesClient.getNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。