kyverno VS gateKeeper
kyverno VS gateKeeper
概述
这两组开源工具都是是基于kubernetes 的webhook机制,支持validatingwebhook和mutatingwebhook。整体思路上是一样的,都是针对资源的字段,如标签、镜像等来设置规则,在对kubernetes资源的控制范围和粒度上,二者可以看作是一样的。
kyverno
kyverno 的架构如下,它是基于kubernetes 资源的一种策略执行器,主要基于kubernetes资源的标签和spec字段制定规则,规则支持简单的条件判断,逻辑与、或、非。支持如下功能:
- 支持集群级别和命名空间级别的策略
- 支持审计日志功能
- 有一个官方的UI
- 支持kubernetes原生资源和CRD
- 支持如下规则类型:
validate:规则校验,最常用的类型
mutate:支持修改现有资源
generate:支持生成新的资源
verifyImages:校验镜像签名

例子
如下策略表示拒绝没有cluster-admin clusterRoles的用户删除带app.kubernetes.io/managed-by: kyverno 标签的对象
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: deny-deletes
spec:
validationFailureAction: enforce
background: false
rules:
- name: block-deletes-for-kyverno-resources
match:
resources:
selector:
matchLabels:
app.kubernetes.io/managed-by: kyverno
exclude:
clusterRoles:
- cluster-admin
validate:
message: "Deleting {{request.oldObject.kind}}/{{request.oldObject.metadata.name}} is not allowed"
deny:
conditions:
- key: "{{request.operation}}"
operator: In
value:
- DELETE
由于kyverno 建立在kubernetes之上,其策略决策和策略执行也是基于kubernetes的资源,因此也限制了其使用场景,如对接image registries, Active Directory/LDAP directories等第三方验证服务,而gatekeeper就可以支持就这些场景。
此外由于它使用类yaml的方式来表达策略的,因此其使用起来比较笨拙。
优点就是使用的配置比较简单,相比于gateKeeper来说入手比较简单,维护成本低。
gateKeeper

