forked from openkruise/kruise-game
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(*): add tencent cloud provider and clb plugin (openkruise#179)
* feat(*): add tencent cloud provider and clb plugin Signed-off-by: rockerchen <[email protected]>
- Loading branch information
Showing
14 changed files
with
1,332 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package options | ||
|
||
type TencentCloudOptions struct { | ||
Enable bool `toml:"enable"` | ||
CLBOptions TencentCloudCLBOptions `toml:"clb"` | ||
} | ||
|
||
type TencentCloudCLBOptions struct { | ||
MaxPort int32 `toml:"max_port"` | ||
MinPort int32 `toml:"min_port"` | ||
} | ||
|
||
func (o TencentCloudOptions) Valid() bool { | ||
clbOptions := o.CLBOptions | ||
|
||
if clbOptions.MaxPort > 65535 { | ||
return false | ||
} | ||
|
||
if clbOptions.MinPort < 1 { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (o TencentCloudOptions) Enabled() bool { | ||
return o.Enable | ||
} |
93 changes: 93 additions & 0 deletions
93
cloudprovider/tencentcloud/apis/v1alpha1/dedicatedclblistener_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed 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 ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! | ||
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. | ||
|
||
// DedicatedCLBListenerSpec defines the desired state of DedicatedCLBListener | ||
type DedicatedCLBListenerSpec struct { | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable" | ||
LbId string `json:"lbId"` | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable" | ||
// +optional | ||
LbRegion string `json:"lbRegion,omitempty"` | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable" | ||
LbPort int64 `json:"lbPort"` | ||
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Value is immutable" | ||
// +kubebuilder:validation:Enum=TCP;UDP | ||
Protocol string `json:"protocol"` | ||
// +optional | ||
ExtensiveParameters string `json:"extensiveParameters,omitempty"` | ||
// +optional | ||
TargetPod *TargetPod `json:"targetPod,omitempty"` | ||
} | ||
|
||
type TargetPod struct { | ||
PodName string `json:"podName"` | ||
TargetPort int64 `json:"targetPort"` | ||
} | ||
|
||
// DedicatedCLBListenerStatus defines the observed state of DedicatedCLBListener | ||
type DedicatedCLBListenerStatus struct { | ||
ListenerId string `json:"listenerId,omitempty"` | ||
// +kubebuilder:validation:Enum=Bound;Available;Pending;Failed;Deleting | ||
State string `json:"state,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
Address string `json:"address,omitempty"` | ||
} | ||
|
||
const ( | ||
DedicatedCLBListenerStateBound = "Bound" | ||
DedicatedCLBListenerStateAvailable = "Available" | ||
DedicatedCLBListenerStatePending = "Pending" | ||
DedicatedCLBListenerStateFailed = "Failed" | ||
DedicatedCLBListenerStateDeleting = "Deleting" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="LbId",type="string",JSONPath=".spec.lbId",description="CLB ID" | ||
// +kubebuilder:printcolumn:name="LbPort",type="integer",JSONPath=".spec.lbPort",description="Port of CLB Listener" | ||
// +kubebuilder:printcolumn:name="Pod",type="string",JSONPath=".spec.targetPod.podName",description="Pod name of target pod" | ||
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state",description="State of the dedicated clb listener" | ||
|
||
// DedicatedCLBListener is the Schema for the dedicatedclblisteners API | ||
type DedicatedCLBListener struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec DedicatedCLBListenerSpec `json:"spec,omitempty"` | ||
Status DedicatedCLBListenerStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// DedicatedCLBListenerList contains a list of DedicatedCLBListener | ||
type DedicatedCLBListenerList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []DedicatedCLBListener `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&DedicatedCLBListener{}, &DedicatedCLBListenerList{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Package v1alpha1 contains API Schema definitions for the tencentcloud v1alpha1 API group | ||
// +k8s:deepcopy-gen=package,register | ||
// +groupName=networking.cloud.tencent.com | ||
package v1alpha1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
Copyright 2024. | ||
Licensed 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 contains API Schema definitions for the networking v1alpha1 API group | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:object:generate=true | ||
// +groupName=networking.cloud.tencent.com | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// GroupVersion is group version used to register these objects | ||
GroupVersion = schema.GroupVersion{Group: "networking.cloud.tencent.com", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) |
135 changes: 135 additions & 0 deletions
135
cloudprovider/tencentcloud/apis/v1alpha1/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.