From af4b1c44abdd0885c55357cefe3e4239ced10575 Mon Sep 17 00:00:00 2001 From: pixiake Date: Tue, 29 Sep 2020 17:41:08 +0800 Subject: [PATCH] add status Signed-off-by: pixiake --- api/v1alpha1/cluster_types.go | 22 ++++++++ api/v1alpha1/zz_generated.deepcopy.go | 51 ++++++++++++++++++- .../bases/kubekey.kubesphere.io_clusters.yaml | 39 ++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/cluster_types.go b/api/v1alpha1/cluster_types.go index eb3f1892..ed36b318 100644 --- a/api/v1alpha1/cluster_types.go +++ b/api/v1alpha1/cluster_types.go @@ -49,6 +49,28 @@ type ClusterSpec struct { type ClusterStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file + + Version string `json:"version,omitempty"` + NetworkPlugin string `json:"networkPlugin,omitempty"` + NodesCount int `json:"nodesCount,omitempty"` + EtcdCount int `json:"etcdCount,omitempty"` + MasterCount int `json:"masterCount,omitempty"` + WorkerCount int `json:"workerCount,omitempty"` + Nodes []NodeStatus `json:"nodes,omitempty"` + Conditions []Condition `json:"Conditions,omitempty"` +} + +type NodeStatus struct { + InternalIP string `json:"internalIP,omitempty"` + Hostname string `json:"hostname,omitempty"` + Roles map[string]bool `json:"roles,omitempty"` +} + +type Condition struct { + Step string `json:"step,omitempty"` + StartTime string `json:"startTime,omitempty"` + EndTime string `json:"endTime,omitempty"` + Status bool `json:"status,omitempty"` } // +kubebuilder:object:root=true diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 4dceca5f..0ad857e2 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -81,7 +81,7 @@ func (in *Cluster) DeepCopyInto(out *Cluster) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster. @@ -170,6 +170,18 @@ func (in *ClusterSpec) DeepCopy() *ClusterSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { *out = *in + if in.Nodes != nil { + in, out := &in.Nodes, &out.Nodes + *out = make([]NodeStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. @@ -182,6 +194,21 @@ func (in *ClusterStatus) DeepCopy() *ClusterStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Condition) DeepCopyInto(out *Condition) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Condition. +func (in *Condition) DeepCopy() *Condition { + if in == nil { + return nil + } + out := new(Condition) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControlPlaneEndpoint) DeepCopyInto(out *ControlPlaneEndpoint) { *out = *in @@ -328,6 +355,28 @@ func (in *NetworkConfig) DeepCopy() *NetworkConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatus) DeepCopyInto(out *NodeStatus) { + *out = *in + if in.Roles != nil { + in, out := &in.Roles, &out.Roles + *out = make(map[string]bool, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatus. +func (in *NodeStatus) DeepCopy() *NodeStatus { + if in == nil { + return nil + } + out := new(NodeStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RegistryConfig) DeepCopyInto(out *RegistryConfig) { *out = *in diff --git a/config/crd/bases/kubekey.kubesphere.io_clusters.yaml b/config/crd/bases/kubekey.kubesphere.io_clusters.yaml index 0e25c7c0..6c893b31 100644 --- a/config/crd/bases/kubekey.kubesphere.io_clusters.yaml +++ b/config/crd/bases/kubekey.kubesphere.io_clusters.yaml @@ -195,6 +195,45 @@ spec: type: object status: description: ClusterStatus defines the observed state of Cluster + properties: + Conditions: + items: + properties: + endTime: + type: string + startTime: + type: string + status: + type: boolean + step: + type: string + type: object + type: array + etcdCount: + type: integer + masterCount: + type: integer + networkPlugin: + type: string + nodes: + items: + properties: + hostname: + type: string + internalIP: + type: string + roles: + additionalProperties: + type: boolean + type: object + type: object + type: array + nodesCount: + type: integer + version: + type: string + workerCount: + type: integer type: object type: object version: v1alpha1