如果我具有这样的自定义资源定义:
$ kubectl get crd unifiedpushservers.push.aerogear.org
NAME CREATED AT
unifiedpushservers.push.aerogear.org 2019-06-05T13:39:23Z
是否可以创建一个ResourceQuota
来将这种类型的自定义资源的数量限制为1,从而拒绝尝试创建其他自定义资源?
这是我到目前为止尝试过的:
apiVersion: v1
kind: ResourceQuota
metadata:
name: unifiedpushservers-limit
spec:
hard:
count/unifiedpushservers.push.aerogear.org: 1
虽然这被接受并创建了,但似乎无法进行计数,并且我可以创建多个实例。
编辑:如果我在规范中引用字段的整数值,则这样:
apiVersion: v1
kind: ResourceQuota
metadata:
name: unifiedpushservers-limit
spec:
hard:
count/unifiedpushservers.push.aerogear.org: "1"
然后在尝试创建一个实例时收到以下错误消息:
Error from server (Forbidden): error when creating "./deploy/crds/push_v1alpha1_unifiedpushserver_cr.yaml": unifiedpushservers.push.aerogear.org "example-unifiedpushserver" is forbidden: status unknown for quota: unifiedpushservers-limit
那感觉就像是进步,但我不确定,我可能会走得更远。
此外,我应该提到我正在OpenShift v3.11集群上尝试此操作,该集群返回以下Kubernetes版本信息:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-10-10T16:38:01Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-11-09T15:12:26Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
答案 0 :(得分:3)
自 kubernetes 1.15 起,命名空间的自定义资源现在使用count/<resource>.<group>
语法支持对象计数配额
例如,要在example.com API组中的小部件自定义资源上创建配额,请使用count / widgets.example.com。