【问题标题】:How to delete a custom resource using fabric8io?如何使用 fabric8io 删除自定义资源?
【发布时间】:2021-05-19 20:47:31
【问题描述】:

是否可以使用 fabric8io 删除自定义资源?
如果没有,是否可以使用 kubectl java 客户端?

【问题讨论】:

    标签: kubernetes kubectl fabric8


    【解决方案1】:

    两者皆有可能。

    Fabric8 示例:

    public static Map<String, Object> doDeleteCustomResource(
        KubernetesClient kubernetesClient, CustomResourceDefinitionContext crdContext, String namespace, String name)
        throws IOException{
    
        if ("Namespaced".equals(crdContext.getScope())) {
            return kubernetesClient.customResource(crdContext).delete(namespace, name);
        } else {
            return kubernetesClient.customResource(crdContext).delete(name);
        }
    }
    

    取自here

    或者同样使用同样使用 Fabric8 客户端的Java Operator SDK

    client.customResource(context).delete(name);
    

    您还可以查看fabric8 client code here 中的测试以获取更多示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-28
      • 2012-02-21
      • 1970-01-01
      • 1970-01-01
      • 2018-11-09
      • 1970-01-01
      相关资源
      最近更新 更多