简体   繁体   English

kubebuilder 脚手架中的“域”是什么?

[英]What is "domain" in kubebuilder scaffolding?

The kubebuilder scaffolding command includes a repo and domain eg kubebuilder 脚手架命令包括一个 repo 和域,例如

kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project

I found following text in kubebuilder book about "domain":我在 kubebuilder 书中找到了以下关于“域”的文本:

domain: Store the domain of the project. domain:存放项目的域名。 This information can be provided by the user when the project is generate with the init sub-command and the domain flag.当使用 init 子命令和域标志生成项目时,用户可以提供此信息。 And domain: domain for groups (default "my.domain")和域:组域(默认“my.domain”)

I understand domain is usually to set boundaries to avoid naming conflicts eg different teams in a company can use different domains/sub-domains and have freedom of choosing names under that domain/sub-domain.我理解域通常是设置边界以避免命名冲突,例如公司中的不同团队可以使用不同的域/子域,并且可以自由选择该域/子域下的名称。 But in the context of a kubebuilder project:但是在 kubebuilder 项目的上下文中:

  • What name conflicts are we avoiding here?我们在这里避免了哪些名称冲突? What if teams are different but still they deploy to a shared cluster?如果团队不同但仍部署到共享集群怎么办? What if domain name itself is duplicate?如果域名本身是重复的怎么办? When do you figure out there's a conflict?你什么时候发现有冲突?
  • What are the functional implications of a domain eg on CRDs, on APIs etc. ?域的功能含义是什么,例如 CRD、API 等?
  • Can you change it later and any gotchas?你可以稍后更改它并且有任何问题吗?
  • Can you have no domain at all, not even default - my.domain?你可以没有域,甚至没有默认值 - my.domain?

I'm aware that these answers could be much longer for a post if elaborated, any guidance or material in this context would help.我知道,如果详细说明,这些答案对于帖子来说可能会更长,在这种情况下的任何指导或材料都会有所帮助。 Thanks.谢谢。

The domain is the Kubernetes 'group', which as you describe is used for namespacing and avoiding naming conflicts.域是 Kubernetes “组”,正如您所描述的,它用于命名空间和避免命名冲突。 A 'group' along with a 'version' and a 'kind' uniquely identify a type of resource that the Kubernetes API server knows about. “组”连同“版本”和“种类”唯一标识 Kubernetes API 服务器知道的资源类型。

To answer your questions:要回答您的问题:

  • The name conflicts you are avoiding are generally if two separate groups have a concept they want to represent with a similar name.您要避免的名称冲突通常是如果两个单独的组有一个他们想用相似名称表示的概念。 Generally, the friendly name of a resource goes in the 'kind' field, eg 'Bucket'.通常,资源的友好名称位于“种类”字段中,例如“桶”。 If you have two separate concepts of a bucket, then without the existence of the 'group', you might call one kind: AWSBucket and the other kind: GCPBucket .如果您有两个独立的存储桶概念,那么在不存在“组”的情况下,您可能会调用kind: AWSBucket和另kind: GCPBucket With groups, you can do the following:使用组,您可以执行以下操作:

     apiVersion: aws.amazon.com/v1 kind: Bucket

    as separate from

    apiVersion: gcp.google.com/v1 kind: Bucket
  • The previous dot-point hints at this.前面的点提示了这一点。 Functionally, the 'domain'/'group' along with the version form the apiVersion field of any resources you provision against the CRD, and will form the group field of the Custom Resource Definition .从功能上讲,“域”/“组”与版本一起构成您针对 CRD 提供的任何资源的apiVersion字段,并将构成自定义资源定义group字段。

  • You can change it later.您可以稍后更改。 There's the obvious gotcha that some other team might already be using your namespace.很明显,其他团队可能已经在使用您的命名空间。 You'll also need to update and re-deploy any resources that use this domain as part of a custom resource.您还需要更新和重新部署使用此域作为自定义资源一部分的任何资源。 Practically, this might as well be a new API from the point of view of Kubernetes.实际上,从 Kubernetes 的角度来看,这也可能是一个新的 API。 You'll start again with no resources of that kind, and so you'll need to update and re-deploy any resources you've created against the old kind.您将在没有此类资源的情况下重新开始,因此您需要更新并重新部署针对旧类型创建的任何资源。 This may cause issues, though it should be possible to handle these as part of a controller (eg migrate any controller state recorded against the old resource to the new resource).这可能会导致问题,尽管应该可以将这些作为 controller 的一部分进行处理(例如,将针对旧资源记录的任何 controller state 迁移到新资源)。

  • No, it's not possible to not define a domain.不,不可能不定义域。 I'm not sure what Kubebuilder will do if you don't provide this flag.如果您不提供此标志,我不确定 Kubebuilder 会做什么。 But practically, group is a required field on the CustomResourceDefinition resource that is used to register the custom resource with Kubernetes.但实际上, groupCustomResourceDefinition资源上的必填字段,用于向 Kubernetes 注册自定义资源。 See the API documentation for CustomResourceDefinition有关CustomResourceDefinition,请参阅 API 文档

Resources:资源:

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

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