Skip to content

Commit

Permalink
Merge pull request #28 from daimaxiaxie/impl-subnet-provider
Browse files Browse the repository at this point in the history
implement VSwitchProvider
  • Loading branch information
jwcesign authored Oct 8, 2024
2 parents 5f59314 + 6c1d8aa commit 87ff8ba
Show file tree
Hide file tree
Showing 6 changed files with 390 additions and 1 deletion.
56 changes: 56 additions & 0 deletions config/components/crds/karpenter.k8s.alicloud_ecsnodeclasses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,65 @@ spec:
description: |-
ECSNodeClassSpec is the top level specification for the AliCloud Karpenter Provider.
This will contain configuration necessary to launch instances in AliCloud.
properties:
vSwitchSelectorTerms:
description: VSwitchSelectorTerms is a list of or vSwitch selector
terms. The terms are ORed.
items:
description: VSwitchSelectorTerm defines selection logic for a vSwitch
used by Karpenter to launch nodes.
properties:
id:
description: ID is the vSwitch id in ECS
pattern: vsw-[0-9a-z]+
type: string
tags:
additionalProperties:
type: string
description: |-
Tags is a map of key/value tags used to select vSwitches
Specifying '*' for a value selects all values for a given tag key.
maxProperties: 20
type: object
x-kubernetes-validations:
- message: empty tag keys aren't supported
rule: self.all(k, k != '')
type: object
maxItems: 30
type: array
x-kubernetes-validations:
- message: vSwitchSelectorTerms cannot be empty
rule: self.size() != 0
- message: expected at least one, got none, ['tags', 'id']
rule: self.all(x, has(x.tags) || has(x.id))
- message: '''id'' is mutually exclusive, cannot be set with a combination
of other fields in vSwitchSelectorTerms'
rule: '!self.all(x, has(x.id) && has(x.tags))'
required:
- vSwitchSelectorTerms
type: object
status:
description: ECSNodeClassStatus contains the resolved state of the ECSNodeClass
properties:
vSwitches:
description: |-
VSwitches contains the current VSwitch values that are available to the
cluster under the vSwitch selectors.
items:
description: VSwitch contains resolved VSwitch selector values utilized
for node launch
properties:
id:
description: ID of the vSwitch
type: string
zoneID:
description: The associated availability zone ID
type: string
required:
- id
- zoneID
type: object
type: array
type: object
type: object
served: true
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ require (
github.com/alibabacloud-go/ecs-20140526/v4 v4.25.1
github.com/alibabacloud-go/tea v1.2.2
github.com/alibabacloud-go/tea-utils/v2 v2.0.6
github.com/alibabacloud-go/vpc-20160428/v6 v6.10.4
github.com/aliyun/aliyun-cli v0.0.0-20240925084117-158a70e275f0
github.com/awslabs/operatorpkg v0.0.0-20240805231134-67d0acfb6306
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/samber/lo v1.46.0
go.uber.org/multierr v1.11.0
Expand Down Expand Up @@ -63,7 +65,6 @@ require (
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ github.com/alibabacloud-go/tea-utils/v2 v2.0.6 h1:ZkmUlhlQbaDC+Eba/GARMPy6hKdCLi
github.com/alibabacloud-go/tea-utils/v2 v2.0.6/go.mod h1:qxn986l+q33J5VkialKMqT/TTs3E+U9MJpd001iWQ9I=
github.com/alibabacloud-go/tea-xml v1.1.3 h1:7LYnm+JbOq2B+T/B0fHC4Ies4/FofC4zHzYtqw7dgt0=
github.com/alibabacloud-go/tea-xml v1.1.3/go.mod h1:Rq08vgCcCAjHyRi/M7xlHKUykZCEtyBy9+DPF6GgEu8=
github.com/alibabacloud-go/vpc-20160428/v6 v6.10.4 h1:6OXPOw1WcEjoSCOPFtKKgFFSlSSapns0uoOML+hzn8M=
github.com/alibabacloud-go/vpc-20160428/v6 v6.10.4/go.mod h1:6516WWE4Y9lzscVSfaev84DM+TQSvBEGX1oeMvDL5xk=
github.com/aliyun/aliyun-cli v0.0.0-20240925084117-158a70e275f0 h1:GyWC5h0inFp+vmJVbbRGh34KTj/HeG/tyqJwR+pQbko=
github.com/aliyun/aliyun-cli v0.0.0-20240925084117-158a70e275f0/go.mod h1:LRvAoBmigy35079C5FYKseCCHG4oCCC0dEgyuSsAVeo=
github.com/aliyun/credentials-go v1.1.2/go.mod h1:ozcZaMR5kLM7pwtCMEpVmQ242suV6qTJya2bDq4X1Tw=
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/v1alpha1/ecsnodeclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ import (
// ECSNodeClassSpec is the top level specification for the AliCloud Karpenter Provider.
// This will contain configuration necessary to launch instances in AliCloud.
type ECSNodeClassSpec struct {
// VSwitchSelectorTerms is a list of or vSwitch selector terms. The terms are ORed.
// +kubebuilder:validation:XValidation:message="vSwitchSelectorTerms cannot be empty",rule="self.size() != 0"
// +kubebuilder:validation:XValidation:message="expected at least one, got none, ['tags', 'id']",rule="self.all(x, has(x.tags) || has(x.id))"
// +kubebuilder:validation:XValidation:message="'id' is mutually exclusive, cannot be set with a combination of other fields in vSwitchSelectorTerms",rule="!self.all(x, has(x.id) && has(x.tags))"
// +kubebuilder:validation:MaxItems:=30
// +required
VSwitchSelectorTerms []VSwitchSelectorTerm `json:"vSwitchSelectorTerms" hash:"ignore"`
}

// VSwitchSelectorTerm defines selection logic for a vSwitch used by Karpenter to launch nodes.
type VSwitchSelectorTerm struct {
// Tags is a map of key/value tags used to select vSwitches
// Specifying '*' for a value selects all values for a given tag key.
// +kubebuilder:validation:XValidation:message="empty tag keys aren't supported",rule="self.all(k, k != '')"
// +kubebuilder:validation:MaxProperties:=20
// +optional
Tags map[string]string `json:"tags,omitempty"`
// ID is the vSwitch id in ECS
// +kubebuilder:validation:Pattern="vsw-[0-9a-z]+"
// +optional
ID string `json:"id,omitempty"`
}

// KubeletConfiguration defines args to be used when configuring kubelet on provisioned nodes.
Expand Down
14 changes: 14 additions & 0 deletions pkg/apis/v1alpha1/ecsnodeclass_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ limitations under the License.

package v1alpha1

// VSwitch contains resolved VSwitch selector values utilized for node launch
type VSwitch struct {
// ID of the vSwitch
// +required
ID string `json:"id"`
// The associated availability zone ID
// +required
ZoneID string `json:"zoneID,omitempty"`
}

// ECSNodeClassStatus contains the resolved state of the ECSNodeClass
type ECSNodeClassStatus struct {
// VSwitches contains the current VSwitch values that are available to the
// cluster under the vSwitch selectors.
// +optional
VSwitches []VSwitch `json:"vSwitches,omitempty"`
}
Loading

0 comments on commit 87ff8ba

Please sign in to comment.