如何解决Kubernetes Fabric8 API
我目前使用fabric8 API读取POD,服务等的内容。
KubernetesClient client = new DefaultKubernetesClient();
client.configMaps().withName("ConfigMapName");
是否可以从api组projectcontour.io的httpproxies检索HTTPProxy的内容?
提前谢谢!
解决方法
HTTPProxy
似乎是Custom Resource。 Kubernetes客户端提供一个Typed API(您需要为自定义资源提供POJO)和一个Typeless API(使用原始HashMap来操纵自定义资源)。这是有关如何使用无类型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");
}
您可以选择自己认为适合的任何方法。如果有兴趣,您可以查看我的博客中有关这些方法的详细信息:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。