例子
gateKeeper的规则配置要分为两步,首先创建ConstraintTemplate,再创建constraint
首先需要创建一个模板ConstraintTemplate,下面模板用于要求所有资源中必须存在constraint 所要求的标签
apiVersion: templates.gatekeeper.sh/v1beta1
kind: ConstraintTemplate
metadata:
name: k8srequiredlabels
spec:
crd:
spec:
names:
kind: K8sRequiredLabels
validation:
# Schema for the `parameters` field
openAPIV3Schema:
properties:
labels:
type: array
items: string
targets:
- target: admission.k8s.gatekeeper.sh
rego: |
package k8srequiredlabels
violation[{"msg": msg, "details": {"missing_labels": missing}}] {
provided := {label | input.review.object.metadata.labels[label]}
required := {label | label := input.parameters.labels[_]}
missing := required - provided
count(missing) > 0
msg := sprintf("you must provide labels: %v", [missing])
}
然后创建一个constraints,并指定上面的K8sRequiredLabels模板,要求所有命名空间资源中必须有gatekeeper标签
apiVersion: constraints.gatekeeper.sh/v1beta1
kind: K8sRequiredLabels
metadata:
name: ns-must-have-gk
spec:
match:
kinds:
- apiGroups: [""]
kinds: ["Namespace"]
parameters:
labels: ["gatekeeper"]
对比表
| Features/Capabilities | Gatekeeper | Kyverno |
|---|---|---|
| Validation | ✓ | ✓ |
| Mutation | ✓* beta | ✓ |
| Generation | X | ✓ |
| Policy as native resources | ✓ | ✓ |
| Metrics exposed | ✓ | ✓ |
OpenAPI validation schema (kubectl explain) |
X | ✓ |
| High Availability | ✓ | ✓* |
| API object lookup | ✓ | ✓ |
| CLI with test ability | ✓** | ✓ |
| Policy audit ability | ✓ | ✓ |
| Self-service reports | X | ✓ |
* Alpha status
** Separate CLI
| Community/Ecosystem | Gatekeeper | Kyverno |
|---|---|---|
| CNCF status | Graduated (OPA) | Sandbox |
| Partner ecosystem adoption* | ◗ | ◔ |
| GitHub status (stars, forks, releases, commits) | 1,832, 349, 46, 630 | 1,063, 122, 82, 3,326 |
| Community traction** | ◗ | ◔ |
| Policy sample library | ✓ | ✓ |
* Not well defined. 相比Kyverno来说,Gatekeeper 的采纳意向更多,但具体不详.
** No objective measurement exists. 考虑到社区的存在时间,Gatekeeper 可能更具吸引力.
| Meta/Misc | Gatekeeper | Kyverno |
|---|---|---|
| Programming required | ✓ | X |
| Use outside Kubernetes | ✓ | X |
| Birth (Age as of June 2021) | July 2017 (3 years, 11 months) | May 2019 (2 years, 1 month) |
| Origin company | Styra (OPA) | Nirmata |
| Documentation maturity | ◗* | ◕ |
* Not totally objective with direct comparison being difficult. Assessment made based on Gatekeeper project/functionality and not maturity level of Rego enablement materials/literature.
参考
- kubernetes-policy-comparison-opa-gatekeeper-vs-kyverno
- Kyverno 和 OPA/Gatkeeper 的一点对比
- kyverno policies
- gatekeeper-library
kyverno VS gateKeeper的更多相关文章
- Gatekeeper Pattern 把关(守门人)模式
Protect applications and services by using a dedicated host instance that acts as a broker between c ...
- Re-Architecting the Video Gatekeeper(一)
原文 https://medium.com/netflix-techblog/re-architecting-the-video-gatekeeper-f7b0ac2f6b00 本文介绍了了内容配置工 ...
- Re-Architecting the Video Gatekeeper(二)
原文: https://medium.com/netflix-techblog/re-architecting-the-video-gatekeeper-f7b0ac2f6b00 想法 我们决定部署一 ...
- MacOS X GateKeeper Bypass
MacOS X GateKeeper Bypass OVERVIEW On MacOS X version <= 10.14.5 (at time of writing) is it possi ...
- 小米 OJ 编程比赛 02 月常规赛 3 Logic Gatekeeper CDQ分治
link:https://code.mi.com/problem/list/view?id=139 题意: 有一个1e6 * 1e6 大的格子,现在有两种操作:1,给一个子矩阵中的每个格子加上k.2, ...
- Google Capture The Flag 2018 (Quals) - Reverse - Beginner's Quest - Gatekeeper
参考链接:https://ctftime.org/task/6264 题目 It's a media PC! All fully purchased through the online subscr ...
- gatekeeper学习概述
1.概述 该产品部署在网络隔离装置两端,以代理程序的身份,完成两侧设备连接维护,数据转发的功能.场景简化如图所示: 软件核心是一个基于Netty的网络应用程序,考虑到系统的可维可测性,集成了web化的 ...
- opa gatekeeper笔记:AdmissionReview input.request请求对象结构
官方:https://v1-17.docs.kubernetes.io/zh/docs/reference/access-authn-authz/extensible-admission-contro ...
- Summary of Critical and Exploitable iOS Vulnerabilities in 2016
Summary of Critical and Exploitable iOS Vulnerabilities in 2016 Author:Min (Spark) Zheng, Cererdlong ...
随机推荐
- thrift基础知识
1. 架构图 Thrift 包含一个完整的堆栈结构用于构建客户端和服务器端.下图描绘了 Thrift 的整体架构. 图 1. 架构图 如图所示,图中黄色部分是用户实现的业务逻辑,褐色部分是根据 Thr ...
- HttpServletRequest接口详解
般情况下,浏览器(客户端)通过 HTTP 协议来访问服务器的资源,Servlet 主要用来处理 HTTP 请求.Servlet 处理 HTTP 请求的流程如下: Servlet 容器接收到来自客户端的 ...
- Vue之 watch、computed、filter之间的区别与使用场景
computed 计算属性: 当页面中需要使用大量的表达式处理数据时,为了页面维护更加简单,所以使用 计算属性 来出来复杂的逻辑运算 watch 侦听器 当需要在数据变化时执行异步或开销较大的操作时 ...
- 创建一个python类 ,self init相关参数的简单介绍
一 创建 ''' 一 使用python 语法 创建一个类, 探究self 是干啥的 1 创建一个对象 car 2 写入两个行参 3 定义两个方法 ''' class Car(): ''' 二 init ...
- ApacheCN 深度学习译文集 20210125 更新
新增了七个教程: PyTorch 中文官方教程 1.7 学习 PyTorch PyTorch 深度学习:60 分钟的突击 张量 torch.autograd的简要介绍 神经网络 训练分类器 通过示例学 ...
- <input type="file"> 标签详解
详见:https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/Input/file#attr-multiple 使用 type=" ...
- JAVA_HOME环境的配置
JAVA_HOME环境的配置 有时候可能需要更换Jdk的目录,但是经常修改path的值可能会不小心修改其他的路径,解决方法: 1. 创建一个JAVA_HOME的变量. 2. JAVA_HOME的值 ...
- Zookeeper、Kafka集群与Filebeat+Kafka+ELK架构
Zookeeper.Kafka集群与Filebeat+Kafka+ELK架构 目录 Zookeeper.Kafka集群与Filebeat+Kafka+ELK架构 一.Zookeeper 1. Zook ...
- 注解的使用、拦截器使用、AOP切面使用
Java 自定义注解及使用场景 转载: https://www.jianshu.com/p/a7bedc771204 Java自定义注解一般使用场景为:自定义注解+拦截器或者AOP,使用自定义注解来自 ...
- 5个不常提及的HTML技巧
2021年你需要知道的HTML标签和属性 Web开发人员都在广泛的使用HTML.无论你使用什么框架或者选择哪个后端语言,框架在变,但是HTML始终如一.尽管被广泛使用,但还是有一些标签或者属性是大部分 ...