diff --git a/api/v1alpha1/linodecluster_types.go b/api/v1alpha1/linodecluster_types.go index a0f1126e7..7b9595e4b 100644 --- a/api/v1alpha1/linodecluster_types.go +++ b/api/v1alpha1/linodecluster_types.go @@ -18,28 +18,53 @@ package v1alpha1 import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" + "sigs.k8s.io/cluster-api/errors" ) -// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! -// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. - // LinodeClusterSpec defines the desired state of LinodeCluster type LinodeClusterSpec struct { - // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster - // Important: Run "make" to regenerate code after modifying this file + // The Linode Region the LinodeCluster lives in. + Region string `json:"region"` + + // ControlPlaneEndpoint represents the endpoint used to communicate with the LinodeCluster control plane. + // If ControlPlaneEndpoint is unset then the Nodebalancer ip will be used. + // +optional + ControlPlaneEndpoint clusterv1.APIEndpoint `json:"controlPlaneEndpoint"` - // Foo is an example field of LinodeCluster. Edit linodecluster_types.go to remove/update - Foo string `json:"foo,omitempty"` + // NetworkSpec encapsulates all things related to Linode network. + // +optional + Network NetworkSpec `json:"network"` } // LinodeClusterStatus defines the observed state of LinodeCluster type LinodeClusterStatus struct { - // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster - // Important: Run "make" to regenerate code after modifying this file + // Ready denotes that the cluster (infrastructure) is ready. + // +optional + Ready bool `json:"ready"` + + // FailureReason will be set in the event that there is a terminal problem + // reconciling the Machine and will contain a succinct value suitable + // for machine interpretation. + // +optional + FailureReason *errors.MachineStatusError `json:"failureReason"` + + // FailureMessage will be set in the event that there is a terminal problem + // reconciling the Machine and will contain a more verbose string suitable + // for logging and human consumption. + // +optional + FailureMessage *string `json:"failureMessage"` + + // Conditions defines current service state of the LinodeCluster. + // +optional + Conditions clusterv1.Conditions `json:"conditions,omitempty"` } -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this LinodeCluster belongs" +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Cluster infrastructure is ready for Linode instances" +// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".spec.ControlPlaneEndpoint",description="API Endpoint",priority=1 // LinodeCluster is the Schema for the linodeclusters API type LinodeCluster struct { @@ -50,7 +75,22 @@ type LinodeCluster struct { Status LinodeClusterStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +func (lm *LinodeCluster) GetConditions() clusterv1.Conditions { + return lm.Status.Conditions +} + +func (lm *LinodeCluster) SetConditions(conditions clusterv1.Conditions) { + lm.Status.Conditions = conditions +} + +// NetworkSpec encapsulates Linode networking resources. +type NetworkSpec struct { + // NodebalancerID is the id of apiserver Nodebalancer. + // +optional + NodebalancerID int `json:"nodebalancerID,omitempty"` +} + +// +kubebuilder:object:root=true // LinodeClusterList contains a list of LinodeCluster type LinodeClusterList struct { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 624b53adc..29963df12 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -78,7 +78,7 @@ func (in *LinodeCluster) DeepCopyInto(out *LinodeCluster) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) out.Spec = in.Spec - out.Status = in.Status + in.Status.DeepCopyInto(&out.Status) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LinodeCluster. @@ -134,6 +134,8 @@ func (in *LinodeClusterList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LinodeClusterSpec) DeepCopyInto(out *LinodeClusterSpec) { *out = *in + out.ControlPlaneEndpoint = in.ControlPlaneEndpoint + out.Network = in.Network } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LinodeClusterSpec. @@ -149,6 +151,23 @@ func (in *LinodeClusterSpec) DeepCopy() *LinodeClusterSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LinodeClusterStatus) DeepCopyInto(out *LinodeClusterStatus) { *out = *in + if in.FailureReason != nil { + in, out := &in.FailureReason, &out.FailureReason + *out = new(errors.MachineStatusError) + **out = **in + } + if in.FailureMessage != nil { + in, out := &in.FailureMessage, &out.FailureMessage + *out = new(string) + **out = **in + } + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1beta1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LinodeClusterStatus. @@ -321,6 +340,21 @@ func (in *LinodeMachineStatus) DeepCopy() *LinodeMachineStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NetworkSpec) DeepCopyInto(out *NetworkSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkSpec. +func (in *NetworkSpec) DeepCopy() *NetworkSpec { + if in == nil { + return nil + } + out := new(NetworkSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPCIPv4) DeepCopyInto(out *VPCIPv4) { *out = *in diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_linodeclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_linodeclusters.yaml index cc747a459..706c0ceb3 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_linodeclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_linodeclusters.yaml @@ -14,7 +14,21 @@ spec: singular: linodecluster scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - description: Cluster to which this LinodeCluster belongs + jsonPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name + name: Cluster + type: string + - description: Cluster infrastructure is ready for Linode instances + jsonPath: .status.ready + name: Ready + type: string + - description: API Endpoint + jsonPath: .spec.ControlPlaneEndpoint + name: Endpoint + priority: 1 + type: string + name: v1alpha1 schema: openAPIV3Schema: description: LinodeCluster is the Schema for the linodeclusters API @@ -34,13 +48,97 @@ spec: spec: description: LinodeClusterSpec defines the desired state of LinodeCluster properties: - foo: - description: Foo is an example field of LinodeCluster. Edit linodecluster_types.go - to remove/update + controlPlaneEndpoint: + description: ControlPlaneEndpoint represents the endpoint used to + communicate with the LinodeCluster control plane. If ControlPlaneEndpoint + is unset then the Nodebalancer ip will be used. + properties: + host: + description: The hostname on which the API server is serving. + type: string + port: + description: The port on which the API server is serving. + format: int32 + type: integer + required: + - host + - port + type: object + network: + description: NetworkSpec encapsulates all things related to Linode + network. + properties: + nodebalancerID: + description: NodebalancerID is the id of apiserver Nodebalancer. + type: integer + type: object + region: + description: The Linode Region the LinodeCluster lives in. type: string + required: + - region type: object status: description: LinodeClusterStatus defines the observed state of LinodeCluster + properties: + conditions: + description: Conditions defines current service state of the LinodeCluster. + items: + description: Condition defines an observation of a Cluster API resource + operational state. + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. This should be when the underlying condition changed. + If that is not known, then using the time when the API field + changed is acceptable. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. This field may be empty. + type: string + reason: + description: The reason for the condition's last transition + in CamelCase. The specific API may choose whether or not this + field is considered a guaranteed API. This field may not be + empty. + type: string + severity: + description: Severity provides an explicit classification of + Reason code, so the users or machines can immediately understand + the current situation and act accordingly. The Severity field + MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + failureMessage: + description: FailureMessage will be set in the event that there is + a terminal problem reconciling the Machine and will contain a more + verbose string suitable for logging and human consumption. + type: string + failureReason: + description: FailureReason will be set in the event that there is + a terminal problem reconciling the Machine and will contain a succinct + value suitable for machine interpretation. + type: string + ready: + description: Ready denotes that the cluster (infrastructure) is ready. + type: boolean type: object type: object served: true