7.3.6. ImagePolicy 准入插件


准入插件截获对 API 的请求,并根据配置的规则执行检查,并根据这些规则允许或拒绝某些操作。OpenShift Container Platform 可以使用 ImagePolicy 准入插件限制环境中运行的镜像:

  • 镜像源:可以用于拉取镜像的 registry
  • 镜像解析:强制 pod 使用不可变摘要运行,以确保因为重新标记而不会改变镜像
  • 容器镜像标签限制:强制镜像具有或没有特定标签
  • 镜像注解限制:强制集成容器 registry 中的镜像具有或没有特定注解
警告

ImagePolicy 准入插件目前被视为 beta。

流程
  1. 如果启用了 ImagePolicy 插件,则需要修改它,以允许在每个 master 节点上修改 /etc/origin/master/master-config.yaml 文件来允许使用外部 registry:

    admissionConfig:
      pluginConfig:
        openshift.io/ImagePolicy:
          configuration:
            kind: ImagePolicyConfig
            apiVersion: v1
            executionRules:
            - name: allow-images-from-other-registries
              onResources:
              - resource: pods
              - resource: builds
              matchRegistries:
              - docker.io
              - <my.registry.example.com>
              - registry.redhat.io
    注意

    启用 ImagePolicy 要求用户在部署应用程序时指定 registry,如 oc new-app docker.io/kubernetes/guestbook 替代 oc new-app kubernetes/guestbook,否则会失败。

  2. 要在安装时启用准入插件,openshift_master_admission_plugin_config 变量可用于 json 格式的字符串,包括所有 pluginConfig 配置:

    openshift_master_admission_plugin_config={"openshift.io/ImagePolicy":{"configuration":{"kind":"ImagePolicyConfig","apiVersion":"v1","executionRules":[{"name":"allow-images-from-other-registries","onResources":[{"resource":"pods"},{"resource":"builds"}],"matchRegistries":["docker.io","*my.registry.example.com*","registry.redhat.io"]}]}}}
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.