Skip to content

Commit

Permalink
Merge branch 'main' into support/refine-cluster-component-v1-api
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf committed Sep 14, 2024
2 parents 47eabd6 + b6416ec commit 7a6100b
Show file tree
Hide file tree
Showing 31 changed files with 339 additions and 458 deletions.
69 changes: 0 additions & 69 deletions apis/apps/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,75 +548,6 @@ type ClusterComponentService struct {
PodService *bool `json:"podService,omitempty"`
}

// UserResourceRefs defines references to user-defined Secrets and ConfigMaps.
type UserResourceRefs struct {
// SecretRefs defines the user-defined Secrets.
//
// +patchMergeKey=name
// +patchStrategy=merge,retainKeys
// +listType=map
// +listMapKey=name
// +optional
SecretRefs []SecretRef `json:"secretRefs,omitempty"`

// ConfigMapRefs defines the user-defined ConfigMaps.
//
// +patchMergeKey=name
// +patchStrategy=merge,retainKeys
// +listType=map
// +listMapKey=name
// +optional
ConfigMapRefs []ConfigMapRef `json:"configMapRefs,omitempty"`
}

// SecretRef defines a reference to a Secret.
type SecretRef struct {
ResourceMeta `json:",inline"`

// Secret specifies the Secret to be mounted as a volume.
//
// +kubebuilder:validation:Required
Secret corev1.SecretVolumeSource `json:"secret"`
}

// ConfigMapRef defines a reference to a ConfigMap.
type ConfigMapRef struct {
ResourceMeta `json:",inline"`

// ConfigMap specifies the ConfigMap to be mounted as a volume.
//
// +kubebuilder:validation:Required
ConfigMap corev1.ConfigMapVolumeSource `json:"configMap"`
}

// ResourceMeta encapsulates metadata and configuration for referencing ConfigMaps and Secrets as volumes.
type ResourceMeta struct {
// Name is the name of the referenced ConfigMap or Secret object. It must conform to DNS label standards.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
Name string `json:"name"`

// MountPoint is the filesystem path where the volume will be mounted.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=256
// +kubebuilder:validation:Pattern:=`^/[a-z]([a-z0-9\-]*[a-z0-9])?$`
MountPoint string `json:"mountPoint"`

// SubPath specifies a path within the volume from which to mount.
//
// +optional
SubPath string `json:"subPath,omitempty"`

// AsVolumeFrom lists the names of containers in which the volume should be mounted.
//
// +listType=set
// +optional
AsVolumeFrom []string `json:"asVolumeFrom,omitempty"`
}

