Skip to content

Commit

Permalink
feat: add datahome configure (#119)
Browse files Browse the repository at this point in the history
* chore: add datahome

* feat: add datahome field
  • Loading branch information
daviderli614 authored Dec 8, 2023
1 parent 6abec87 commit c583e7d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apis/v1alpha1/defaulting.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
// The default storage settings for datanode.
defaultDataNodeStorageName = "datanode"
defaultDataNodeStorageSize = "10Gi"
defaultDataNodeStorageMountPath = "/tmp/greptimedb"
defaultDataNodeStorageMountPath = "/data/greptimedb"
defaultStorageRetainPolicyType = RetainStorageRetainPolicyTypeRetain

defaultInitializer = "greptime/greptimedb-initializer:latest"
Expand Down
14 changes: 12 additions & 2 deletions apis/v1alpha1/greptimedbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,11 @@ type S3StorageProvider struct {
// The S3 directory path.
// +optional
Root string `json:"root,omitempty"`

// The datahome directory
// +optional
// +kubebuilder:default:="/data/greptimedb"
DataHome string `json:"dataHome,omitempty"`
}

type OSSStorageProvider struct {
Expand All @@ -440,14 +445,19 @@ type OSSStorageProvider struct {
// +optional
SecretName string `json:"secretName,omitempty"`

// The S3 directory path.
// The OSS directory path.
// +optional
Root string `json:"root,omitempty"`

// The datahome directory
// +optional
// +kubebuilder:default:="/data/greptimedb"
DataHome string `json:"dataHome,omitempty"`
}

type LocalStorageProvider struct {
// The local directory to store the data.
Directory string `json:"directory,omitempty"`
DataHome string `json:"dataHome,omitempty"`
}

// GreptimeDBClusterSpec defines the desired state of GreptimeDBCluster
Expand Down
8 changes: 7 additions & 1 deletion config/crd/bases/greptime.io_greptimedbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10724,13 +10724,16 @@ spec:
type: string
local:
properties:
directory:
dataHome:
type: string
type: object
oss:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand All @@ -10744,6 +10747,9 @@ spec:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand Down
8 changes: 7 additions & 1 deletion manifests/greptimedb-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10723,13 +10723,16 @@ spec:
type: string
local:
properties:
directory:
dataHome:
type: string
type: object
oss:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand All @@ -10743,6 +10746,9 @@ spec:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand Down
8 changes: 7 additions & 1 deletion manifests/greptimedb-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10730,13 +10730,16 @@ spec:
type: string
local:
properties:
directory:
dataHome:
type: string
type: object
oss:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand All @@ -10750,6 +10753,9 @@ spec:
properties:
bucket:
type: string
dataHome:
default: /data/greptimedb
type: string
endpoint:
type: string
region:
Expand Down
5 changes: 4 additions & 1 deletion pkg/dbconfig/datanode_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (c *DatanodeConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster)
if cluster.Spec.StorageProvider != nil {
if cluster.Spec.StorageProvider.Local != nil {
c.Storage.Type = "File"
c.Storage.DataHome = cluster.Spec.StorageProvider.Local.Directory
c.Storage.DataHome = cluster.Spec.StorageProvider.Local.DataHome
} else if cluster.Spec.StorageProvider.S3 != nil {
if cluster.Spec.StorageProvider.S3.SecretName != "" {
accessKeyID, secretAccessKey, err := c.getOCSCredentials(cluster.Namespace, cluster.Spec.StorageProvider.S3.SecretName)
Expand All @@ -174,6 +174,8 @@ func (c *DatanodeConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster)
c.Storage.Root = cluster.Spec.StorageProvider.S3.Root
c.Storage.Endpoint = cluster.Spec.StorageProvider.S3.Endpoint
c.Storage.Region = cluster.Spec.StorageProvider.S3.Region
c.Storage.DataHome = cluster.Spec.StorageProvider.S3.DataHome

} else if cluster.Spec.StorageProvider.OSS != nil {
if cluster.Spec.StorageProvider.OSS.SecretName != "" {
accessKeyID, secretAccessKey, err := c.getOCSCredentials(cluster.Namespace, cluster.Spec.StorageProvider.OSS.SecretName)
Expand All @@ -189,6 +191,7 @@ func (c *DatanodeConfig) ConfigureByCluster(cluster *v1alpha1.GreptimeDBCluster)
c.Storage.Root = cluster.Spec.StorageProvider.OSS.Root
c.Storage.Endpoint = cluster.Spec.StorageProvider.OSS.Endpoint
c.Storage.Region = cluster.Spec.StorageProvider.OSS.Region
c.Storage.DataHome = cluster.Spec.StorageProvider.OSS.DataHome
}
}

Expand Down

0 comments on commit c583e7d

Please sign in to comment.