我目前使用fabric8 API来读取豆荚、服务等的内容。
KubernetesClient client = new DefaultKubernetesClient();
client.configMaps().withName("ConfigMapName");是否有方法从api组HTTPProxy的httpproxies检索projectcontour.io的内容?
提前谢谢!
发布于 2020-09-19 17:42:22
HTTPProxy似乎是定制资源。Kubernetes客户端提供了一个类型化API (您需要为您的自定义资源提供POJO)和一个无型API(使用原始HashMaps操作自定义资源)。下面是一个示例,说明如何使用无类型API来完成此操作:
try (KubernetesClient client = new DefaultKubernetesClient()) {
CustomResourceDefinitionContext httpProxyContext = new CustomResourceDefinitionContext.Builder()
.withGroup("projectcontour.io") // <- Group of Custom Resource
.withVersion("v1") // <- Version of Custom Resource
.withPlural("httpproxies") // <- Plural form as specified in CRD
.withScope("Namespaced") // <- Whether Custom Resource is Cluster Scoped or Namespaced
.build();
// List all HTTPProxies
Map<String, Object> httpProxyList = client.customResource(httpProxyContext).list("ns1");
// Get a specific HTTPProxy
Map<String, Object> myHttpProxy = client.customResource(httpProxyContext).get("ns1", "tls-example");
}你可以选择任何你认为适合你需要的方法。如果有兴趣的话,您可以详细查看我的博客中有关这些方法的内容:
https://stackoverflow.com/questions/63962025
复制相似问题