Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1alpha1/broker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -48,6 +49,10 @@ type BrokerSpec struct {
// +optional
// default: report-interval: 10s, url: http://broker1:9000/api/v1/write?db=_internal
Monitor MonitorSpec `json:"monitor,omitempty"`

// the resource configuration
// +optional
Resource corev1.ResourceList `json:"resource,omitempty"`
}

type LoggingSpec struct {
Expand Down
31 changes: 21 additions & 10 deletions api/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Enum={"Pending", "Running", "Failed"}
// ClusterPhaseStatus is the status of the cluster

type ClusterPhaseStatus string

const (
ClusterPending ClusterPhaseStatus = "Pending"
ClusterRunning ClusterPhaseStatus = "Running"
ClusterFailed ClusterPhaseStatus = "Failed"
)

// ClusterSpec defines the desired state of Cluster

type ClusterSpec struct {
Expand Down Expand Up @@ -87,21 +99,20 @@ type CloudStorageSpec struct {
// +kubebuilder:validation:Required
// +kubebuilder:default:="/data"
MountPath string `json:"mountPath,omitempty"`

// recycling strategy
// +kubebuilder:validation:Required
// +kubebuilder:default:="Delete"
// +kubebuilder:validation:Enum={"Delete", "Retain"}
RecyclingStrategy string `json:"recyclingStrategy,omitempty"`
}

// ClusterStatus defines the observed state of Cluster
type ClusterStatus struct {
// the status of cluster
// +kubebuilder:validation:Optional
ClusterStatus string `json:"clusterStatus,omitempty"`

// the status of brokers
// +optional
BrokerStatuses BrokerStatus `json:"brokerStatuses,omitempty"`

// the status of storages
// +optional
StorageStatuses StorageStatus `json:"storageStatuses,omitempty"`
// +kubebuilder:default:="Pending"
// +kubebuilder:printcolumn:name="Phase",type=string,JSONPath=`.status.phaseStatus`
PhaseStatus ClusterPhaseStatus `json:"phaseStatus,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
5 changes: 5 additions & 0 deletions api/v1alpha1/storage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -45,6 +46,10 @@ type StorageSpec struct {
// +optional
// default: report-interval: 10s, url: http://broker1:9000/api/v1/write?db=_internal
Monitor MonitorSpec `json:"monitor,omitempty"`

// the resource configuration
// +optional
Resource corev1.ResourceList `json:"resource,omitempty"`
}

// StorageStatus defines the observed state of Storage
Expand Down
17 changes: 15 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

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

45 changes: 45 additions & 0 deletions config/crd/bases/lindb.lindb.io_brokers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,51 @@ spec:
identity. If unspecified, defaults to 1. default: 1'
format: int32
type: integer
resources:
description: Resources are not allowed for ephemeral containers. Ephemeral
containers use spare resources already allocated to the pod.
properties:
claims:
description: "Claims lists the names of resources, defined in
spec.resourceClaims, that are used by this container. \n This
is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in pod.spec.resourceClaims
of the Pod where this field is used. It makes that resource
available inside a container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-type: set
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
type: object
status:
description: BrokerStatus defines the observed state of Broker
Expand Down
90 changes: 71 additions & 19 deletions config/crd/bases/lindb.lindb.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,53 @@ spec:
1. default: 1'
format: int32
type: integer
resources:
description: Resources are not allowed for ephemeral containers.
Ephemeral containers use spare resources already allocated to
the pod.
properties:
claims:
description: "Claims lists the names of resources, defined
in spec.resourceClaims, that are used by this container.
\n This is an alpha field and requires enabling the DynamicResourceAllocation
feature gate. \n This field is immutable."
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
properties:
name:
description: Name must match the name of one entry in
pod.spec.resourceClaims of the Pod where this field
is used. It makes that resource available inside a
container.
type: string
required:
- name
type: object
type: array
x-kubernetes-list-type: set
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Limits describes the maximum amount of compute
resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: 'Requests describes the minimum amount of compute
resources required. If Requests is omitted for a container,
it defaults to Limits if that is explicitly specified, otherwise
to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
type: object
cloud:
description: Cloud is the cloud configuration
Expand All @@ -92,6 +139,13 @@ spec:
default: /data
description: mountPath is the mount path of the cloud storage
type: string
recyclingStrategy:
default: Delete
description: recycling strategy
enum:
- Delete
- Retain
type: string
storageClass:
default: gp2
description: storageClass is the storage class of the cloud
Expand Down Expand Up @@ -135,6 +189,17 @@ spec:
storages:
description: storage is the storage configuration
properties:
Resource:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources are not allowed for ephemeral containers.
Ephemeral containers use spare resources already allocated to
the pod.
type: object
grpcPort:
description: 'the port of storage grpc server default: 2891'
format: int32
Expand Down Expand Up @@ -167,27 +232,14 @@ spec:
status:
description: ClusterStatus defines the observed state of Cluster
properties:
brokerStatuses:
description: the status of brokers
properties:
status:
description: the status of broker
type: string
type: object
clusterStatus:
phaseStatus:
default: Pending
description: the status of cluster
enum:
- Pending
- Running
- Failed
type: string
storageStatuses:
description: the status of storages
properties:
myid:
description: the indicator of storage
format: int32
type: integer
status:
description: the status of storage
type: string
type: object
type: object
type: object
served: true
Expand Down
10 changes: 10 additions & 0 deletions config/crd/bases/lindb.lindb.io_storages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ spec:
spec:
description: StorageSpec defines the desired state of Storage
properties:
Resource:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: Resources are not allowed for ephemeral containers. Ephemeral
containers use spare resources already allocated to the pod.
type: object
grpcPort:
description: 'the port of storage grpc server default: 2891'
format: int32
Expand Down
18 changes: 10 additions & 8 deletions controllers/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ type ClusterReconciler struct {
func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)

var lindbCluster = alpha1.Cluster{}
err := r.Get(ctx, req.NamespacedName, &lindbCluster)
if err != nil {
return ctrl.Result{}, err
var cls = alpha1.Cluster{}

if err := r.Get(ctx, req.NamespacedName, &cls); err != nil {
logger.Error(err, "unable to fetch LindbCluster")
return ctrl.Result{}, client.IgnoreNotFound(err)
}
logger.Info("Reconciling Lindb cluster", "cluster", lindbCluster.Namespace+"/"+lindbCluster.Name)

if apierrors.IsNotFound(err) || lindbCluster.GetDeletionTimestamp() != nil {
return r.reconcileDelete(ctx, &lindbCluster)
if cls.GetDeletionTimestamp() != nil {
return r.reconcileNormal(ctx, &cls)
}

return r.reconcileNormal(ctx, &lindbCluster)
logger.Info("Reconciling Lindb cluster", "cluster", cls.Namespace+"/"+cls.Name)

return r.reconcileNormal(ctx, &cls)
}

func (r *ClusterReconciler) reconcileNormal(ctx context.Context, cluster *alpha1.Cluster) (ctrl.Result, error) {
Expand Down