diff --git a/examples/operator/computenode-hpa.yaml b/examples/operator/computenode-hpa.yaml new file mode 100644 index 00000000..1e56d0e3 --- /dev/null +++ b/examples/operator/computenode-hpa.yaml @@ -0,0 +1,43 @@ + # + # Licensed to the Apache Software Foundation (ASF) under one or more + # contributor license agreements. See the NOTICE file distributed with + # this work for additional information regarding copyright ownership. + # The ASF licenses this file to You under the Apache License, Version 2.0 + # (the "License"); you may not use this file except in compliance with + # the License. You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + # + +apiVersion: shardingsphere.apache.org/v1alpha1 +kind: AutoScaler +metadata: + name: foo +spec: + policyGroup: + - targetSelector: + objectRef: + apiVersion: shardingsphere.apache.org/v1alpha1 + kind: ComputeNode + name: foo + provider: KubernetesHPA + horizontal: + maxReplicas: 5 + minReplicas: 1 + scaleUpRules: + stabilizationWindowSeconds: 10 + scaleDownRules: + stabilizationWindowSeconds: 10 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 diff --git a/shardingsphere-operator/api/v1alpha1/autoscaler_types.go b/shardingsphere-operator/api/v1alpha1/autoscaler_types.go new file mode 100644 index 00000000..05d5c7fe --- /dev/null +++ b/shardingsphere-operator/api/v1alpha1/autoscaler_types.go @@ -0,0 +1,175 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v1alpha1 + +import ( + autoscalingv2 "k8s.io/api/autoscaling/v2" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + vpav1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" +) + +// +kubebuilder:object:root=true +// AutoScalerList contains a list of AutoScaler +type AutoScalerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []AutoScaler `json:"items"` +} + +// +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// AutoScaler defines a autoscaler for ShardingSphere given +type AutoScaler struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec AutoScalerSpec `json:"spec,omitempty"` + Status AutoScalerStatus `json:"status,omitempty"` +} + +// AutoScalerSpec defines a list of scaling policies +type AutoScalerSpec struct { + // PolicyGroup declares a set of scaling policies, including horizontal and vertical scaling + // Allow ComputeNode to enable HPA and VPA at the same time, without guaranteeing the result + // Haven't verified the configuration of HPA and VPA of StorageNode yet + PolicyGroup []ScalingPolicy `json:"policyGroup,omitempty" yaml:"policyGroup,omiempty"` +} + +// ScalingPolicy defines a policy for scaling +type ScalingPolicy struct { + // TargetSelector is used to select the auto-scaling target + // Support native CrossVersionObjectReference and Selector + // The first version plans to support CrossVersionObjectReference first + TargetSelector *ObjectRefSelector `json:"targetSelector,omitempty" yaml:"targetSelector,omitempty"` + + // Provider is the provider of the scaling mechanism, and the optional values are: + // - Empty: default value, which means provided by ShardingSphere Operator + // - KubernetesHPA: Indicates the use of Kubernetes native HPA + // - KubernetesVPA: Indicates the use of Kubernetes community VPA + // - Other: Indicates a controller using a third-party controller + // +optional + Provider string `json:"provider,omitempty" yaml:"provider,omitempty"` + + // HorizontalScaling contains the necessary parameters for HPA scaling + // Does not contain StorageNode related configuration + // +optional + Horizontal *HorizontalScaling `json:"horizontal,omitempty" yaml:"horizontal,omitempty"` + + // VerticalScaling contains the necessary parameters for VPA scaling + // Does not contain StorageNode related configuration + // +optional + Vertical *VerticalScaling `json:"vertical,omitempty" yaml:"vertical,omitempty"` +} + +// ObjectRefSelector defines a selector for objects +type ObjectRefSelector struct { + // +optional + ObjectRef autoscalingv2.CrossVersionObjectReference `json:"objectRef,omitempty" yaml:"objectRef,omitempty"` + // +optional + Selector *metav1.LabelSelector `json:"selector,omitempty" yaml:"selector,omitempty"` +} + +// The following configuration items are basically the same as HPA configuration, +// please refer to the corresponding documentation for descriptiontype +type HorizontalScaling struct { + // maxReplicas is the upper limit for the number of replicas to which the autoscaler can scale up. + // It cannot be less that minReplicas. + // +optional + MaxReplicas int32 `json:"maxReplicas,omitempty" yaml:"maxReplicas,omitempty"` + // minReplicas is the lower limit for the number of replicas to which the autoscaler + // can scale down. It defaults to 1 pod. minReplicas is allowed to be 0 if the + // alpha feature gate HPAScaleToZero is enabled and at least one Object or External + // metric is configured. Scaling is active as long as at least one metric value is + // available. + // +optional + MinReplicas int32 `json:"minReplicas,omitempty" yaml:"minReplicas,omitempty"` + + // scaleUp is scaling policy for scaling Up. + // If not set, the default value is the higher of: + // * increase no more than 4 pods per 60 seconds + // * double the number of pods per 60 seconds + // No stabilization is used. + // +optional + ScaleUpRules *autoscalingv2.HPAScalingRules `json:"scaleUpRules,omitempty" yaml:"scaleUpRules,omitempty"` + // scaleDown is scaling policy for scaling Down. + // If not set, the default value is to allow to scale down to minReplicas pods, with a + // 300 second stabilization window (i.e., the highest recommendation for + // the last 300sec is used). + // +optional + ScaleDownRules *autoscalingv2.HPAScalingRules `json:"scaleDownRules,omitempty" yaml:"scaleDownRules,omitempty"` + + // metrics contains the specifications for which to use to calculate the + // desired replica count (the maximum replica count across all metrics will + // be used). The desired replica count is calculated multiplying the + // ratio between the target value and the current value by the current + // number of pods. Ergo, metrics used must decrease as the pod count is + // increased, and vice-versa. See the individual metric source types for + // more information about how each type of metric must respond. + // If not set, the default metric will be set to 80% average CPU utilization. + // +optional + Metrics []autoscalingv2.MetricSpec `json:"metrics,omitempty" yaml:"metrics,omitempty"` +} + +// The following configuration items are basically the same as the VPA configuration, +// please refer to the corresponding documentation for instructions +type VerticalScaling struct { + // Describes the rules on how changes are applied to the pods. + // If not specified, all fields in the `PodUpdatePolicy` are set to their + // default values. + // +optional + UpdatePolicy *vpav1.PodUpdatePolicy `json:"updatePolicy,omitempty" yaml:"updatePolicy,omitempty"` + + // Controls how the autoscaler computes recommended resources. + // The resource policy may be used to set constraints on the recommendations + // for individual containers. If not specified, the autoscaler computes recommended + // resources for all containers in the pod, without additional constraints. + // +optional + ResourcePolicy *vpav1.PodResourcePolicy `json:"resourcePolicy,omitempty" yaml:"resourcePolicy,omitempty"` + + // Recommender responsible for generating recommendation for this object. + // List should be empty (then the default recommender will generate the + // recommendation) or contain exactly one recommender. + // +optional + Recommenders []vpav1.VerticalPodAutoscalerRecommenderSelector `json:"recommenders,omitempty" yaml:"recommenders,omitempty"` +} + +// AutoScalerStatus defines the status of a autoscaler +type AutoScalerStatus struct { + // +optional + Conditions []AutoScalerCondition `json:"conditions,omitempty" yaml:"conditions,omitempty"` +} + +// AutoScalerCondition defiens the condition of a autoscaler +type AutoScalerCondition struct { + Type AutoScalerConditionType `json:"type" protobuf:"bytes,1,name=type"` + Status v1.ConditionStatus `json:"status" protobuf:"bytes,2,name=status"` + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,3,opt,name=lastTransitionTime"` + Reason string `json:"reason,omitempty" protobuf:"bytes,4,opt,name=reason"` + Message string `json:"message,omitempty" protobuf:"bytes,5,opt,name=message"` +} + +type AutoScalerConditionType string + +const ( + ScalingReady AutoScalerConditionType = "ScalingReady" +) + +func init() { + SchemeBuilder.Register(&AutoScaler{}, &AutoScalerList{}) +} diff --git a/shardingsphere-operator/api/v1alpha1/compute_node_types.go b/shardingsphere-operator/api/v1alpha1/compute_node_types.go index 59172499..2c875f8e 100644 --- a/shardingsphere-operator/api/v1alpha1/compute_node_types.go +++ b/shardingsphere-operator/api/v1alpha1/compute_node_types.go @@ -35,7 +35,7 @@ type ComputeNodeList struct { // +kubebuilder:printcolumn:JSONPath=".status.loadBalancer.clusterIP",name="Cluster-IP",type=string // +kubebuilder:printcolumn:JSONPath=".spec.portBindings[*].servicePort",name="ServicePorts",type=integer // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name=Age,type=date -// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.spec.selectors +// +kubebuilder:subresource:scale:specpath=.spec.replicas,statuspath=.status.replicas,selectorpath=.status.selector // +kubebuilder:object:root=true // +kubebuilder:subresource:status // ComputeNode is the Schema for the ShardingSphere Proxy API @@ -289,6 +289,8 @@ type ComputeNodeSpec struct { // ComputeNodeStatus defines the observed state of ShardingSphere Proxy type ComputeNodeStatus struct { + Selector string `json:"selector" yaml:"selector"` + Replicas int32 `json:"replicas" yaml:"replicas"` Ready string `json:"ready,omitempty" yaml:"ready,omitempty"` diff --git a/shardingsphere-operator/api/v1alpha1/zz_generated.deepcopy.go b/shardingsphere-operator/api/v1alpha1/zz_generated.deepcopy.go index 01a9add9..12163ce2 100644 --- a/shardingsphere-operator/api/v1alpha1/zz_generated.deepcopy.go +++ b/shardingsphere-operator/api/v1alpha1/zz_generated.deepcopy.go @@ -23,10 +23,12 @@ package v1alpha1 import ( + "k8s.io/api/autoscaling/v2" "k8s.io/api/autoscaling/v2beta2" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + autoscaling_k8s_iov1 "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -104,6 +106,125 @@ func (in *Auth) DeepCopy() *Auth { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoScaler) DeepCopyInto(out *AutoScaler) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScaler. +func (in *AutoScaler) DeepCopy() *AutoScaler { + if in == nil { + return nil + } + out := new(AutoScaler) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AutoScaler) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoScalerCondition) DeepCopyInto(out *AutoScalerCondition) { + *out = *in + in.LastTransitionTime.DeepCopyInto(&out.LastTransitionTime) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScalerCondition. +func (in *AutoScalerCondition) DeepCopy() *AutoScalerCondition { + if in == nil { + return nil + } + out := new(AutoScalerCondition) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoScalerList) DeepCopyInto(out *AutoScalerList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AutoScaler, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScalerList. +func (in *AutoScalerList) DeepCopy() *AutoScalerList { + if in == nil { + return nil + } + out := new(AutoScalerList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AutoScalerList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoScalerSpec) DeepCopyInto(out *AutoScalerSpec) { + *out = *in + if in.PolicyGroup != nil { + in, out := &in.PolicyGroup, &out.PolicyGroup + *out = make([]ScalingPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScalerSpec. +func (in *AutoScalerSpec) DeepCopy() *AutoScalerSpec { + if in == nil { + return nil + } + out := new(AutoScalerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AutoScalerStatus) DeepCopyInto(out *AutoScalerStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]AutoScalerCondition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScalerStatus. +func (in *AutoScalerStatus) DeepCopy() *AutoScalerStatus { + if in == nil { + return nil + } + out := new(AutoScalerStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *AutomaticScaling) DeepCopyInto(out *AutomaticScaling) { *out = *in @@ -736,6 +857,38 @@ func (in *Endpoint) DeepCopy() *Endpoint { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HorizontalScaling) DeepCopyInto(out *HorizontalScaling) { + *out = *in + if in.ScaleUpRules != nil { + in, out := &in.ScaleUpRules, &out.ScaleUpRules + *out = new(v2.HPAScalingRules) + (*in).DeepCopyInto(*out) + } + if in.ScaleDownRules != nil { + in, out := &in.ScaleDownRules, &out.ScaleDownRules + *out = new(v2.HPAScalingRules) + (*in).DeepCopyInto(*out) + } + if in.Metrics != nil { + in, out := &in.Metrics, &out.Metrics + *out = make([]v2.MetricSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HorizontalScaling. +func (in *HorizontalScaling) DeepCopy() *HorizontalScaling { + if in == nil { + return nil + } + out := new(HorizontalScaling) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *InstanceStatus) DeepCopyInto(out *InstanceStatus) { *out = *in @@ -940,6 +1093,27 @@ func (in *NetworkChaosSpec) DeepCopy() *NetworkChaosSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ObjectRefSelector) DeepCopyInto(out *ObjectRefSelector) { + *out = *in + out.ObjectRef = in.ObjectRef + if in.Selector != nil { + in, out := &in.Selector, &out.Selector + *out = new(v1.LabelSelector) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectRefSelector. +func (in *ObjectRefSelector) DeepCopy() *ObjectRefSelector { + if in == nil { + return nil + } + out := new(ObjectRefSelector) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OpenTelemetry) DeepCopyInto(out *OpenTelemetry) { *out = *in @@ -1496,6 +1670,36 @@ func (in *Result) DeepCopy() *Result { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ScalingPolicy) DeepCopyInto(out *ScalingPolicy) { + *out = *in + if in.TargetSelector != nil { + in, out := &in.TargetSelector, &out.TargetSelector + *out = new(ObjectRefSelector) + (*in).DeepCopyInto(*out) + } + if in.Horizontal != nil { + in, out := &in.Horizontal, &out.Horizontal + *out = new(HorizontalScaling) + (*in).DeepCopyInto(*out) + } + if in.Vertical != nil { + in, out := &in.Vertical, &out.Vertical + *out = new(VerticalScaling) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ScalingPolicy. +func (in *ScalingPolicy) DeepCopy() *ScalingPolicy { + if in == nil { + return nil + } + out := new(ScalingPolicy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ServerConfig) DeepCopyInto(out *ServerConfig) { *out = *in @@ -1949,3 +2153,33 @@ func (in *User) DeepCopy() *User { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VerticalScaling) DeepCopyInto(out *VerticalScaling) { + *out = *in + if in.UpdatePolicy != nil { + in, out := &in.UpdatePolicy, &out.UpdatePolicy + *out = new(autoscaling_k8s_iov1.PodUpdatePolicy) + (*in).DeepCopyInto(*out) + } + if in.ResourcePolicy != nil { + in, out := &in.ResourcePolicy, &out.ResourcePolicy + *out = new(autoscaling_k8s_iov1.PodResourcePolicy) + (*in).DeepCopyInto(*out) + } + if in.Recommenders != nil { + in, out := &in.Recommenders, &out.Recommenders + *out = make([]autoscaling_k8s_iov1.VerticalPodAutoscalerRecommenderSelector, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VerticalScaling. +func (in *VerticalScaling) DeepCopy() *VerticalScaling { + if in == nil { + return nil + } + out := new(VerticalScaling) + in.DeepCopyInto(out) + return out +} diff --git a/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go b/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go index b4dcaeae..f0919efe 100644 --- a/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go +++ b/shardingsphere-operator/cmd/shardingsphere-operator/manager/option.go @@ -29,6 +29,7 @@ import ( "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/configmap" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/job" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/service" + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/reconcile/autoscaler" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/reconcile/computenode" chaosv1alpha1 "github.com/chaos-mesh/chaos-mesh/api/v1alpha1" @@ -184,4 +185,18 @@ var featureGatesHandlers = map[string]FeatureGateHandler{ } return nil }, + "AutoScaler": func(mgr manager.Manager) error { + if err := (&controllers.AutoScalerReconciler{ + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + Log: mgr.GetLogger(), + Builder: autoscaler.NewBuilder(), + Resources: kubernetes.NewResources(mgr.GetClient()), + }).SetupWithManager(mgr); err != nil { + logger.Error(err, "unable to create controller", "controller", "AutoScaler") + return err + } + + return nil + }, } diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_autoscalers.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_autoscalers.yaml new file mode 100644 index 00000000..af7a43a0 --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_autoscalers.yaml @@ -0,0 +1,917 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: autoscalers.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: AutoScaler + listKind: AutoScalerList + plural: autoscalers + singular: autoscaler + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: AutoScaler defines a autoscaler for ShardingSphere given + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: AutoScalerSpec defines a list of scaling policies + properties: + policyGroup: + description: PolicyGroup declares a set of scaling policies, including + horizontal and vertical scaling Allow ComputeNode to enable HPA + and VPA at the same time, without guaranteeing the result Haven't + verified the configuration of HPA and VPA of StorageNode yet + items: + description: ScalingPolicy defines a policy for scaling + properties: + horizontal: + description: HorizontalScaling contains the necessary parameters + for HPA scaling Does not contain StorageNode related configuration + properties: + maxReplicas: + description: maxReplicas is the upper limit for the number + of replicas to which the autoscaler can scale up. It cannot + be less that minReplicas. + format: int32 + type: integer + metrics: + description: metrics contains the specifications for which + to use to calculate the desired replica count (the maximum + replica count across all metrics will be used). The desired + replica count is calculated multiplying the ratio between + the target value and the current value by the current + number of pods. Ergo, metrics used must decrease as the + pod count is increased, and vice-versa. See the individual + metric source types for more information about how each + type of metric must respond. If not set, the default metric + will be set to 80% average CPU utilization. + items: + description: MetricSpec specifies how to scale based on + a single metric (only `type` and one other matching + field should be set at once). + properties: + containerResource: + description: containerResource refers to a resource + metric (such as those specified in requests and + limits) known to Kubernetes describing a single + container in each pod of the current scale target + (e.g. CPU or memory). Such metrics are built in + to Kubernetes, and have special scaling options + on top of those available to normal per-pod metrics + using the "pods" source. This is an alpha feature + and can be enabled by the HPAContainerMetrics feature + flag. + properties: + container: + description: container is the name of the container + in the pods of the scaling target + type: string + name: + description: name is the name of the resource + in question. + type: string + target: + description: target specifies the target value + for the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as + a percentage of the requested value of the + resource for the pods. Currently only valid + for Resource metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all + relevant pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of + the metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - container + - name + - target + type: object + external: + description: external refers to a global metric that + is not associated with any Kubernetes object. It + allows autoscaling based on information coming from + components running outside of cluster (for example + length of queue in cloud messaging service, or QPS + from loadbalancer running outside of cluster). + properties: + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given + metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be + used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The + requirements are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents + a key's relationship to a set + of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array + of string values. If the operator + is In or NotIn, the values array + must be non-empty. If the operator + is Exists or DoesNotExist, the + values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value + for the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as + a percentage of the requested value of the + resource for the pods. Currently only valid + for Resource metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all + relevant pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of + the metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + object: + description: object refers to a metric describing + a single kubernetes object (for example, hits-per-second + on an Ingress object). + properties: + describedObject: + description: describedObject specifies the descriptions + of a object,such as kind,name apiVersion + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: + https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent; More info: + http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given + metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be + used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The + requirements are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents + a key's relationship to a set + of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array + of string values. If the operator + is In or NotIn, the values array + must be non-empty. If the operator + is Exists or DoesNotExist, the + values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value + for the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as + a percentage of the requested value of the + resource for the pods. Currently only valid + for Resource metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all + relevant pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of + the metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - describedObject + - metric + - target + type: object + pods: + description: pods refers to a metric describing each + pod in the current scale target (for example, transactions-processed-per-second). The + values will be averaged together before being compared + to the target value. + properties: + metric: + description: metric identifies the target metric + by name and selector + properties: + name: + description: name is the name of the given + metric + type: string + selector: + description: selector is the string-encoded + form of a standard kubernetes label selector + for the given metric When set, it is passed + as an additional parameter to the metrics + server for more specific metrics scoping. + When unset, just the metricName will be + used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list + of label selector requirements. The + requirements are ANDed. + items: + description: A label selector requirement + is a selector that contains values, + a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key + that the selector applies to. + type: string + operator: + description: operator represents + a key's relationship to a set + of values. Valid operators are + In, NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array + of string values. If the operator + is In or NotIn, the values array + must be non-empty. If the operator + is Exists or DoesNotExist, the + values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator + is "In", and the values array contains + only "value". The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value + for the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as + a percentage of the requested value of the + resource for the pods. Currently only valid + for Resource metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all + relevant pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of + the metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + resource: + description: resource refers to a resource metric + (such as those specified in requests and limits) + known to Kubernetes describing each pod in the current + scale target (e.g. CPU or memory). Such metrics + are built in to Kubernetes, and have special scaling + options on top of those available to normal per-pod + metrics using the "pods" source. + properties: + name: + description: name is the name of the resource + in question. + type: string + target: + description: target specifies the target value + for the given metric + properties: + averageUtilization: + description: averageUtilization is the target + value of the average of the resource metric + across all relevant pods, represented as + a percentage of the requested value of the + resource for the pods. Currently only valid + for Resource metric source type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value + of the average of the metric across all + relevant pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of + the metric (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - name + - target + type: object + type: + description: 'type is the type of metric source. It + should be one of "ContainerResource", "External", + "Object", "Pods" or "Resource", each mapping to + a matching field in the object. Note: "ContainerResource" + type is available on when the feature-gate HPAContainerMetrics + is enabled' + type: string + required: + - type + type: object + type: array + minReplicas: + description: minReplicas is the lower limit for the number + of replicas to which the autoscaler can scale down. It + defaults to 1 pod. minReplicas is allowed to be 0 if + the alpha feature gate HPAScaleToZero is enabled and at + least one Object or External metric is configured. Scaling + is active as long as at least one metric value is available. + format: int32 + type: integer + scaleDownRules: + description: scaleDown is scaling policy for scaling Down. + If not set, the default value is to allow to scale down + to minReplicas pods, with a 300 second stabilization window + (i.e., the highest recommendation for the last 300sec + is used). + properties: + policies: + description: policies is a list of potential scaling + polices which can be used during scaling. At least + one policy must be specified, otherwise the HPAScalingRules + will be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: PeriodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and + less than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: Type is used to specify the scaling + policy. + type: string + value: + description: Value contains the amount of change + which is permitted by the policy. It must be + greater than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max + is used. + type: string + stabilizationWindowSeconds: + description: 'StabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. StabilizationWindowSeconds + must be greater than or equal to zero and less than + or equal to 3600 (one hour). If not set, use the default + values: - For scale up: 0 (i.e. no stabilization is + done). - For scale down: 300 (i.e. the stabilization + window is 300 seconds long).' + format: int32 + type: integer + type: object + scaleUpRules: + description: 'scaleUp is scaling policy for scaling Up. + If not set, the default value is the higher of: * increase + no more than 4 pods per 60 seconds * double the number + of pods per 60 seconds No stabilization is used.' + properties: + policies: + description: policies is a list of potential scaling + polices which can be used during scaling. At least + one policy must be specified, otherwise the HPAScalingRules + will be discarded as invalid + items: + description: HPAScalingPolicy is a single policy which + must hold true for a specified past interval. + properties: + periodSeconds: + description: PeriodSeconds specifies the window + of time for which the policy should hold true. + PeriodSeconds must be greater than zero and + less than or equal to 1800 (30 min). + format: int32 + type: integer + type: + description: Type is used to specify the scaling + policy. + type: string + value: + description: Value contains the amount of change + which is permitted by the policy. It must be + greater than zero + format: int32 + type: integer + required: + - periodSeconds + - type + - value + type: object + type: array + x-kubernetes-list-type: atomic + selectPolicy: + description: selectPolicy is used to specify which policy + should be used. If not set, the default value Max + is used. + type: string + stabilizationWindowSeconds: + description: 'StabilizationWindowSeconds is the number + of seconds for which past recommendations should be + considered while scaling up or scaling down. StabilizationWindowSeconds + must be greater than or equal to zero and less than + or equal to 3600 (one hour). If not set, use the default + values: - For scale up: 0 (i.e. no stabilization is + done). - For scale down: 300 (i.e. the stabilization + window is 300 seconds long).' + format: int32 + type: integer + type: object + type: object + provider: + description: 'Provider is the provider of the scaling mechanism, + and the optional values are: - Empty: default value, which + means provided by ShardingSphere Operator - KubernetesHPA: + Indicates the use of Kubernetes native HPA - KubernetesVPA: + Indicates the use of Kubernetes community VPA - Other: Indicates + a controller using a third-party controller' + type: string + targetSelector: + description: TargetSelector is used to select the auto-scaling + target Support native CrossVersionObjectReference and Selector + The first version plans to support CrossVersionObjectReference + first + properties: + objectRef: + description: CrossVersionObjectReference contains enough + information to let you identify the referred resource. + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + selector: + description: A label selector is a label query over a set + of resources. The result of matchLabels and matchExpressions + are ANDed. An empty label selector matches all objects. + A null label selector matches no objects. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values array + must be non-empty. If the operator is Exists + or DoesNotExist, the values array must be empty. + This array is replaced during a strategic merge + patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + A single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field + is "key", the operator is "In", and the values array + contains only "value". The requirements are ANDed. + type: object + type: object + type: object + vertical: + description: VerticalScaling contains the necessary parameters + for VPA scaling Does not contain StorageNode related configuration + properties: + recommenders: + description: Recommender responsible for generating recommendation + for this object. List should be empty (then the default + recommender will generate the recommendation) or contain + exactly one recommender. + items: + description: VerticalPodAutoscalerRecommenderSelector + points to a specific Vertical Pod Autoscaler recommender. + In the future it might pass parameters to the recommender. + properties: + name: + description: Name of the recommender responsible for + generating recommendation for this object. + type: string + required: + - name + type: object + type: array + resourcePolicy: + description: Controls how the autoscaler computes recommended + resources. The resource policy may be used to set constraints + on the recommendations for individual containers. If not + specified, the autoscaler computes recommended resources + for all containers in the pod, without additional constraints. + properties: + containerPolicies: + description: Per-container resource policies. + items: + description: ContainerResourcePolicy controls how + autoscaler computes the recommended resources for + a specific container. + properties: + containerName: + description: Name of the container or DefaultContainerResourcePolicy, + in which case the policy is used by the containers + that don't have their own policy specified. + type: string + controlledResources: + description: Specifies the type of recommendations + that will be computed (and possibly applied) + by VPA. If not specified, the default of [ResourceCPU, + ResourceMemory] will be used. + items: + description: ResourceName is the name identifying + various resources in a ResourceList. + type: string + type: array + controlledValues: + description: Specifies which resource values should + be controlled. The default is "RequestsAndLimits". + enum: + - RequestsAndLimits + - RequestsOnly + type: string + maxAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the maximum amount of resources + that will be recommended for the container. + The default is no maximum. + type: object + minAllowed: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Specifies the minimal amount of resources + that will be recommended for the container. + The default is no minimum. + type: object + mode: + description: Whether autoscaler is enabled for + the container. The default is "Auto". + enum: + - Auto + - "Off" + type: string + type: object + type: array + type: object + updatePolicy: + description: Describes the rules on how changes are applied + to the pods. If not specified, all fields in the `PodUpdatePolicy` + are set to their default values. + properties: + minReplicas: + description: Minimal number of replicas which need to + be alive for Updater to attempt pod eviction (pending + other checks like PDB). Only positive values are allowed. + Overrides global '--min-replicas' flag. + format: int32 + type: integer + updateMode: + description: Controls when autoscaler applies changes + to the pod resources. The default is 'Auto'. + enum: + - "Off" + - Initial + - Recreate + - Auto + type: string + type: object + type: object + type: object + type: array + type: object + status: + description: AutoScalerStatus defines the status of a autoscaler + properties: + conditions: + items: + description: AutoScalerCondition defiens the condition of a autoscaler + properties: + lastTransitionTime: + format: date-time + type: string + message: + type: string + reason: + type: string + status: + type: string + type: + type: string + required: + - status + - type + type: object + type: array + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_chaos.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_chaos.yaml new file mode 100644 index 00000000..6a37ef4a --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_chaos.yaml @@ -0,0 +1,447 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: chaos.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: Chaos + listKind: ChaosList + plural: chaos + singular: chaos + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: Chaos defines a chaos test case for the ShardingSphere Proxy + cluster + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ChaosSpec defines the desired state of Chaos + properties: + injectJob: + description: JobSpec specifies the config of job to create + properties: + experimental: + type: string + pressure: + type: string + verify: + type: string + type: object + networkChaos: + description: NetworkChaosSpec Fields that need to be configured for + network type chaos + properties: + action: + description: NetworkChaosAction specify the action type of network + Chaos + type: string + direction: + description: Direction specifies the direction of action of network + chaos + type: string + duration: + type: string + params: + description: NetworkParams Optional parameters for network type + configuration + properties: + corrupt: + properties: + corrupt: + type: string + type: object + delay: + properties: + jitter: + type: string + latency: + type: string + type: object + duplicate: + properties: + duplicate: + type: string + type: object + loss: + properties: + loss: + type: string + type: object + type: object + source: + description: PodSelector used to select the target of the specified + chaos + properties: + annotationSelectors: + additionalProperties: + type: string + type: object + expressionSelectors: + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + labelSelectors: + additionalProperties: + type: string + type: object + namespaces: + items: + type: string + type: array + nodeSelectors: + additionalProperties: + type: string + type: object + nodes: + items: + type: string + type: array + pods: + additionalProperties: + items: + type: string + type: array + type: object + type: object + target: + description: PodSelector used to select the target of the specified + chaos + properties: + annotationSelectors: + additionalProperties: + type: string + type: object + expressionSelectors: + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + labelSelectors: + additionalProperties: + type: string + type: object + namespaces: + items: + type: string + type: array + nodeSelectors: + additionalProperties: + type: string + type: object + nodes: + items: + type: string + type: array + pods: + additionalProperties: + items: + type: string + type: array + type: object + type: object + type: object + podChaos: + description: PodChaosSpec Fields that need to be configured for pod + type chaos + properties: + action: + description: PodChaosAction Specify the action type of pod Chaos + type: string + params: + description: PodActionParams Optional parameters for pod type + configuration + properties: + containerKill: + properties: + containerNames: + items: + type: string + type: array + type: object + cpuStress: + properties: + cores: + type: integer + duration: + type: string + load: + type: integer + required: + - duration + type: object + memoryStress: + properties: + consumption: + type: string + duration: + type: string + workers: + type: integer + required: + - duration + type: object + podFailure: + properties: + duration: + type: string + type: object + podKill: + properties: + gracePeriod: + format: int64 + type: integer + type: object + type: object + selector: + description: PodSelector used to select the target of the specified + chaos + properties: + annotationSelectors: + additionalProperties: + type: string + type: object + expressionSelectors: + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that relates + the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, NotIn, + Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. If + the operator is In or NotIn, the values array must + be non-empty. If the operator is Exists or DoesNotExist, + the values array must be empty. This array is replaced + during a strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + labelSelectors: + additionalProperties: + type: string + type: object + namespaces: + items: + type: string + type: array + nodeSelectors: + additionalProperties: + type: string + type: object + nodes: + items: + type: string + type: array + pods: + additionalProperties: + items: + type: string + type: array + type: object + type: object + required: + - action + type: object + pressureCfg: + properties: + concurrentNum: + type: integer + distSQLs: + items: + properties: + args: + items: + type: string + type: array + sql: + type: string + required: + - sql + type: object + type: array + duration: + type: string + reqNum: + type: integer + reqTime: + type: string + ssHost: + type: string + zkHost: + type: string + required: + - concurrentNum + - duration + - reqNum + - reqTime + - ssHost + type: object + type: object + status: + description: ChaosStatus defines the actual state of Chaos + properties: + chaosCondition: + description: ChaosCondition Show Chaos Progress + type: string + conditions: + description: Result Result `json:"result,omitempty" yaml:"result,omitempty"` + items: + description: "Condition contains details for one aspect of the current + state of this API Resource. --- This struct is intended for direct + use as an array at the field path .status.conditions. For example, + \n type FooStatus struct{ // Represents the observations of a + foo's current state. // Known .status.conditions.type are: \"Available\", + \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge + // +listType=map // +listMapKey=type Conditions []metav1.Condition + `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" + protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" + properties: + lastTransitionTime: + description: lastTransitionTime is the last time the condition + transitioned from one status to another. This should be when + the underlying condition changed. If that is not known, then + using the time when the API field changed is acceptable. + format: date-time + type: string + message: + description: message is a human readable message indicating + details about the transition. This may be an empty string. + maxLength: 32768 + type: string + observedGeneration: + description: observedGeneration represents the .metadata.generation + that the condition was set based upon. For instance, if .metadata.generation + is currently 12, but the .status.conditions[x].observedGeneration + is 9, the condition is out of date with respect to the current + state of the instance. + format: int64 + minimum: 0 + type: integer + reason: + description: reason contains a programmatic identifier indicating + the reason for the condition's last transition. Producers + of specific condition types may define expected values and + meanings for this field, and whether the values are considered + a guaranteed API. The value should be a CamelCase string. + This field may not be empty. + maxLength: 1024 + minLength: 1 + pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ + type: string + status: + description: status of the condition, one of True, False, Unknown. + enum: + - "True" + - "False" + - Unknown + type: string + type: + description: type of condition in CamelCase or in foo.example.com/CamelCase. + --- Many .condition.type values are consistent across resources + like Available, but because arbitrary conditions can be useful + (see .node.status.conditions), the ability to deconflict is + important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + required: + - lastTransitionTime + - message + - reason + - status + - type + type: object + type: array + phase: + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_computenodes.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_computenodes.yaml new file mode 100644 index 00000000..f3b0e585 --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_computenodes.yaml @@ -0,0 +1,1043 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: computenodes.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: ComputeNode + listKind: ComputeNodeList + plural: computenodes + singular: computenode + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.ready + name: Ready + type: string + - jsonPath: .status.phase + name: Status + type: string + - jsonPath: .status.loadBalancer.clusterIP + name: Cluster-IP + type: string + - jsonPath: .spec.portBindings[*].servicePort + name: ServicePorts + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: ComputeNode is the Schema for the ShardingSphere Proxy API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ProxySpec defines the desired state of ShardingSphereProxy + properties: + bootstrap: + description: BootstrapConfig is used for any ShardingSphere Proxy + startup + properties: + agentConfig: + description: AgentConfig defines the config for ShardingSphere-Agent, + renderred as agent.yaml + properties: + plugins: + description: AgentPlugin defines a set of plugins for ShardingSphere + Agent + properties: + logging: + description: PluginLogging defines the plugin for logging + properties: + file: + properties: + props: + additionalProperties: + type: string + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + metrics: + description: PluginMetrics defines the plugin for metrics + properties: + prometheus: + properties: + host: + type: string + port: + format: int32 + type: integer + props: + additionalProperties: + type: string + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - host + - port + type: object + type: object + tracing: + description: PluginTracing defines the plugin for tracing + properties: + openTelemetry: + properties: + props: + additionalProperties: + type: string + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + openTracing: + properties: + props: + additionalProperties: + type: string + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + type: object + type: object + logbackConfig: + description: LogbackConfig contains contents of the expected logback.xml + type: string + serverConfig: + description: ServerConfig defines the bootstrap config for a ShardingSphere + Proxy + properties: + authority: + description: ComputeNodeAuthority is used to set up initial + user to login compute node, and authority data of storage + node. + properties: + privilege: + description: ComputeNodePrivilege for storage node, the + default value is ALL_PERMITTED + properties: + type: + type: string + type: object + users: + items: + description: 'ComputeNodeUser is a slice about authorized + host and password for compute node. Format: user:@,hostname + is % or empty string means do not care about authorized + host password:' + properties: + password: + type: string + user: + type: string + required: + - password + - user + type: object + type: array + type: object + mode: + description: ComputeNodeServerMode is the mode for ShardingSphere + Proxy + properties: + repository: + description: Repository is the metadata persistent store + for ShardingSphere + properties: + props: + additionalProperties: + type: string + description: properties of metadata repository + type: object + x-kubernetes-preserve-unknown-fields: true + type: + description: type of metadata repository + enum: + - ZooKeeper + - Etcd + type: string + type: object + type: + type: string + type: object + props: + additionalProperties: + type: string + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + type: object + env: + items: + description: EnvVar represents an environment variable present in + a Container. + properties: + name: + description: Name of the environment variable. Must be a C_IDENTIFIER. + type: string + value: + description: 'Variable references $(VAR_NAME) are expanded using + the previously defined environment variables in the container + and any service environment variables. If a variable cannot + be resolved, the reference in the input string will be unchanged. + Double $$ are reduced to a single $, which allows for escaping + the $(VAR_NAME) syntax: i.e. "$$(VAR_NAME)" will produce the + string literal "$(VAR_NAME)". Escaped references will never + be expanded, regardless of whether the variable exists or + not. Defaults to "".' + type: string + valueFrom: + description: Source for the environment variable's value. Cannot + be used if value is not empty. + properties: + configMapKeyRef: + description: Selects a key of a ConfigMap. + properties: + key: + description: The key to select. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the ConfigMap or its key + must be defined + type: boolean + required: + - key + type: object + fieldRef: + description: 'Selects a field of the pod: supports metadata.name, + metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, + spec.nodeName, spec.serviceAccountName, status.hostIP, + status.podIP, status.podIPs.' + properties: + apiVersion: + description: Version of the schema the FieldPath is + written in terms of, defaults to "v1". + type: string + fieldPath: + description: Path of the field to select in the specified + API version. + type: string + required: + - fieldPath + type: object + resourceFieldRef: + description: 'Selects a resource of the container: only + resources limits and requests (limits.cpu, limits.memory, + limits.ephemeral-storage, requests.cpu, requests.memory + and requests.ephemeral-storage) are currently supported.' + properties: + containerName: + description: 'Container name: required for volumes, + optional for env vars' + type: string + divisor: + anyOf: + - type: integer + - type: string + description: Specifies the output format of the exposed + resources, defaults to "1" + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + resource: + description: 'Required: resource to select' + type: string + required: + - resource + type: object + secretKeyRef: + description: Selects a key of a secret in the pod's namespace + properties: + key: + description: The key of the secret to select from. Must + be a valid secret key. + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + optional: + description: Specify whether the Secret or its key must + be defined + type: boolean + required: + - key + type: object + type: object + required: + - name + type: object + type: array + imagePullSecrets: + items: + description: LocalObjectReference contains enough information to + let you locate the referenced object inside the same namespace. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + type: array + portBindings: + items: + properties: + containerPort: + description: Number of port to expose on the pod's IP address. + This must be a valid port number, 0 < x < 65536. + format: int32 + type: integer + hostIP: + description: What host IP to bind the external port to. + type: string + name: + description: If specified, this must be an IANA_SVC_NAME and + unique within the pod. Each named port in a pod must have + a unique name. Name for the port that can be referred to by + services. + type: string + nodePort: + description: 'The port on each node on which this service is + exposed when type is NodePort or LoadBalancer. Usually assigned + by the system. If a value is specified, in-range, and not + in use it will be used, otherwise the operation will fail. If + not specified, a port will be allocated if this Service requires + one. If this field is specified when creating a Service which + does not need it, creation will fail. This field will be wiped + when updating a Service to no longer need it (e.g. changing + type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' + format: int32 + type: integer + protocol: + default: TCP + description: Protocol for port. Must be UDP, TCP, or SCTP. Defaults + to "TCP". + type: string + servicePort: + description: The port that will be exposed by this service. + format: int32 + type: integer + required: + - containerPort + - servicePort + type: object + type: array + probes: + description: ProxyProbe defines the probe actions for LivenesProbe, + ReadinessProbe and StartupProbe + properties: + livenessProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + readinessProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + startupProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command + is simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit + status of 0 is treated as live/healthy and non-zero + is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to + be considered failed after having succeeded. Defaults to + 3. Minimum value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. + This is a beta field and requires enabling GRPCContainerProbe + feature gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is + defined by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the + pod IP. You probably want to set "Host" in httpHeaders + instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP + allows repeated headers. + items: + description: HTTPHeader describes a custom header to + be used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. + Defaults to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. + Default to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to + be considered successful after having failed. Defaults to + 1. Must be 1 for liveness and startup. Minimum value is + 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP + port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the + container. Number must be in the range 1 to 65535. Name + must be an IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to + terminate gracefully upon probe failure. The grace period + is the duration in seconds after the processes running in + the pod are sent a termination signal and the time when + the processes are forcibly halted with a kill signal. Set + this value longer than the expected cleanup time for your + process. If this value is nil, the pod's terminationGracePeriodSeconds + will be used. Otherwise, this value overrides the value + provided by the pod spec. Value must be non-negative integer. + The value zero indicates stop immediately via the kill signal + (no opportunity to shut down). This is a beta field and + requires enabling ProbeTerminationGracePeriod feature gate. + Minimum value is 1. spec.terminationGracePeriodSeconds is + used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times + out. Defaults to 1 second. Minimum value is 1. More info: + https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + type: object + replicas: + description: replicas is the expected number of replicas of ShardingSphere-Proxy + format: int32 + type: integer + resources: + description: ResourceRequirements describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined in + spec.resourceClaims, that are used by this container. \n This + is an alpha field and requires enabling the DynamicResourceAllocation + feature gate. \n This field is immutable. It can only be set + for containers." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims + of the Pod where this field is used. It makes that resource + available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + selector: + description: selector defines a set of label selectors + properties: + matchExpressions: + description: matchExpressions is a list of label selector requirements. + The requirements are ANDed. + items: + description: A label selector requirement is a selector that + contains values, a key, and an operator that relates the key + and values. + properties: + key: + description: key is the label key that the selector applies + to. + type: string + operator: + description: operator represents a key's relationship to + a set of values. Valid operators are In, NotIn, Exists + and DoesNotExist. + type: string + values: + description: values is an array of string values. If the + operator is In or NotIn, the values array must be non-empty. + If the operator is Exists or DoesNotExist, the values + array must be empty. This array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. A single + {key,value} in the matchLabels map is equivalent to an element + of matchExpressions, whose key field is "key", the operator + is "In", and the values array contains only "value". The requirements + are ANDed. + type: object + type: object + serverVersion: + description: version is the version of ShardingSphere-Proxy + type: string + serviceType: + description: Service Type string describes ingress methods for a service + enum: + - ClusterIP + - NodePort + - LoadBalancer + - ExternalName + type: string + storageNodeConnector: + description: MySQLDriver Defines the mysql-driven version in ShardingSphere-proxy + properties: + type: + description: ConnectorType defines the frontend protocol for ShardingSphere + Proxy + type: string + version: + description: mysql-driven version,must be x.y.z + pattern: ^([1-9]\d|[1-9])(\.([1-9]\d|\d)){2}$ + type: string + required: + - type + - version + type: object + required: + - selector + type: object + status: + description: ComputeNodeStatus defines the observed state of ShardingSphere + Proxy + properties: + conditions: + description: Conditions The conditions array, the reason and message + fields + items: + description: ComputeNodeCondition defines a condition template + properties: + lastTransitionTime: + format: date-time + type: string + lastUpdateTime: + format: date-time + type: string + message: + type: string + reason: + type: string + status: + description: ConditionStatus represents the validation status + of a condition + type: string + type: + description: ComputeNodeConditioType represents the type of + a compute node condition during the startup process of ShardingSphere-Proxy + type: string + required: + - message + - reason + - status + - type + type: object + type: array + loadBalancer: + description: LoadBalancer contains the current status of the load-balancer, + if one is present. + properties: + clusterIP: + type: string + ingress: + description: Ingress is a list containing ingress points for the + load-balancer. Traffic intended for the service should be sent + to these ingress points. + items: + description: 'LoadBalancerIngress represents the status of a + load-balancer ingress point: traffic intended for the service + should be sent to an ingress point.' + properties: + hostname: + description: Hostname is set for load-balancer ingress points + that are DNS based (typically AWS load-balancers) + type: string + ip: + description: IP is set for load-balancer ingress points + that are IP based (typically GCE or OpenStack load-balancers) + type: string + ports: + description: Ports is a list of records of service ports + If used, every port defined in the service should have + an entry in it + items: + properties: + error: + description: 'Error is to record the problem with + the service port The format of the error shall comply + with the following rules: - built-in error values + shall be specified in this file and those shall + use CamelCase names - cloud provider specific error + values must have names that comply with the format + foo.example.com/CamelCase. --- The regex it matches + is (dns1123SubdomainFmt/)?(qualifiedNameFmt)' + maxLength: 316 + pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ + type: string + port: + description: Port is the port number of the service + port of which status is recorded here + format: int32 + type: integer + protocol: + default: TCP + description: 'Protocol is the protocol of the service + port of which status is recorded here The supported + values are: "TCP", "UDP", "SCTP"' + type: string + required: + - port + - protocol + type: object + type: array + x-kubernetes-list-type: atomic + type: object + type: array + type: object + observedGeneration: + description: The generation observed by the deployment controller. + format: int64 + type: integer + phase: + description: 'ShardingSphere-Proxy phase are a brief summary of the + ShardingSphere-Proxy life cycle There are two possible phase values: + Ready: ShardingSphere-Proxy can already provide external services + NotReady: ShardingSphere-Proxy cannot provide external services' + type: string + ready: + type: string + replicas: + format: int32 + type: integer + selector: + type: string + required: + - replicas + - selector + type: object + type: object + served: true + storage: true + subresources: + scale: + labelSelectorPath: .status.selector + specReplicasPath: .spec.replicas + statusReplicasPath: .status.replicas + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxies.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxies.yaml new file mode 100644 index 00000000..55e5e25a --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxies.yaml @@ -0,0 +1,1135 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: shardingsphereproxies.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: ShardingSphereProxy + listKind: ShardingSphereProxyList + plural: shardingsphereproxies + singular: shardingsphereproxy + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.readyNodes + name: ReadyNodes + type: integer + - jsonPath: .status.phase + name: Phase + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: ShardingSphereProxy is the Schema for the proxies API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ProxySpec defines the desired state of ShardingSphereProxy + properties: + automaticScaling: + description: AutomaticScaling HPA configuration + properties: + customMetrics: + items: + description: MetricSpec specifies how to scale based on a single + metric (only `type` and one other matching field should be + set at once). + properties: + containerResource: + description: container resource refers to a resource metric + (such as those specified in requests and limits) known + to Kubernetes describing a single container in each pod + of the current scale target (e.g. CPU or memory). Such + metrics are built in to Kubernetes, and have special scaling + options on top of those available to normal per-pod metrics + using the "pods" source. This is an alpha feature and + can be enabled by the HPAContainerMetrics feature flag. + properties: + container: + description: container is the name of the container + in the pods of the scaling target + type: string + name: + description: name is the name of the resource in question. + type: string + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + Currently only valid for Resource metric source + type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - container + - name + - target + type: object + external: + description: external refers to a global metric that is + not associated with any Kubernetes object. It allows autoscaling + based on information coming from components running outside + of cluster (for example length of queue in cloud messaging + service, or QPS from loadbalancer running outside of cluster). + properties: + metric: + description: metric identifies the target metric by + name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded form + of a standard kubernetes label selector for the + given metric When set, it is passed as an additional + parameter to the metrics server for more specific + metrics scoping. When unset, just the metricName + will be used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator is + "In", and the values array contains only "value". + The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + Currently only valid for Resource metric source + type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + object: + description: object refers to a metric describing a single + kubernetes object (for example, hits-per-second on an + Ingress object). + properties: + describedObject: + description: CrossVersionObjectReference contains enough + information to let you identify the referred resource. + properties: + apiVersion: + description: API version of the referent + type: string + kind: + description: 'Kind of the referent; More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names' + type: string + required: + - kind + - name + type: object + metric: + description: metric identifies the target metric by + name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded form + of a standard kubernetes label selector for the + given metric When set, it is passed as an additional + parameter to the metrics server for more specific + metrics scoping. When unset, just the metricName + will be used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator is + "In", and the values array contains only "value". + The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + Currently only valid for Resource metric source + type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - describedObject + - metric + - target + type: object + pods: + description: pods refers to a metric describing each pod + in the current scale target (for example, transactions-processed-per-second). The + values will be averaged together before being compared + to the target value. + properties: + metric: + description: metric identifies the target metric by + name and selector + properties: + name: + description: name is the name of the given metric + type: string + selector: + description: selector is the string-encoded form + of a standard kubernetes label selector for the + given metric When set, it is passed as an additional + parameter to the metrics server for more specific + metrics scoping. When unset, just the metricName + will be used to gather metrics. + properties: + matchExpressions: + description: matchExpressions is a list of label + selector requirements. The requirements are + ANDed. + items: + description: A label selector requirement + is a selector that contains values, a key, + and an operator that relates the key and + values. + properties: + key: + description: key is the label key that + the selector applies to. + type: string + operator: + description: operator represents a key's + relationship to a set of values. Valid + operators are In, NotIn, Exists and + DoesNotExist. + type: string + values: + description: values is an array of string + values. If the operator is In or NotIn, + the values array must be non-empty. + If the operator is Exists or DoesNotExist, + the values array must be empty. This + array is replaced during a strategic + merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} + pairs. A single {key,value} in the matchLabels + map is equivalent to an element of matchExpressions, + whose key field is "key", the operator is + "In", and the values array contains only "value". + The requirements are ANDed. + type: object + type: object + required: + - name + type: object + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + Currently only valid for Resource metric source + type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - metric + - target + type: object + resource: + description: resource refers to a resource metric (such + as those specified in requests and limits) known to Kubernetes + describing each pod in the current scale target (e.g. + CPU or memory). Such metrics are built in to Kubernetes, + and have special scaling options on top of those available + to normal per-pod metrics using the "pods" source. + properties: + name: + description: name is the name of the resource in question. + type: string + target: + description: target specifies the target value for the + given metric + properties: + averageUtilization: + description: averageUtilization is the target value + of the average of the resource metric across all + relevant pods, represented as a percentage of + the requested value of the resource for the pods. + Currently only valid for Resource metric source + type + format: int32 + type: integer + averageValue: + anyOf: + - type: integer + - type: string + description: averageValue is the target value of + the average of the metric across all relevant + pods (as a quantity) + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: + description: type represents whether the metric + type is Utilization, Value, or AverageValue + type: string + value: + anyOf: + - type: integer + - type: string + description: value is the target value of the metric + (as a quantity). + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + required: + - type + type: object + required: + - name + - target + type: object + type: + description: 'type is the type of metric source. It should + be one of "ContainerResource", "External", "Object", "Pods" + or "Resource", each mapping to a matching field in the + object. Note: "ContainerResource" type is available on + when the feature-gate HPAContainerMetrics is enabled' + type: string + required: + - type + type: object + type: array + enable: + type: boolean + maxInstance: + format: int32 + type: integer + minInstance: + format: int32 + type: integer + scaleDownWindows: + format: int32 + type: integer + scaleUpWindows: + format: int32 + type: integer + target: + format: int32 + type: integer + type: object + imagePullSecrets: + items: + description: LocalObjectReference contains enough information to + let you locate the referenced object inside the same namespace. + properties: + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + TODO: Add other useful fields. apiVersion, kind, uid?' + type: string + type: object + type: array + livenessProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command is + simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit status + of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be + considered failed after having succeeded. Defaults to 3. Minimum + value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. This + is a beta field and requires enabling GRPCContainerProbe feature + gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is defined + by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod + IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows + repeated headers. + items: + description: HTTPHeader describes a custom header to be + used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults + to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default + to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be + considered successful after having failed. Defaults to 1. Must + be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate + gracefully upon probe failure. The grace period is the duration + in seconds after the processes running in the pod are sent a + termination signal and the time when the processes are forcibly + halted with a kill signal. Set this value longer than the expected + cleanup time for your process. If this value is nil, the pod's + terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. Value must + be non-negative integer. The value zero indicates stop immediately + via the kill signal (no opportunity to shut down). This is a + beta field and requires enabling ProbeTerminationGracePeriod + feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds + is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + mySQLDriver: + description: MySQLDriver Defines the mysql-driven version in ShardingSphere-proxy + properties: + version: + description: mysql-driven version,must be x.y.z + pattern: ^([1-9]\d|[1-9])(\.([1-9]\d|\d)){2}$ + type: string + required: + - version + type: object + port: + description: Port is ShardingSphere-Proxy startup port + format: int32 + minimum: 0 + type: integer + proxyConfigName: + description: ProxyConfigName is the name of the ShardingSphereProxyServerConfig + CRD + minLength: 0 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$ + type: string + readinessProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command is + simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit status + of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be + considered failed after having succeeded. Defaults to 3. Minimum + value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. This + is a beta field and requires enabling GRPCContainerProbe feature + gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is defined + by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod + IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows + repeated headers. + items: + description: HTTPHeader describes a custom header to be + used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults + to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default + to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be + considered successful after having failed. Defaults to 1. Must + be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate + gracefully upon probe failure. The grace period is the duration + in seconds after the processes running in the pod are sent a + termination signal and the time when the processes are forcibly + halted with a kill signal. Set this value longer than the expected + cleanup time for your process. If this value is nil, the pod's + terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. Value must + be non-negative integer. The value zero indicates stop immediately + via the kill signal (no opportunity to shut down). This is a + beta field and requires enabling ProbeTerminationGracePeriod + feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds + is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + replicas: + description: Replicas is the expected number of replicas of ShardingSphere-Proxy + format: int32 + type: integer + resources: + description: ResourceRequirements describes the compute resource requirements. + properties: + claims: + description: "Claims lists the names of resources, defined in + spec.resourceClaims, that are used by this container. \n This + is an alpha field and requires enabling the DynamicResourceAllocation + feature gate. \n This field is immutable. It can only be set + for containers." + items: + description: ResourceClaim references one entry in PodSpec.ResourceClaims. + properties: + name: + description: Name must match the name of one entry in pod.spec.resourceClaims + of the Pod where this field is used. It makes that resource + available inside a container. + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount of compute resources + allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount of compute + resources required. If Requests is omitted for a container, + it defaults to Limits if that is explicitly specified, otherwise + to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + serviceType: + description: ServiceType defines the Service in Kubernetes of ShardingSphere-Proxy + properties: + nodePort: + description: 'The port on each node on which this service is exposed + when type is NodePort or LoadBalancer. Usually assigned by + the system. If a value is specified, in-range, and not in use + it will be used, otherwise the operation will fail. If not + specified, a port will be allocated if this Service requires + one. If this field is specified when creating a Service which + does not need it, creation will fail. This field will be wiped + when updating a Service to no longer need it (e.g. changing + type from NodePort to ClusterIP). More info: https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport' + format: int32 + minimum: 0 + type: integer + type: + description: Service Type string describes ingress methods for + a service + enum: + - ClusterIP + - NodePort + - LoadBalancer + - ExternalName + type: string + required: + - type + type: object + startupProbe: + description: Probes are not allowed for ephemeral containers. + properties: + exec: + description: Exec specifies the action to take. + properties: + command: + description: Command is the command line to execute inside + the container, the working directory for the command is + root ('/') in the container's filesystem. The command is + simply exec'd, it is not run inside a shell, so traditional + shell instructions ('|', etc) won't work. To use a shell, + you need to explicitly call out to that shell. Exit status + of 0 is treated as live/healthy and non-zero is unhealthy. + items: + type: string + type: array + type: object + failureThreshold: + description: Minimum consecutive failures for the probe to be + considered failed after having succeeded. Defaults to 3. Minimum + value is 1. + format: int32 + type: integer + grpc: + description: GRPC specifies an action involving a GRPC port. This + is a beta field and requires enabling GRPCContainerProbe feature + gate. + properties: + port: + description: Port number of the gRPC service. Number must + be in the range 1 to 65535. + format: int32 + type: integer + service: + description: "Service is the name of the service to place + in the gRPC HealthCheckRequest (see https://github.com/grpc/grpc/blob/master/doc/health-checking.md). + \n If this is not specified, the default behavior is defined + by gRPC." + type: string + required: + - port + type: object + httpGet: + description: HTTPGet specifies the http request to perform. + properties: + host: + description: Host name to connect to, defaults to the pod + IP. You probably want to set "Host" in httpHeaders instead. + type: string + httpHeaders: + description: Custom headers to set in the request. HTTP allows + repeated headers. + items: + description: HTTPHeader describes a custom header to be + used in HTTP probes + properties: + name: + description: The header field name + type: string + value: + description: The header field value + type: string + required: + - name + - value + type: object + type: array + path: + description: Path to access on the HTTP server. + type: string + port: + anyOf: + - type: integer + - type: string + description: Name or number of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + scheme: + description: Scheme to use for connecting to the host. Defaults + to HTTP. + type: string + required: + - port + type: object + initialDelaySeconds: + description: 'Number of seconds after the container has started + before liveness probes are initiated. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + periodSeconds: + description: How often (in seconds) to perform the probe. Default + to 10 seconds. Minimum value is 1. + format: int32 + type: integer + successThreshold: + description: Minimum consecutive successes for the probe to be + considered successful after having failed. Defaults to 1. Must + be 1 for liveness and startup. Minimum value is 1. + format: int32 + type: integer + tcpSocket: + description: TCPSocket specifies an action involving a TCP port. + properties: + host: + description: 'Optional: Host name to connect to, defaults + to the pod IP.' + type: string + port: + anyOf: + - type: integer + - type: string + description: Number or name of the port to access on the container. + Number must be in the range 1 to 65535. Name must be an + IANA_SVC_NAME. + x-kubernetes-int-or-string: true + required: + - port + type: object + terminationGracePeriodSeconds: + description: Optional duration in seconds the pod needs to terminate + gracefully upon probe failure. The grace period is the duration + in seconds after the processes running in the pod are sent a + termination signal and the time when the processes are forcibly + halted with a kill signal. Set this value longer than the expected + cleanup time for your process. If this value is nil, the pod's + terminationGracePeriodSeconds will be used. Otherwise, this + value overrides the value provided by the pod spec. Value must + be non-negative integer. The value zero indicates stop immediately + via the kill signal (no opportunity to shut down). This is a + beta field and requires enabling ProbeTerminationGracePeriod + feature gate. Minimum value is 1. spec.terminationGracePeriodSeconds + is used if unset. + format: int64 + type: integer + timeoutSeconds: + description: 'Number of seconds after which the probe times out. + Defaults to 1 second. Minimum value is 1. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes' + format: int32 + type: integer + type: object + version: + description: Version is the version of ShardingSphere-Proxy + type: string + required: + - port + - proxyConfigName + - replicas + - serviceType + - version + type: object + status: + description: ProxyStatus defines the observed state of ShardingSphereProxy + properties: + conditions: + description: Conditions The conditions array, the reason and message + fields + items: + properties: + lastUpdateTime: + format: date-time + type: string + status: + type: string + type: + type: string + required: + - status + - type + type: object + type: array + phase: + description: 'ShardingSphere-Proxy phase are a brief summary of the + ShardingSphere-Proxy life cycle There are two possible phase values: + Ready: ShardingSphere-Proxy can already provide external services + NotReady: ShardingSphere-Proxy cannot provide external services' + type: string + readyNodes: + description: ReadyNodes shows the number of replicas that ShardingSphere-Proxy + is running normally + format: int32 + type: integer + required: + - conditions + - phase + - readyNodes + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxyserverconfigs.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxyserverconfigs.yaml new file mode 100644 index 00000000..e6ae0496 --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_shardingsphereproxyserverconfigs.yaml @@ -0,0 +1,190 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: shardingsphereproxyserverconfigs.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: ShardingSphereProxyServerConfig + listKind: ShardingSphereProxyServerConfigList + plural: shardingsphereproxyserverconfigs + singular: shardingsphereproxyserverconfig + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.metadataRepository + name: MetadataRepository + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: ShardingSphereProxyServerConfig is the Schema for the proxyconfigs + API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: ProxyConfigSpec defines the desired state of ShardingSphereProxyServerConfig + properties: + authority: + description: Auth is used to set up initial user to login compute + node, and authority data of storage node. + properties: + privilege: + description: Privilege for storage node, the default value is + ALL_PRIVILEGES_PERMITTED + properties: + type: + type: string + required: + - type + type: object + users: + items: + description: 'User is a slice about authorized host and password + for compute node. Format: user:@,hostname + is % or empty string means do not care about authorized host + password:' + properties: + password: + type: string + user: + type: string + required: + - password + - user + type: object + type: array + required: + - users + type: object + mode: + description: ClusterConfig needs to fill in the relevant configuration + required by Cluster mode + properties: + repository: + description: Persist repository configuration + properties: + props: + description: Properties of persist repository + properties: + digest: + description: Password of login + type: string + maxRetries: + description: 'MaxRetries Max retries of client connection. + default: 3' + type: integer + namespace: + description: Namespace of registry center + type: string + operationTimeoutMilliseconds: + description: 'OperationTimeoutMilliseconds Milliseconds + of operation timeout. default: 500' + type: integer + retryIntervalMilliseconds: + description: 'RetryIntervalMilliseconds Milliseconds of + retry interval. default: 500' + type: integer + server-lists: + description: Server lists of registry center + type: string + timeToLiveSeconds: + description: 'TimeToLiveSeconds Seconds of ephemeral data + live.default: 60' + type: integer + required: + - namespace + - server-lists + type: object + type: + description: Type of persist repository + enum: + - ZooKeeper + type: string + required: + - props + - type + type: object + type: + description: 'Type of mode configuration. Values only support: + Cluster' + enum: + - Cluster + type: string + required: + - repository + - type + type: object + props: + description: Props Apache ShardingSphere provides the way of property + configuration to configure system level configuration. + properties: + check-duplicate-table-enabled: + description: Whether validate duplicate table when application + startup or updated. + type: boolean + check-table-metadata-enabled: + description: Whether validate table meta data consistency when + application startup or updated. + type: boolean + kernel-executor-size: + description: The max thread size of worker group to execute SQL. + One ShardingSphereDataSource will use a independent thread pool, + it does not share thread pool even different data source in + same JVM. + type: integer + proxy-backend-driver-type: + type: string + proxy-backend-executor-suitable: + description: 'Available options of proxy backend executor suitable: + OLAP(default), OLTP. The OLTP option may reduce time cost of + writing packets to client, but it may increase the latency of + SQL execution and block other clients if client connections + are more than proxy-frontend-executor-size, especially executing + slow SQL.' + type: string + proxy-backend-query-fetch-size: + description: ShardingSphereProxy backend query fetch size. A larger + value may increase the memory usage of ShardingSphere ShardingSphereProxy. + The default value is -1, which means set the minimum value for + different JDBC drivers. + type: integer + proxy-frontend-database-protocol-type: + type: string + proxy-frontend-executor-size: + description: ShardingSphereProxy frontend Netty executor size. + The default value is 0, which means let Netty decide. + type: integer + type: object + required: + - authority + - mode + type: object + status: + description: ProxyConfigStatus defines the observed state of ShardingSphereProxyServerConfig + properties: + metadataRepository: + type: string + required: + - metadataRepository + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storagenodes.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storagenodes.yaml new file mode 100644 index 00000000..9684ace3 --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storagenodes.yaml @@ -0,0 +1,185 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: storagenodes.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: StorageNode + listKind: StorageNodeList + plural: storagenodes + singular: storagenode + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.phase + name: Phase + type: string + - jsonPath: .status.cluster.status + name: ClusterStatus + type: string + - jsonPath: .status.registered + name: registered + priority: 1 + type: boolean + - jsonPath: .spec.storageProviderName + name: StorageProvider + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1alpha1 + schema: + openAPIV3Schema: + description: StorageNode is the Schema for the ShardingSphere storage unit + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: StorageNodeSpec defines the desired state of a set of storage + units + properties: + replicas: + default: 1 + description: Only for aws aurora storage provider right now. And the + default value is 1. aws rds instance is always 1. aws rds cluster + will auto create 3 instances(1 primary and 2 replicas). + format: int32 + type: integer + schema: + description: the default database name of the storage node. if not + set, will NOT create database + type: string + storageProviderName: + type: string + required: + - storageProviderName + type: object + status: + description: StorageNodeStatus defines the actual state of a set of storage + units + properties: + cluster: + description: Cluster contains the current status of the StorageNode + cluster + properties: + primaryEndpoint: + properties: + address: + type: string + port: + format: int32 + type: integer + required: + - address + - port + type: object + properties: + additionalProperties: + type: string + type: object + readerEndpoints: + items: + properties: + address: + type: string + port: + format: int32 + type: integer + required: + - address + - port + type: object + type: array + status: + type: string + required: + - primaryEndpoint + - status + type: object + conditions: + description: Conditions The conditions array, the reason and message + fields + items: + description: StorageNodeCondition contains details for the current + condition of this StorageNode. + properties: + lastUpdateTime: + format: date-time + type: string + message: + type: string + reason: + type: string + status: + type: string + type: + type: string + required: + - message + - reason + - status + - type + type: object + type: array + instances: + description: Instances contains the current status of the StorageNode + instance + items: + properties: + primaryEndpoint: + properties: + address: + type: string + port: + format: int32 + type: integer + required: + - address + - port + type: object + properties: + additionalProperties: + type: string + type: object + status: + type: string + required: + - primaryEndpoint + - status + type: object + type: array + observedGeneration: + description: The generation observed by the StorageNode controller. + format: int64 + type: integer + phase: + description: 'Phase is a brief summary of the StorageNode life cycle + There are two possible phase values: Ready: StorageNode can already + provide external services NotReady: StorageNode cannot provide external + services' + type: string + registered: + description: Registered indicates whether the StorageNode has been + registered to shardingsphere + type: boolean + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storageproviders.yaml b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storageproviders.yaml new file mode 100644 index 00000000..21891b8d --- /dev/null +++ b/shardingsphere-operator/config/crd/bases/shardingsphere.apache.org_storageproviders.yaml @@ -0,0 +1,65 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.9.0 + creationTimestamp: null + name: storageproviders.shardingsphere.apache.org +spec: + group: shardingsphere.apache.org + names: + kind: StorageProvider + listKind: StorageProviderList + plural: storageproviders + shortNames: + - sp + singular: storageprovider + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: StorageProvider is the Schema for the storageproviders API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: StorageProviderSpec defines the desired state of StorageProvider + properties: + parameters: + additionalProperties: + type: string + type: object + provisioner: + type: string + reclaimPolicy: + default: Retain + description: StorageReclaimPolicy defines the reclaim policy for storage + enum: + - DeleteWithFinalSnapshot + - Delete + - Retain + type: string + required: + - parameters + - provisioner + type: object + status: + description: StorageProviderStatus defines the observed state of StorageProvider + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/shardingsphere-operator/go.mod b/shardingsphere-operator/go.mod index 277acdce..a6738213 100644 --- a/shardingsphere-operator/go.mod +++ b/shardingsphere-operator/go.mod @@ -20,6 +20,7 @@ require ( gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.26.4 k8s.io/apimachinery v0.26.4 + k8s.io/autoscaler/vertical-pod-autoscaler v0.14.0 k8s.io/client-go v0.26.3 k8s.io/utils v0.0.0-20230505201702-9f6742963106 sigs.k8s.io/controller-runtime v0.14.6 diff --git a/shardingsphere-operator/go.sum b/shardingsphere-operator/go.sum index 5ffaa0e4..031d1f2e 100644 --- a/shardingsphere-operator/go.sum +++ b/shardingsphere-operator/go.sum @@ -392,6 +392,8 @@ k8s.io/apiextensions-apiserver v0.26.3 h1:5PGMm3oEzdB1W/FTMgGIDmm100vn7IaUP5er36 k8s.io/apiextensions-apiserver v0.26.3/go.mod h1:jdA5MdjNWGP+njw1EKMZc64xAT5fIhN6VJrElV3sfpQ= k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs= k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I= +k8s.io/autoscaler/vertical-pod-autoscaler v0.14.0 h1:HkQHkcuwVP3BgJpVqTGeYHro83qGBj8mWotygHZND1k= +k8s.io/autoscaler/vertical-pod-autoscaler v0.14.0/go.mod h1:w6/LjLR3DPQd57vlgvgbpzpuJKsCiily0+OzQI+nyfI= k8s.io/client-go v0.26.3 h1:k1UY+KXfkxV2ScEL3gilKcF7761xkYsSD6BC9szIu8s= k8s.io/client-go v0.26.3/go.mod h1:ZPNu9lm8/dbRIPAgteN30RSXea6vrCpFvq+MateTUuQ= k8s.io/component-base v0.26.3 h1:oC0WMK/ggcbGDTkdcqefI4wIZRYdK3JySx9/HADpV0g= diff --git a/shardingsphere-operator/pkg/controllers/auto_scaler_controller.go b/shardingsphere-operator/pkg/controllers/auto_scaler_controller.go new file mode 100644 index 00000000..11aae7aa --- /dev/null +++ b/shardingsphere-operator/pkg/controllers/auto_scaler_controller.go @@ -0,0 +1,133 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package controllers + +import ( + "context" + "reflect" + + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1" + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes" + reconcile "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/reconcile/autoscaler" + + "github.com/go-logr/logr" + autoscalingv2beta2 "k8s.io/api/autoscaling/v2" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/types" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +const ( + autoScalerControllerName = "autoscaler-controller" +) + +// AutoScalerReconciler is a controller for the shardingsphere cluster +type AutoScalerReconciler struct { + client.Client + Scheme *runtime.Scheme + Log logr.Logger + + Builder reconcile.Builder + Resources kubernetes.Resources +} + +// SetupWithManager sets up the controller with the Manager +func (r *AutoScalerReconciler) SetupWithManager(mgr ctrl.Manager) error { + return ctrl.NewControllerManagedBy(mgr). + For(&v1alpha1.AutoScaler{}). + Owns(&autoscalingv2beta2.HorizontalPodAutoscaler{}). + Complete(r) +} + +// +kubebuilder:rbac:groups=shardingsphere.apache.org,resources=computenodes,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=autoscaling/v2,resources=horizontalpodautoscaler,verbs=get;list;watch;create;update;patch;delete +// Reconcile handles main function of this controller +func (r *AutoScalerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { + logger := r.Log.WithValues(autoScalerControllerName, req.NamespacedName) + + as := &v1alpha1.AutoScaler{} + if err := r.Get(ctx, req.NamespacedName, as); err != nil { + if apierrors.IsNotFound(err) { + return ctrl.Result{RequeueAfter: defaultRequeueTime}, nil + } + + logger.Error(err, "Failed to get the autoscaler") + return ctrl.Result{Requeue: true}, err + } + + if err := r.reconcileAutoScaler(ctx, as); err != nil { + logger.Error(err, "Failed to reconcile autoscaler") + } + + return ctrl.Result{RequeueAfter: defaultRequeueTime}, nil +} + +func (r *AutoScalerReconciler) reconcileAutoScaler(ctx context.Context, as *v1alpha1.AutoScaler) error { + gvk := as.GroupVersionKind() + + for i := range as.Spec.PolicyGroup { + pg := as.Spec.PolicyGroup[i] + if pg.Provider == "KubernetesHPA" && pg.Horizontal != nil { + if err := r.reconcileHPA(ctx, &as.ObjectMeta, gvk, &pg); err != nil { + return err + } + } + } + + return nil +} + +func (r *AutoScalerReconciler) reconcileHPA(ctx context.Context, meta *metav1.ObjectMeta, gvk schema.GroupVersionKind, policy *v1alpha1.ScalingPolicy) error { + hpa, err := r.getHPAByNamespacedName(ctx, types.NamespacedName{Namespace: meta.Namespace, Name: meta.Name}) + if err != nil { + return err + } + if hpa != nil { + return r.updateHPA(ctx, meta, gvk, policy, hpa) + } + return r.createHPA(ctx, meta, gvk, policy) +} + +func (r *AutoScalerReconciler) getHPAByNamespacedName(ctx context.Context, namespacedName types.NamespacedName) (*autoscalingv2beta2.HorizontalPodAutoscaler, error) { + return r.Resources.HPA().GetByNamespacedName(ctx, namespacedName) +} + +func (r *AutoScalerReconciler) updateHPA(ctx context.Context, meta *metav1.ObjectMeta, gvk schema.GroupVersionKind, policy *v1alpha1.ScalingPolicy, hpa *autoscalingv2beta2.HorizontalPodAutoscaler) error { + exp := r.Builder.BuildHorizontalPodAutoScaler(ctx, meta, gvk, policy) + exp.ObjectMeta = hpa.ObjectMeta + exp.Labels = hpa.Labels + exp.Annotations = hpa.Annotations + + if !reflect.DeepEqual(hpa.Spec, exp.Spec) { + return r.Resources.HPA().Update(ctx, hpa) + } + return nil +} + +func (r *AutoScalerReconciler) createHPA(ctx context.Context, meta *metav1.ObjectMeta, gvk schema.GroupVersionKind, policy *v1alpha1.ScalingPolicy) error { + hpa := r.Builder.BuildHorizontalPodAutoScaler(ctx, meta, gvk, policy) + err := r.Resources.HPA().Create(ctx, hpa) + if err != nil && apierrors.IsAlreadyExists(err) || err == nil { + return nil + } + return err +} diff --git a/shardingsphere-operator/pkg/controllers/compute_node_controller.go b/shardingsphere-operator/pkg/controllers/compute_node_controller.go index c5b22486..44a0472a 100644 --- a/shardingsphere-operator/pkg/controllers/compute_node_controller.go +++ b/shardingsphere-operator/pkg/controllers/compute_node_controller.go @@ -34,6 +34,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" @@ -122,7 +123,9 @@ func (r *ComputeNodeReconciler) reconcileDeployment(ctx context.Context, cn *v1a if err != nil { return err } + if deploy != nil { + fmt.Printf("deploy selector: %s\n", deploy.Spec.Selector.String()) return r.updateDeployment(ctx, cn, deploy) } return r.createDeployment(ctx, cn) @@ -316,6 +319,12 @@ func (r *ComputeNodeReconciler) reconcileConfigMap(ctx context.Context, cn *v1al } func (r *ComputeNodeReconciler) reconcileStatus(ctx context.Context, cn *v1alpha1.ComputeNode) error { + selector, err := metav1.LabelSelectorAsSelector(cn.Spec.Selector) + if err != nil { + err := fmt.Errorf("error retrieving ComputeNode labels") + return err + } + podlist := &corev1.PodList{} if err := r.List(ctx, podlist, client.InNamespace(cn.Namespace), client.MatchingLabels(cn.Spec.Selector.MatchLabels)); err != nil { return err @@ -339,6 +348,7 @@ func (r *ComputeNodeReconciler) reconcileStatus(ctx context.Context, cn *v1alpha if err != nil { return err } + status.Selector = selector.String() rt.Status = *status return r.Status().Update(ctx, rt) diff --git a/shardingsphere-operator/pkg/kubernetes/hpa/builder.go b/shardingsphere-operator/pkg/kubernetes/hpa/builder.go new file mode 100644 index 00000000..7f56e1d8 --- /dev/null +++ b/shardingsphere-operator/pkg/kubernetes/hpa/builder.go @@ -0,0 +1,82 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hpa + +import ( + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/metadata" + autoscalingv2 "k8s.io/api/autoscaling/v2" +) + +// HorizontalPodAutoscalerBuilder is a builder for HPA +type HorizontalPodAutoscalerBuilder interface { + metadata.MetadataBuilder + + SetScaleTargetRef(ref autoscalingv2.CrossVersionObjectReference) HorizontalPodAutoscalerBuilder + SetMinReplicas(n int32) HorizontalPodAutoscalerBuilder + SetMaxReplicas(n int32) HorizontalPodAutoscalerBuilder + SetMetrics(specs []autoscalingv2.MetricSpec) HorizontalPodAutoscalerBuilder + SetBehavior(bh *autoscalingv2.HorizontalPodAutoscalerBehavior) HorizontalPodAutoscalerBuilder + + BuildHPA() *autoscalingv2.HorizontalPodAutoscaler +} + +// NewHorizontalPodAutoScalerBuilder returns a HorizontalPodAutoScalerBuilder for HPA +func NewHorizontalPodAutoScalerBuilder() HorizontalPodAutoscalerBuilder { + return &hpaBuilder{} +} + +type hpaBuilder struct { + hpa *autoscalingv2.HorizontalPodAutoscaler + metadata.MetadataBuilder +} + +// SetScaleTargetRef set the scale target +func (b *hpaBuilder) SetScaleTargetRef(ref autoscalingv2.CrossVersionObjectReference) HorizontalPodAutoscalerBuilder { + b.hpa.Spec.ScaleTargetRef = ref + return b +} + +// SetMinReplicas set the min replicas +func (b *hpaBuilder) SetMinReplicas(n int32) HorizontalPodAutoscalerBuilder { + b.hpa.Spec.MinReplicas = &n + return b +} + +// SetMaxReplicas set the max replicas +func (b *hpaBuilder) SetMaxReplicas(n int32) HorizontalPodAutoscalerBuilder { + b.hpa.Spec.MaxReplicas = n + return b +} + +// SetMetrics set the metrics +func (b *hpaBuilder) SetMetrics(specs []autoscalingv2.MetricSpec) HorizontalPodAutoscalerBuilder { + b.hpa.Spec.Metrics = specs + return b +} + +// SetBehavior set the behavior +func (b *hpaBuilder) SetBehavior(bh *autoscalingv2.HorizontalPodAutoscalerBehavior) HorizontalPodAutoscalerBuilder { + b.hpa.Spec.Behavior = bh + return b +} + +// BuildHPA returns a HPA +func (b *hpaBuilder) BuildHPA() *autoscalingv2.HorizontalPodAutoscaler { + b.hpa.ObjectMeta = *b.BuildMetadata() + return b.hpa +} diff --git a/shardingsphere-operator/pkg/kubernetes/hpa/hpa.go b/shardingsphere-operator/pkg/kubernetes/hpa/hpa.go new file mode 100644 index 00000000..b367a5cf --- /dev/null +++ b/shardingsphere-operator/pkg/kubernetes/hpa/hpa.go @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package hpa + +import ( + "context" + + autoscalingv2 "k8s.io/api/autoscaling/v2" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// NewHorizontalPodAutoscalerClient creates a new HorizontalPodAutoscaler +func NewHorizontalPodAutoscalerClient(c client.Client) HorizontalPodAutoscaler { + return hpaClient{ + getter: getter{ + Client: c, + }, + setter: setter{ + Client: c, + }, + } +} + +// HorizontalPodAutoscaler interface contains setter and getter +type HorizontalPodAutoscaler interface { + Getter + Setter +} + +type hpaClient struct { + getter + setter +} + +// Getter get HorizontalPodAutoscaler from different parameters +type Getter interface { + GetByNamespacedName(context.Context, types.NamespacedName) (*autoscalingv2.HorizontalPodAutoscaler, error) +} + +type getter struct { + client.Client +} + +// GetByNamespacedName returns Deployment from given namespaced name +func (dg getter) GetByNamespacedName(ctx context.Context, namespacedName types.NamespacedName) (*autoscalingv2.HorizontalPodAutoscaler, error) { + hpa := &autoscalingv2.HorizontalPodAutoscaler{} + if err := dg.Client.Get(ctx, namespacedName, hpa); err != nil { + if apierrors.IsNotFound(err) { + return nil, nil + } + return nil, err + } else { + return hpa, nil + } +} + +// Setter get HorizontalPodAutoscaler from different parameters +type Setter interface { + Create(context.Context, *autoscalingv2.HorizontalPodAutoscaler) error + Update(context.Context, *autoscalingv2.HorizontalPodAutoscaler) error +} + +type setter struct { + client.Client +} + +// Create creates HorizontalPodAutoscaler +func (ds setter) Create(ctx context.Context, dp *autoscalingv2.HorizontalPodAutoscaler) error { + return ds.Client.Create(ctx, dp) +} + +// Update updates HorizontalPodAutoscaler +func (ds setter) Update(ctx context.Context, dp *autoscalingv2.HorizontalPodAutoscaler) error { + return ds.Client.Update(ctx, dp) +} diff --git a/shardingsphere-operator/pkg/kubernetes/resources.go b/shardingsphere-operator/pkg/kubernetes/resources.go index a40a30a7..d8bcdf46 100644 --- a/shardingsphere-operator/pkg/kubernetes/resources.go +++ b/shardingsphere-operator/pkg/kubernetes/resources.go @@ -22,6 +22,7 @@ import ( cloudnativepg "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/cloudnative-pg" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/configmap" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/deployment" + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/hpa" "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/service" "sigs.k8s.io/controller-runtime/pkg/client" @@ -38,7 +39,7 @@ type KubernetesResources interface { Deployment() deployment.Deployment Service() service.Service ConfigMap() configmap.ConfigMap - // Pod() + HPA() hpa.HorizontalPodAutoscaler // Job() } @@ -55,6 +56,7 @@ func NewResources(c client.Client) Resources { deployment: deployment.NewDeploymentClient(c), service: service.NewServiceClient(c), configmap: configmap.NewConfigMapClient(c), + hpa: hpa.NewHorizontalPodAutoscalerClient(c), }, ExtendedResources: &extended{ chaosmesh: chaosmesh.NewChaos(c), @@ -74,6 +76,7 @@ type kubernetes struct { deployment deployment.Deployment service service.Service configmap configmap.ConfigMap + hpa hpa.HorizontalPodAutoscaler } // Deployment returns a Kubernetes deployment @@ -91,6 +94,11 @@ func (r *kubernetes) ConfigMap() configmap.ConfigMap { return r.configmap } +// HPA returns a Kubernetes HPA +func (r *kubernetes) HPA() hpa.HorizontalPodAutoscaler { + return r.hpa +} + var _ ExtendedResources = &extended{} type extended struct { diff --git a/shardingsphere-operator/pkg/reconcile/autoscaler/auto_scaler.go b/shardingsphere-operator/pkg/reconcile/autoscaler/auto_scaler.go new file mode 100644 index 00000000..9950e5e9 --- /dev/null +++ b/shardingsphere-operator/pkg/reconcile/autoscaler/auto_scaler.go @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package autoscaler + +import ( + "context" + + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1" + + autoscalingv2 "k8s.io/api/autoscaling/v2" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// Builder build HPA from given AutoScaler +type Builder interface { + BuildHorizontalPodAutoScaler(context.Context, *metav1.ObjectMeta, schema.GroupVersionKind, *v1alpha1.ScalingPolicy) *autoscalingv2.HorizontalPodAutoscaler +} + +// NewBulder builds resources needed by AutoScaler +func NewBuilder() Builder { + return &builder{} +} + +type builder struct{} diff --git a/shardingsphere-operator/pkg/reconcile/autoscaler/hpa.go b/shardingsphere-operator/pkg/reconcile/autoscaler/hpa.go new file mode 100644 index 00000000..6164316d --- /dev/null +++ b/shardingsphere-operator/pkg/reconcile/autoscaler/hpa.go @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package autoscaler + +import ( + "context" + + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1" + "github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/pkg/kubernetes/hpa" + + autoscalingv2 "k8s.io/api/autoscaling/v2" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// BuildHorizontalPodAutoScaler returns a new HPA +func (b builder) BuildHorizontalPodAutoScaler(ctx context.Context, meta *metav1.ObjectMeta, gvk schema.GroupVersionKind, policy *v1alpha1.ScalingPolicy) *autoscalingv2.HorizontalPodAutoscaler { + blder := hpa.NewHorizontalPodAutoScalerBuilder() + blder.SetName(meta.Name).SetNamespace(meta.Namespace).SetLabels(meta.Labels).SetAnnotations(meta.Annotations).SetOwnerReferences([]metav1.OwnerReference{ + *metav1.NewControllerRef(meta.GetObjectMeta(), gvk), + }) + + blder.SetScaleTargetRef(autoscalingv2.CrossVersionObjectReference{ + Kind: "ComputeNode", + Name: policy.TargetSelector.ObjectRef.Name, + APIVersion: "shardingsphere.apache.org/v1alpha1", + }) + + blder.SetMinReplicas(policy.Horizontal.MinReplicas) + blder.SetMaxReplicas(policy.Horizontal.MaxReplicas) + if policy.Horizontal.Metrics != nil { + blder.SetMetrics(policy.Horizontal.Metrics) + } + + var ( + up, down *autoscalingv2.HPAScalingRules + ) + + if policy.Horizontal.ScaleUpRules != nil { + up = policy.Horizontal.ScaleUpRules + } + if policy.Horizontal.ScaleDownRules != nil { + down = policy.Horizontal.ScaleDownRules + } + + if up != nil || down != nil { + blder.SetBehavior(&autoscalingv2.HorizontalPodAutoscalerBehavior{ + ScaleUp: up, + ScaleDown: down, + }) + } + + return blder.BuildHPA() +}