Skip to content

Commit

Permalink
fix automq
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu committed Sep 30, 2024
1 parent 1240a24 commit 8cd5423
Show file tree
Hide file tree
Showing 4 changed files with 896 additions and 12 deletions.
142 changes: 137 additions & 5 deletions api/v1beta1/automq_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,151 @@ limitations under the License.
package v1beta1

import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

type S3Spec struct {
// Endpoint is the endpoint of the S3 service
// +kubebuilder:validation:Required
Endpoint string `json:"endpoint,omitempty"`
// Region is the region of the S3 service
// +kubebuilder:validation:Required
// +kubebuilder:validation:Pattern=^[a-zA-Z0-9-]+$
Region string `json:"region,omitempty"`
// AccessKeyID is the access key ID of the S3 service
// +kubebuilder:validation:Required
AccessKeyID string `json:"accessKeyID,omitempty"`
// SecretAccessKey is the secret access key of the S3 service
// +kubebuilder:validation:Required
SecretAccessKey string `json:"secretAccessKey,omitempty"`
// Bucket is the bucket name for storing the operations data
// +kubebuilder:validation:Required
Bucket string `json:"bucket,omitempty"`
}

type NodeAffinity struct {
// Type is the type of the node affinity. Supported values are "soft" and "hard"
Type string `json:"type,omitempty"`
// NodeSelector is the node selector for the node affinity.
// +kubebuilder:minItems=1
NodeSelector []NodeSelector `json:"nodeSelector,omitempty"`
// Weight is the weight of the node affinity. When the type is "soft", the weight is used to select the node. Default is 40.
// +kubebuilder:default=40
Weight int32 `json:"weight,omitempty"`
}

type NodeSelector struct {
// Key is the key of the node selector
// +kubebuilder:validation:Required
Key string `json:"key,omitempty"`
// Values is the value of the node selector
// +kubebuilder:minItems=1
Values []string `json:"values,omitempty"`
}

type PodAffinity struct {
// Type is the type of the node affinity. Supported values are "soft" and "hard"
Type string `json:"type,omitempty"`
// Weight is the weight of the pod affinity. When the type is "soft", the weight is used to select the pods. Default is 40.
// +kubebuilder:default=40
Weight int32 `json:"weight,omitempty"`
}

type PodAntiAffinity struct {
// Type is the type of the node anti affinity. Supported values are "soft" and "hard"
Type string `json:"type,omitempty"`
// Weight is the weight of the pod anti affinity. When the type is "soft", the weight is used to select the pods. Default is 40.
// +kubebuilder:default=40
Weight int32 `json:"weight,omitempty"`
}

type AffinitySpec struct {
// NodeAffinity is the node affinity for the pod
NodeAffinity *NodeAffinity `json:"nodeAffinity,omitempty"`
// PodAntiAffinity is the pod anti-affinity for the pod
PodAntiAffinity *PodAntiAffinity `json:"podAntiAffinity,omitempty"`
// PodAffinity is the pod affinity for the pod
PodAffinity *PodAffinity `json:"podAffinity,omitempty"`
}

type ControllerSpec struct {
// Replicas is the number of controller replicas
// +kubebuilder:validation:Minimum=1
Replicas int32 `json:"replicas,omitempty"`
// JVMOptions is the JVM options for the controller
JVMOptions []string `json:"jvmOptions,omitempty"`
// Envs is the environment variables for the controller
Envs []v1.EnvVar `json:"envs,omitempty"`
// Resource is the resource requirements for the controller
Resource v1.ResourceRequirements `json:"resource,omitempty"`
// Affinity is the affinity for the controller
Affinity *AffinitySpec `json:"affinity,omitempty"`
}

type BrokerSpec struct {
// Replicas is the number of controller replicas
// +kubebuilder:validation:Minimum=1
Replicas int32 `json:"replicas,omitempty"`
// JVMOptions is the JVM options for the controller
JVMOptions []string `json:"jvmOptions,omitempty"`
// Envs is the environment variables for the controller
Envs []v1.EnvVar `json:"envs,omitempty"`
// Resource is the resource requirements for the controller
Resource v1.ResourceRequirements `json:"resource,omitempty"`
// Affinity is the affinity for the broker
Affinity *AffinitySpec `json:"affinity,omitempty"`
}

type MetricsType string

const (
Prometheus MetricsType = "prometheus"
OTLP MetricsType = "otlp"
)

type OtlpProtocol string

const (
GRPC OtlpProtocol = "grpc"
Http OtlpProtocol = "http"
)

// MetricsSpec is the metrics configuration for the AutoMQ
type MetricsSpec struct {
// Type is the type of the metrics. Supported values are "prometheus", "otlp"
// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=prometheus;otlp
// +kubebuilder:default=prometheus
Type MetricsType `json:"type,omitempty"`
// OtlpIp is the IP address of the OTLP server.
OtlpIp string `json:"otlpIp,omitempty"`
// OtlpPort is the port of the OTLP server.
OtlpPort int32 `json:"otlpPort,omitempty"`
// OtlpProtocol is the protocol of the OTLP server. Supported values are "grpc", "http"
OtlpProtocol OtlpProtocol `json:"otlpProtocol,omitempty"`
}

// AutoMQSpec defines the desired state of AutoMQ
type AutoMQSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of AutoMQ. Edit automq_types.go to remove/update
Foo string `json:"foo,omitempty"`
// S3 is the S3 configuration for the AutoMQ
// +kubebuilder:validation:Required
S3 S3Spec `json:"s3,omitempty"`
// ClusterID is the ID of the cluster. Default is "rZdE0DjZSrqy96PXrMUZVw"
// +kubebuilder:validation:Required
// +kubebuilder:validation:default=rZdE0DjZSrqy96PXrMUZVw
ClusterID string `json:"clusterID,omitempty"`
// Metrics is the metrics configuration for the AutoMQ
Metrics MetricsSpec `json:"metrics,omitempty"`
// Controller is the controller configuration for the AutoMQ
// +kubebuilder:validation:Required
Controller ControllerSpec `json:"controller,omitempty"`
// Broker is the broker configuration for the AutoMQ
// +kubebuilder:validation:Required
Broker BrokerSpec `json:"broker,omitempty"`
}

// AutoMQStatus defines the observed state of AutoMQ
Expand Down
205 changes: 204 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

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

Loading

0 comments on commit 8cd5423

Please sign in to comment.