當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。