Skip to content

Commit

Permalink
ci(main): add s3
Browse files Browse the repository at this point in the history
Signed-off-by: cuisongliu <[email protected]>
  • Loading branch information
cuisongliu committed Oct 4, 2024
1 parent 5fd1557 commit fd7e880
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/v1beta1/automq_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/infra.cuisongliu.github.com_automqs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
30 changes: 30 additions & 0 deletions internal/controller/automq_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit fd7e880

Please sign in to comment.