Group

Group(资源组),在Kubernetes API Server中也称为API Group。
资源按照不同功能划分到不同的资源组。
资源组特点如下:

  • 允许单独启用/进制某个资源组(资源也可以)
  • 支持资源组中拥有不同的资源版本,方便迭代升级
  • 支持同名的资源(即Kind)位于不同的资源组内
  • 资源组和资源版本通过Kubernetes API Server对外暴露,可以通过HTTP协议进行交互并通过动态客户端(即DynamicClient)进行资源发现
  • 支持CRD自定义资源扩展
  • 使用kubectl可以不同写资源组名称

资源组数据结构如下:
代码路径:vendor/k8s.io/apimachinery/pkg/apis/meta/v1/types.go

  1. // APIGroup contains the name, the supported versions, and the preferred version
  2. // of a group.
  3. type APIGroup struct {
  4. TypeMeta `json:",inline"`
  5. // name is the name of the group.
  6. Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
  7. // versions are the versions supported in this group.
  8. Versions []GroupVersionForDiscovery `json:"versions" protobuf:"bytes,2,rep,name=versions"`
  9. // preferredVersion is the version preferred by the API server, which
  10. // probably is the storage version.
  11. // +optional
  12. PreferredVersion GroupVersionForDiscovery `json:"preferredVersion,omitempty" protobuf:"bytes,3,opt,name=preferredVersion"`
  13. // a map of client CIDR to server address that is serving this group.
  14. // This is to help clients reach servers in the most network-efficient way possible.
  15. // Clients can use the appropriate server address as per the CIDR that they match.
  16. // In case of multiple matches, clients should use the longest matching CIDR.
  17. // The server returns only those CIDRs that it thinks that the client can match.
  18. // For example: the master will return an internal IP CIDR only, if the client reaches the server using an internal IP.
  19. // Server looks at X-Forwarded-For header or X-Real-Ip header or request.RemoteAddr (in that order) to get the client IP.
  20. // +optional
  21. ServerAddressByClientCIDRs []ServerAddressByClientCIDR `json:"serverAddressByClientCIDRs,omitempty" protobuf:"bytes,4,rep,name=serverAddressByClientCIDRs"`
  22. }

Kubernets系统中支持两种资源组: