这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
接口&对象 | 类型 | 文件位置 | 说明 |
---|---|---|---|
runTime.Object | 接口 | runtime/interfaces.go | kubernetes的对象都实现了此接口 |
schema.ObjectKind | 接口 | runtime/schema/interfaces.go | 对象类型相关的接口 |
metav1.Object | 接口 | apis/meta/v1/meta.go | 属性相关的接口 |
metav1.ListInterface | 接口 | apis/meta/v1/meta.go | 对象列表相关的接口 |
metav1.TypeMeta | 实现类 | apis/meta/v1/types.go | ObjectKind接口的实现类,负责类型的逻辑 |
metav1.ObjectMeta | 实现类 | apis/meta/v1/types.go | Object接口的实现类,负责属性的逻辑 |
metav1.ListMeta | 实现类 | apis/meta/v1/types.go | ListInterface接口的实现类,负责列表的逻辑 |
type Object interface {
GetObjectKind() schema.ObjectKind
DeepCopyObject() Object
}
type ObjectKind interface {
// SetGroupVersionKind sets or clears the intended serialized kind of an object. Passing kind nil
// should clear the current setting.
SetGroupVersionKind(kind GroupVersionKind)
// GroupVersionKind returns the stored group, version, and kind of an object, or an empty struct
// if the object does not expose or provide these fields.
GroupVersionKind() GroupVersionKind
}
// 1. 代码生成器来生成runtime.Object接口的实现
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Pod is a collection of containers, used as either input (create, update) or as output (list, get).
type Pod struct {
// 2. 这样就实现了schema.ObjectKind接口
metav1.TypeMeta
// 3. 这样就实现了metav1.Object接口
// +optional
metav1.ObjectMeta
// Spec defines the behavior of a pod.
// +optional
Spec PodSpec
// Status represents the current information about a pod. This data may not be up
// to date.
// +optional
Status PodStatus
}
type PodList struct {
metav1.TypeMeta
// +optional
metav1.ListMeta
Items []Pod
}