Skip to content

Commit

Permalink
add spec for LinodeCluster
Browse files Browse the repository at this point in the history
  • Loading branch information
eljohnson92 committed Jan 18, 2024
1 parent 2720a0e commit 6ff9692
Show file tree
Hide file tree
Showing 3 changed files with 189 additions and 17 deletions.
64 changes: 52 additions & 12 deletions api/v1alpha1/linodecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
36 changes: 35 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

106 changes: 102 additions & 4 deletions config/crd/bases/infrastructure.cluster.x-k8s.io_linodeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6ff9692

Please sign in to comment.