代码之家  ›  专栏  ›  技术社区  ›  meallhour

删除后正在重新创建Openshift“模板”资源

  •  0
  • meallhour  · 技术社区  · 1 年前

    我正在删除自定义模板 httpd-example 使用以下命令:

    oc delete template httpd-example -n openshift
    

    但是,删除后将重新创建模板对象。

    oc get template -n openshift | grep httpd 
    

    我无法理解删除后如何重新创建模板。

    1 回复  |  直到 1 年前
        1
  •  1
  •   larsks    1 年前

    这个 httpd-example 模板不是“自定义模板”;它是由OpenShift“开箱即用”提供的。在新的OpenShift(4.14.x)安装中 openshift 命名空间包含50个模板,包括 httpd示例 样板

    $ oc -n openshift get template httpd-example
    NAME            DESCRIPTION                                                                        PARAMETERS     OBJECTS
    httpd-example   An example Apache HTTP Server (httpd) application that serves static content....   10 (3 blank)   5
    

    这些模板由管理 openshift-samples 操作人员如果我们删除其中一个托管模板,我们会看到:

    $ kubectl -n openshift-cluster-samples-operator logs -l name=cluster-samples-operator -f
    Defaulted container "cluster-samples-operator" out of: cluster-samples-operator, cluster-samples-operator-watch
    .
    .
    .
    time="2024-02-06T04:02:27Z" level=info msg="going to recreate deleted managed sample template/httpd-example"
    time="2024-02-06T04:02:27Z" level=info msg="created template httpd-example"
    

    如果使用自定义模板,请在不同的命名空间中创建它们,并将 开式换档 命名空间到托管资源。


    集群样本操作符的配置如所述 the documentation .

    您可以通过设置 skippedTemplates 操作员配置中的选项:

    oc patch config.samples.operator.openshift.io cluster \
      --type=merge  --patch '{"spec": {"skippedTemplates": ["httpd-example"]}}'
    

    有了此配置,我们可以删除 httpd示例 样板

    oc -n openshift delete template httpd-example
    

    请参阅集群示例操作员日志:

    cluster-samples-operator-64f49fbf5c-2f98t cluster-samples-operator time="2024-02-06T04:39:14Z" level=info msg="watch event httpd-example in skipped list for template"
    

    您可以停止集群示例操作员管理 全部的 通过设置 managementState Removed .

    oc patch config.samples.operator.openshift.io cluster \
      --type=merge  --patch '{"spec": {"managementState": "Removed"}}'
    

    这将导致操作员移除 全部的 托管资源(模板和图像流)。设置 管理状态 返回到 Managed 将恢复所有托管资源。

    推荐文章