diff --git a/api/v1beta1/automq_types.go b/api/v1beta1/automq_types.go index 25278c2..fc62cdb 100644 --- a/api/v1beta1/automq_types.go +++ b/api/v1beta1/automq_types.go @@ -100,6 +100,8 @@ type ControllerSpec struct { Resource v1.ResourceRequirements `json:"resource,omitempty"` // Affinity is the affinity for the controller Affinity *AffinitySpec `json:"affinity,omitempty"` + // StorageClass is the storage class for the controller + StorageClass string `json:"storageClass,omitempty"` } type BrokerSpec struct { @@ -114,6 +116,8 @@ type BrokerSpec struct { Resource v1.ResourceRequirements `json:"resource,omitempty"` // Affinity is the affinity for the broker Affinity *AffinitySpec `json:"affinity,omitempty"` + // StorageClass is the storage class for the controller + StorageClass string `json:"storageClass,omitempty"` } // MetricsSpec is the metrics configuration for the AutoMQ diff --git a/config/crd/bases/infra.cuisongliu.github.com_automqs.yaml b/config/crd/bases/infra.cuisongliu.github.com_automqs.yaml index 3f9834a..8780161 100644 --- a/config/crd/bases/infra.cuisongliu.github.com_automqs.yaml +++ b/config/crd/bases/infra.cuisongliu.github.com_automqs.yaml @@ -294,6 +294,9 @@ spec: More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ type: object type: object + storageClass: + description: StorageClass is the storage class for the controller + type: string type: object clusterID: description: ClusterID is the ID of the cluster. Default is "rZdE0DjZSrqy96PXrMUZVw" @@ -543,6 +546,9 @@ spec: More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ type: object type: object + storageClass: + description: StorageClass is the storage class for the controller + type: string type: object image: description: Image is the image of the AutoMQ diff --git a/deploy/charts/automq-operator/crds/infra.cuisongliu.github.com_automqs.yaml b/deploy/charts/automq-operator/crds/infra.cuisongliu.github.com_automqs.yaml index 3f9834a..8780161 100644 --- a/deploy/charts/automq-operator/crds/infra.cuisongliu.github.com_automqs.yaml +++ b/deploy/charts/automq-operator/crds/infra.cuisongliu.github.com_automqs.yaml @@ -294,6 +294,9 @@ spec: More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ type: object type: object + storageClass: + description: StorageClass is the storage class for the controller + type: string type: object clusterID: description: ClusterID is the ID of the cluster. Default is "rZdE0DjZSrqy96PXrMUZVw" @@ -543,6 +546,9 @@ spec: More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ type: object type: object + storageClass: + description: StorageClass is the storage class for the controller + type: string type: object image: description: Image is the image of the AutoMQ diff --git a/internal/controller/automq_controller.go b/internal/controller/automq_controller.go index c525191..6fd3883 100644 --- a/internal/controller/automq_controller.go +++ b/internal/controller/automq_controller.go @@ -206,3 +206,33 @@ func (r *AutoMQReconciler) s3Service(ctx context.Context, obj *infrav1beta1.Auto }) return ctx } + +func (r *AutoMQReconciler) scriptConfigmap(ctx context.Context, obj *infrav1beta1.AutoMQ) context.Context { + conditionType := "SyncS3ServiceReady" + sg, err := storage.NewBucket(storage.Config{ + Type: "s3", + Key: obj.Spec.S3.AccessKeyID, + Secret: obj.Spec.S3.SecretAccessKey, + Region: obj.Spec.S3.Region, + Endpoint: obj.Spec.S3.Endpoint, + }) + if err != nil { + meta.SetStatusCondition(&obj.Status.Conditions, metav1.Condition{ + Type: conditionType, + Status: metav1.ConditionFalse, + ObservedGeneration: obj.Generation, + Reason: "AwsS3ReconcilingInit", + Message: fmt.Sprintf("Failed to create S3 Bucket interface for the custom resource (%s): (%s)", obj.Name, err), + }) + return ctx + } + _ = sg.MkBucket(ctx, obj.Spec.S3.Bucket) + meta.SetStatusCondition(&obj.Status.Conditions, metav1.Condition{ + Type: conditionType, + Status: metav1.ConditionTrue, + ObservedGeneration: obj.Generation, + Reason: "AwsS3Reconciling", + Message: fmt.Sprintf("S3 Bucket interface for the custom resource (%s) has been created", obj.Name), + }) + return ctx +}