// ShardingSpec defines how KubeBlocks manage dynamic provisioned shards.
// A typical design pattern for distributed databases is to distribute data across multiple shards,
// with each shard consisting of multiple replicas.
Expand Down
1 change: 0 additions & 1 deletion apis/apps/v1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ type ComponentSpec struct {
Volumes []corev1.Volume `json:"volumes,omitempty"`

// Overrides Services defined in referenced ComponentDefinition.
// by clients.
//
// +optional
Services []ComponentService `json:"services,omitempty"`
Expand Down
7 changes: 6 additions & 1 deletion apis/apps/v1/componentdefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,9 +997,9 @@ type ComponentTemplateSpec struct {
// template will be mounted to the corresponding volume. Must be a DNS_LABEL name.
// The volume name must be defined in podSpec.containers[*].volumeMounts.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
// +optional
VolumeName string `json:"volumeName"`

// The operator attempts to set default file permissions for scripts (0555) and configurations (0444).
Expand Down Expand Up @@ -1104,6 +1104,11 @@ type ComponentConfigSpec struct {
// +listType=set
// +optional
ReRenderResourceTypes []RerenderResourceType `json:"reRenderResourceTypes,omitempty"`

// Whether to store the final rendered parameters as a secret.
//
// +optional
AsSecret *bool `json:"asSecret,omitempty"`
}

// LegacyRenderedTemplateSpec describes the configuration extension for the lazy rendered template.
Expand Down
88 changes: 5 additions & 83 deletions apis/apps/v1/zz_generated.deepcopy.go

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

4 changes: 4 additions & 0 deletions apis/apps/v1alpha1/config_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ func (configSpec *ComponentConfigSpec) InjectEnvEnabled() bool {
return len(configSpec.AsEnvFrom) > 0 || len(configSpec.InjectEnvTo) > 0
}

func (configSpec *ComponentConfigSpec) ToSecret() bool {
return configSpec.AsSecret != nil && *configSpec.AsSecret
}

func (configSpec *ComponentConfigSpec) ContainersInjectedTo() []string {
if len(configSpec.InjectEnvTo) != 0 {
return configSpec.InjectEnvTo
Expand Down
7 changes: 6 additions & 1 deletion apis/apps/v1alpha1/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ type ComponentTemplateSpec struct {
// template will be mounted to the corresponding volume. Must be a DNS_LABEL name.
// The volume name must be defined in podSpec.containers[*].volumeMounts.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
// +optional
VolumeName string `json:"volumeName"`

// The operator attempts to set default file permissions for scripts (0555) and configurations (0444).
Expand Down Expand Up @@ -201,6 +201,11 @@ type ComponentConfigSpec struct {
// +listType=set
// +optional
ReRenderResourceTypes []RerenderResourceType `json:"reRenderResourceTypes,omitempty"`

// Whether to store the final rendered parameters as a secret.
//
// +optional
AsSecret *bool `json:"asSecret,omitempty"`
}

// RerenderResourceType defines the resource requirements for a component.
Expand Down
5 changes: 5 additions & 0 deletions apis/apps/v1alpha1/zz_generated.deepcopy.go

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

6 changes: 4 additions & 2 deletions config/crd/bases/apps.kubeblocks.io_clusterdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ spec:
type: string
type: array
x-kubernetes-list-type: set
asSecret:
description: Whether to store the final rendered parameters
as a secret.
type: boolean
constraintRef:
description: Specifies the name of the referenced configuration
constraints object.
Expand Down Expand Up @@ -552,7 +556,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -9112,7 +9115,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
12 changes: 8 additions & 4 deletions config/crd/bases/apps.kubeblocks.io_componentdefinitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ spec:
type: string
type: array
x-kubernetes-list-type: set
asSecret:
description: Whether to store the final rendered parameters
as a secret.
type: boolean
constraintRef:
description: Specifies the name of the referenced configuration
constraints object.
Expand Down Expand Up @@ -289,7 +293,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -11638,7 +11641,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -13260,6 +13262,10 @@ spec:
type: string
type: array
x-kubernetes-list-type: set
asSecret:
description: Whether to store the final rendered parameters
as a secret.
type: boolean
constraintRef:
description: Specifies the name of the referenced configuration
constraints object.
Expand Down Expand Up @@ -13411,7 +13417,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down Expand Up @@ -26667,7 +26672,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
type: array
x-kubernetes-list-map-keys:
Expand Down
4 changes: 1 addition & 3 deletions config/crd/bases/apps.kubeblocks.io_components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4974,9 +4974,7 @@ spec:
maxLength: 32
type: string
services:
description: |-
Overrides Services defined in referenced ComponentDefinition.
by clients.
description: Overrides Services defined in referenced ComponentDefinition.
items:
description: |-
ComponentService defines a service that would be exposed as an inter-component service within a Cluster.
Expand Down
5 changes: 4 additions & 1 deletion config/crd/bases/apps.kubeblocks.io_configurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ spec:
type: string
type: array
x-kubernetes-list-type: set
asSecret:
description: Whether to store the final rendered parameters
as a secret.
type: boolean
constraintRef:
description: Specifies the name of the referenced configuration
constraints object.
Expand Down Expand Up @@ -286,7 +290,6 @@ spec:
type: string
required:
- name
- volumeName
type: object
importTemplateRef:
description: |-
Expand Down
Loading

0 comments on commit 7a6100b

Please sign in to comment.