本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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());
}