diff --git a/pkg/apis/crds/network.alibabacloud.com_noderuntimes.yaml b/pkg/apis/crds/network.alibabacloud.com_noderuntimes.yaml new file mode 100644 index 00000000..013d12b2 --- /dev/null +++ b/pkg/apis/crds/network.alibabacloud.com_noderuntimes.yaml @@ -0,0 +1,65 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: noderuntimes.network.alibabacloud.com +spec: + group: network.alibabacloud.com + names: + kind: NodeRuntime + listKind: NodeRuntimeList + plural: noderuntimes + singular: noderuntime + scope: Cluster + versions: + - name: v1beta1 + schema: + openAPIV3Schema: + description: NodeRuntime is the Schema for the per node runtime API + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + type: object + status: + properties: + pods: + additionalProperties: + properties: + podID: + type: string + status: + description: when pod is added + enum: + - initial + - deleted + type: string + required: + - podID + - status + type: object + description: runtime status, indexed by pod uid + type: object + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/pkg/apis/crds/register.go b/pkg/apis/crds/register.go index a6823f12..fad9f2a4 100644 --- a/pkg/apis/crds/register.go +++ b/pkg/apis/crds/register.go @@ -22,6 +22,7 @@ const ( CRDPodENI = "podenis.network.alibabacloud.com" CRDPodNetworking = "podnetworkings.network.alibabacloud.com" CRDNode = "nodes.network.alibabacloud.com" + CRDNodeRuntime = "noderuntimes.network.alibabacloud.com" crdVersionKey = "crd.network.alibabacloud.com/version" ) @@ -35,6 +36,9 @@ var ( //go:embed network.alibabacloud.com_nodes.yaml crdsNode []byte + + //go:embed network.alibabacloud.com_noderuntimes.yaml + crdsNodeRuntime []byte ) func getCRD(name string) apiextensionsv1.CustomResourceDefinition { @@ -50,6 +54,9 @@ func getCRD(name string) apiextensionsv1.CustomResourceDefinition { case CRDNode: crdBytes = crdsNode version = "v0.2.0" + case CRDNodeRuntime: + crdBytes = crdsNodeRuntime + version = "v0.1.0" default: panic(fmt.Sprintf("crd %s name not exist", name)) } diff --git a/pkg/apis/network.alibabacloud.com/v1beta1/node_runtime.go b/pkg/apis/network.alibabacloud.com/v1beta1/node_runtime.go new file mode 100644 index 00000000..cc171c31 --- /dev/null +++ b/pkg/apis/network.alibabacloud.com/v1beta1/node_runtime.go @@ -0,0 +1,57 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +type RuntimePodSpec struct { + UID string `json:"uid"` + Name string `json:"name"` + Namespace string `json:"namespace"` + IPv4 string `json:"ipv4"` + IPv6 string `json:"ipv6"` +} + +// +kubebuilder:validation:Enum=initial;deleted +type CNIStatus string + +const ( + CNIStatusInitial CNIStatus = "initial" + CNIStatusDeleted CNIStatus = "deleted" +) + +type RuntimePodStatus struct { + PodID string `json:"podID"` + // when pod is added + Status CNIStatus `json:"status"` +} + +type NodeRuntimeSpec struct { +} + +type NodeRuntimeStatus struct { + // runtime status, indexed by pod uid + Pods map[string]*RuntimePodStatus `json:"pods,omitempty"` +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:resource:scope=Cluster + +// NodeRuntime is the Schema for the per node runtime API +type NodeRuntime struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NodeRuntimeSpec `json:"spec,omitempty"` + Status NodeRuntimeStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// NodeRuntimeList contains a list of Node +type NodeRuntimeList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NodeRuntime `json:"items"` +} diff --git a/pkg/apis/network.alibabacloud.com/v1beta1/register.go b/pkg/apis/network.alibabacloud.com/v1beta1/register.go index a83387a8..2c924cbf 100644 --- a/pkg/apis/network.alibabacloud.com/v1beta1/register.go +++ b/pkg/apis/network.alibabacloud.com/v1beta1/register.go @@ -53,6 +53,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PodNetworkingList{}, &Node{}, &NodeList{}, + &NodeRuntime{}, + &NodeRuntimeList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/pkg/apis/network.alibabacloud.com/v1beta1/zz_generated.deepcopy.go b/pkg/apis/network.alibabacloud.com/v1beta1/zz_generated.deepcopy.go index 4e2cb7dd..1299dd45 100644 --- a/pkg/apis/network.alibabacloud.com/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/network.alibabacloud.com/v1beta1/zz_generated.deepcopy.go @@ -403,6 +403,111 @@ func (in *NodeMetadata) DeepCopy() *NodeMetadata { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeRuntime) DeepCopyInto(out *NodeRuntime) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeRuntime. +func (in *NodeRuntime) DeepCopy() *NodeRuntime { + if in == nil { + return nil + } + out := new(NodeRuntime) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeRuntime) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeRuntimeList) DeepCopyInto(out *NodeRuntimeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NodeRuntime, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeRuntimeList. +func (in *NodeRuntimeList) DeepCopy() *NodeRuntimeList { + if in == nil { + return nil + } + out := new(NodeRuntimeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NodeRuntimeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeRuntimeSpec) DeepCopyInto(out *NodeRuntimeSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeRuntimeSpec. +func (in *NodeRuntimeSpec) DeepCopy() *NodeRuntimeSpec { + if in == nil { + return nil + } + out := new(NodeRuntimeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeRuntimeStatus) DeepCopyInto(out *NodeRuntimeStatus) { + *out = *in + if in.Pods != nil { + in, out := &in.Pods, &out.Pods + *out = make(map[string]*RuntimePodStatus, len(*in)) + for key, val := range *in { + var outVal *RuntimePodStatus + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(RuntimePodStatus) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeRuntimeStatus. +func (in *NodeRuntimeStatus) DeepCopy() *NodeRuntimeStatus { + if in == nil { + return nil + } + out := new(NodeRuntimeStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeSpec) DeepCopyInto(out *NodeSpec) { *out = *in @@ -711,6 +816,36 @@ func (in *Route) DeepCopy() *Route { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RuntimePodSpec) DeepCopyInto(out *RuntimePodSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePodSpec. +func (in *RuntimePodSpec) DeepCopy() *RuntimePodSpec { + if in == nil { + return nil + } + out := new(RuntimePodSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RuntimePodStatus) DeepCopyInto(out *RuntimePodStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuntimePodStatus. +func (in *RuntimePodStatus) DeepCopy() *RuntimePodStatus { + if in == nil { + return nil + } + out := new(RuntimePodStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Selector) DeepCopyInto(out *Selector) { *out = *in