Skip to content

Commit

Permalink
chore: introduce the v1 version of component definition
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Jun 21, 2024
1 parent 8ed6732 commit 8ef4e8d
Show file tree
Hide file tree
Showing 10 changed files with 31,930 additions and 2 deletions.
8 changes: 8 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ resources:
defaulting: true
validation: true
webhookVersion: v1
- api:
crdVersion: v1
controller: true
domain: kubeblocks.io
group: apps
kind: ComponentDefinition
path: github.com/apecloud/kubeblocks/apis/apps/v1
version: v1
- api:
crdVersion: v1
namespaced: true
Expand Down
1,975 changes: 1,975 additions & 0 deletions apis/apps/v1/componentdefinition_types.go

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions apis/apps/v1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright (C) 2022-2024 ApeCloud Co., Ltd
This file is part of KubeBlocks project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

// Package v1 contains API Schema definitions for the apps v1 API group
// +kubebuilder:object:generate=true
// +groupName=apps.kubeblocks.io
package v1

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "apps.kubeblocks.io", Version: "v1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
111 changes: 111 additions & 0 deletions apis/apps/v1/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
Copyright (C) 2022-2024 ApeCloud Co., Ltd
This file is part of KubeBlocks project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package v1

import (
corev1 "k8s.io/api/core/v1"
)

// Phase represents the status of a CR.
//
// +enum
// +kubebuilder:validation:Enum={Available,Unavailable}
type Phase string

const (
// AvailablePhase indicates that a CR is in an available state.
AvailablePhase Phase = "Available"

// UnavailablePhase indicates that a CR is in an unavailable state.
UnavailablePhase Phase = "Unavailable"
)

// LetterCase defines the available cases to be used in password.
//
// +enum
// +kubebuilder:validation:Enum={LowerCases,UpperCases,MixedCases}
type LetterCase string

const (
// LowerCases represents the use of lower case letters only.
LowerCases LetterCase = "LowerCases"

// UpperCases represents the use of upper case letters only.
UpperCases LetterCase = "UpperCases"

// MixedCases represents the use of a mix of both lower and upper case letters.
MixedCases LetterCase = "MixedCases"
)

type Service struct {
// Name defines the name of the service.
// otherwise, it indicates the name of the service.
// Others can refer to this service by its name. (e.g., connection credential)
// Cannot be updated.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=25
Name string `json:"name"`

// ServiceName defines the name of the underlying service object.
// If not specified, the default service name with different patterns will be used:
//
// - CLUSTER_NAME: for cluster-level services
// - CLUSTER_NAME-COMPONENT_NAME: for component-level services
//
// Only one default service name is allowed.
// Cannot be updated.
//
// +kubebuilder:validation:MaxLength=25
// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
//
// +optional
ServiceName string `json:"serviceName,omitempty"`

// If ServiceType is LoadBalancer, cloud provider related parameters can be put here
// More info: https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer.
//
// +optional
Annotations map[string]string `json:"annotations,omitempty"`

// Spec defines the behavior of a service.
// https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
//
// +optional
Spec corev1.ServiceSpec `json:"spec,omitempty"`

// Extends the above `serviceSpec.selector` by allowing you to specify defined role as selector for the service.
// When `roleSelector` is set, it adds a label selector "kubeblocks.io/role: {roleSelector}"
// to the `serviceSpec.selector`.
// Example usage:
//
// roleSelector: "leader"
//
// In this example, setting `roleSelector` to "leader" will add a label selector
// "kubeblocks.io/role: leader" to the `serviceSpec.selector`.
// This means that the service will select and route traffic to Pods with the label
// "kubeblocks.io/role" set to "leader".
//
// Note that if `podService` sets to true, RoleSelector will be ignored.
// The `podService` flag takes precedence over `roleSelector` and generates a service for each Pod.
//
// +optional
RoleSelector string `json:"roleSelector,omitempty"`
}
Loading

0 comments on commit 8ef4e8d

Please sign in to comment.