繁体   English   中英

如何使用 OPA Gatekeeper 更改 GKE 部署?

[英]How to use OPA Gatekeeper to change GKE deployments?

我正在尝试使用 OPA Gatekeeper 来修改某些 Kubernetes 部署。 在此示例中,我想更改服务帐户的显示名称,而不管用户提供什么。 到目前为止,我一直在关注这里的文档: https://open-policy-agent.github.io/gatekeeper/website/docs/mutation/

我创建了以下 yaml 文件:

apiVersion: mutations.gatekeeper.sh/v1alpha1
kind: Assign
metadata:
  name: change-sa-name
spec:
  applyTo:
  - groups: [""]
    kinds: ["IAMServiceAccount"]
    versions: ["v1beta1"]
  location: "spec.displayName"
  parameters:
    assign:
      value: "New Name"

并使用以下内容部署服务帐户:

apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMServiceAccount
metadata:
  labels:
    label-one: "value-one"
  name: iamserviceaccount-sample
spec:
  displayName: Example Service Account

但是,在部署它时,显示名称仍显示为示例服务帐户,而不是新名称。 我到底做错了什么或者我应该看什么?

根据官方文档,您需要在显示名称行提供您希望提供的显示名称。 在下面找到 yaml 并尝试一下,如果出现错误,请将其粘贴在这里。

apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMServiceAccount
metadata:
  labels:
    label-one: "value-one"
  name: iamserviceaccount-sample
spec:
  displayName: <Give the display name that you are looking for>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM