Skip to content

Commit 890c1b3

Browse files
committed
fix the merge conflict
Merge branch 'main' into feat/systemdisk-size Signed-off-by: shenxianjie <327411586@qq.com>
2 parents 6b107e8 + 1514b23 commit 890c1b3

File tree

14 files changed

+144
-50
lines changed

14 files changed

+144
-50
lines changed

.github/workflows/latest-build.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ jobs:
1717
go-version: '1.23'
1818
cache: false
1919

20-
- name: Config env
21-
run: |
22-
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_AK }}" >> $GITHUB_ENV
23-
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SK }}" >> $GITHUB_ENV
24-
echo "AWS_DEFAULT_REGION=us-east-2" >> $GITHUB_ENV
25-
26-
- name: AWS CLI Init
27-
uses: unfor19/install-aws-cli-action@v1
28-
29-
- name: Config ECR
30-
run: |
31-
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/cloudpilotai
20+
- name: Config ACR
21+
uses: docker/login-action@v3
22+
with:
23+
registry: cloudpilotai-registry.cn-hangzhou.cr.aliyuncs.com
24+
username: ${{ secrets.ALIBABACLOUD_USERNAME }}
25+
password: ${{ secrets.ALIBABACLOUD_PASSWORD }}
3226

3327
- uses: ko-build/setup-ko@v0.6
3428

3529
- name: build and publish image
3630
run: |
37-
export KO_DOCKER_REPO=public.ecr.aws/cloudpilotai/alibabacloud/karpenter
31+
export KO_DOCKER_REPO=cloudpilotai-registry.cn-hangzhou.cr.aliyuncs.com/cloudpilotai/karpenter-provider-alibabacloud
3832
ko build --bare github.com/cloudpilot-ai/karpenter-provider-alibabacloud/cmd/controller

.github/workflows/release-build.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,17 @@ jobs:
3838
go-version: '1.23'
3939
cache: false
4040

41-
- name: Config env
42-
run: |
43-
echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_AK }}" >> $GITHUB_ENV
44-
echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SK }}" >> $GITHUB_ENV
45-
echo "AWS_DEFAULT_REGION=us-east-2" >> $GITHUB_ENV
46-
47-
- name: AWS CLI Init
48-
uses: unfor19/install-aws-cli-action@v1
49-
50-
- name: Config ECR
51-
run: |
52-
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/cloudpilotai
41+
- name: Config ACR
42+
uses: docker/login-action@v3
43+
with:
44+
registry: cloudpilotai-registry.cn-hangzhou.cr.aliyuncs.com
45+
username: ${{ secrets.ALIBABACLOUD_USERNAME }}
46+
password: ${{ secrets.ALIBABACLOUD_PASSWORD }}
5347

5448
- uses: ko-build/setup-ko@v0.6
5549

5650
- name: Build and publish image
5751
run: |
58-
export KO_DOCKER_REPO=public.ecr.aws/cloudpilotai/alibabacloud/karpenter
52+
export KO_DOCKER_REPO=cloudpilotai-registry.cn-hangzhou.cr.aliyuncs.com/cloudpilotai/karpenter-provider-alibabacloud
5953
export IMAGE_TAG=${{ env.tag }}
6054
ko build --bare github.com/cloudpilot-ai/karpenter-provider-alibabacloud/cmd/controller -t $IMAGE_TAG

charts/index.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ entries:
33
karpenter:
44
- apiVersion: v2
55
appVersion: 1.16.0
6-
created: "2025-01-15T09:11:50.624396+08:00"
6+
created: "2025-02-04T17:31:39.658727+08:00"
77
description: A Helm chart for Karpenter
8-
digest: f4361ebba5eaf3f6afcf75d61c4c2dfa0166e29a989e82294c2aad90642e99c4
8+
digest: 2315fed0b7a1f3809f5a3771391579ed950b14483d96cc0efeadb5d619a05ecb
99
name: karpenter
1010
type: application
1111
urls:
1212
- karpenter-0.1.4.tgz
1313
version: 0.1.4
1414
- apiVersion: v2
1515
appVersion: 1.16.0
16-
created: "2025-01-15T09:11:50.623949+08:00"
16+
created: "2025-02-04T17:31:39.657605+08:00"
1717
description: A Helm chart for Kubernetes
1818
digest: ccb800ddac0480fe67d708693de711ae3b0460169a6a53f1495094e878d693af
1919
name: karpenter
@@ -23,7 +23,7 @@ entries:
2323
version: 0.1.3
2424
- apiVersion: v2
2525
appVersion: 1.16.0
26-
created: "2025-01-15T09:11:50.623214+08:00"
26+
created: "2025-02-04T17:31:39.653873+08:00"
2727
description: A Helm chart for Kubernetes
2828
digest: 666cfa537dc50ff73fd11726717e6e4c0f4a7f9c28d03a456183e272ca2ce392
2929
name: karpenter
@@ -33,7 +33,7 @@ entries:
3333
version: 0.1.2
3434
- apiVersion: v2
3535
appVersion: 1.16.0
36-
created: "2025-01-15T09:11:50.622784+08:00"
36+
created: "2025-02-04T17:31:39.65301+08:00"
3737
description: A Helm chart for Kubernetes
3838
digest: 38936d516110324db4f79418b5f3d8c1745778f1bf5357c2f011a8953295ab39
3939
name: karpenter
@@ -43,12 +43,12 @@ entries:
4343
version: 0.1.0
4444
- apiVersion: v2
4545
appVersion: 1.16.0
46-
created: "2025-01-15T09:11:50.62233+08:00"
46+
created: "2025-02-04T17:31:39.652033+08:00"
4747
description: A Helm chart for Kubernetes
4848
digest: a611c779eb159afff8f4b889b57807f83ae921a4932666db814803c8966af76f
4949
name: karpenter
5050
type: application
5151
urls:
5252
- karpenter-0.0.1.tgz
5353
version: 0.0.1
54-
generated: "2025-01-15T09:11:50.621185+08:00"
54+
generated: "2025-02-04T17:31:39.65058+08:00"

charts/karpenter-0.1.4.tgz

30 Bytes
Binary file not shown.

charts/karpenter/crds/karpenter.k8s.alibabacloud_ecsnodeclasses.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,13 @@ spec:
262262
description: SystemDisk to be applied to provisioned nodes.
263263
properties:
264264
categories:
265+
default:
266+
- cloud
267+
- cloud_efficiency
268+
- cloud_ssd
269+
- cloud_essd
270+
- cloud_auto
271+
- cloud_essd_entry
265272
description: |-
266273
The category of the system disk (for example, cloud and cloud_ssd).
267274
Different ECS is compatible with different disk category, using array to maximize ECS creation success.
@@ -286,6 +293,18 @@ spec:
286293
- PL3
287294
type: string
288295
size:
296+
default: 20
297+
description: |-
298+
The size of the system disk. Unit: GiB.
299+
Valid values:
300+
* If you set Category to cloud: 20 to 500.
301+
* If you set Category to other disk categories: 20 to 2048.
302+
format: int32
303+
type: integer
304+
x-kubernetes-validations:
305+
- message: size invalid
306+
rule: self >= 20
307+
volumeSize:
289308
description: |-
290309
Size in `Gi`, `G`, `Ti`, or `T`. You must specify either a snapshot ID or
291310
a volume size. The following are the supported volumes sizes for each volume

charts/karpenter/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ controller:
4343
rollingUpdate:
4444
maxUnavailable: 1
4545
image:
46-
repository: "public.ecr.aws/cloudpilotai/alibabacloud/karpenter"
46+
repository: "cloudpilotai-registry.cn-hangzhou.cr.aliyuncs.com/cloudpilotai/karpenter-provider-alibabacloud"
4747
tag: "latest"
4848
pullPolicy: IfNotPresent
4949
priorityClassName: system-cluster-critical

pkg/apis/v1alpha1/ecsnodeclass.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ type SystemDisk struct {
210210
// Different ECS is compatible with different disk category, using array to maximize ECS creation success.
211211
// Valid values:"cloud", "cloud_efficiency", "cloud_ssd", "cloud_essd", "cloud_auto", and "cloud_essd_entry"
212212
// +kubebuilder:validation:Items=Enum=cloud;cloud_efficiency;cloud_ssd;cloud_essd;cloud_auto;cloud_essd_entry
213+
// +kubebuilder:default:={"cloud","cloud_efficiency","cloud_ssd","cloud_essd","cloud_auto","cloud_essd_entry"}
213214
// +optional
214215
Categories []string `json:"categories,omitempty"`
215216
// Size in `Gi`, `G`, `Ti`, or `T`. You must specify either a snapshot ID or
@@ -229,7 +230,16 @@ type SystemDisk struct {
229230
// +kubebuilder:validation:Schemaless
230231
// +kubebuilder:validation:Type:=string
231232
// +optional
232-
Size *resource.Quantity `json:"size,omitempty" hash:"string"`
233+
VolumeSize *resource.Quantity `json:"volumeSize,omitempty" hash:"string"`
234+
// The size of the system disk. Unit: GiB.
235+
// Valid values:
236+
// * If you set Category to cloud: 20 to 500.
237+
// * If you set Category to other disk categories: 20 to 2048.
238+
//
239+
// +kubebuilder:validation:XValidation:message="size invalid",rule="self >= 20"
240+
// +kubebuilder:default:=20
241+
// +optional
242+
Size *int32 `json:"size,omitempty"`
233243
// The performance level of the ESSD to use as the system disk. Default value: PL0.
234244
// Valid values:
235245
// * PL0: A single ESSD can deliver up to 10,000 random read/write IOPS.

pkg/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controllers/controllers.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
nodeclasshash "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/nodeclass/hash"
3535
nodeclaasstatus "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/nodeclass/status"
3636
nodeclasstermination "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/nodeclass/termination"
37+
nodeclassvolumesize "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/nodeclass/volumesize"
3738
providersinstancetype "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/providers/instancetype"
3839
controllerspricing "github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/providers/pricing"
3940
"github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/controllers/telemetry"
@@ -57,6 +58,7 @@ func NewControllers(ctx context.Context, mgr manager.Manager, clk clock.Clock, r
5758

5859
controllers := []controller.Controller{
5960
nodeclasshash.NewController(kubeClient),
61+
nodeclassvolumesize.NewController(kubeClient),
6062
nodeclaasstatus.NewController(kubeClient, vSwitchProvider, securityGroupProvider, imageProvider),
6163
nodeclasstermination.NewController(kubeClient, recorder),
6264
controllerspricing.NewController(pricingProvider),
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
Copyright 2024 The CloudPilot AI Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package volumesize
18+
19+
import (
20+
"context"
21+
"fmt"
22+
23+
"github.com/awslabs/operatorpkg/reasonable"
24+
"k8s.io/apimachinery/pkg/api/equality"
25+
controllerruntime "sigs.k8s.io/controller-runtime"
26+
"sigs.k8s.io/controller-runtime/pkg/client"
27+
"sigs.k8s.io/controller-runtime/pkg/controller"
28+
"sigs.k8s.io/controller-runtime/pkg/manager"
29+
"sigs.k8s.io/controller-runtime/pkg/reconcile"
30+
"sigs.k8s.io/karpenter/pkg/operator/injection"
31+
"sigs.k8s.io/karpenter/pkg/utils/resources"
32+
33+
"github.com/cloudpilot-ai/karpenter-provider-alibabacloud/pkg/apis/v1alpha1"
34+
)
35+
36+
type Controller struct {
37+
kubeClient client.Client
38+
}
39+
40+
func NewController(kubeClient client.Client) *Controller {
41+
return &Controller{
42+
kubeClient: kubeClient,
43+
}
44+
}
45+
46+
func (c *Controller) Reconcile(ctx context.Context, nodeClass *v1alpha1.ECSNodeClass) (reconcile.Result, error) {
47+
ctx = injection.WithControllerName(ctx, "nodeclass.volumesize")
48+
49+
stored := nodeClass.DeepCopy()
50+
51+
if nodeClass.Spec.SystemDisk.Size != nil {
52+
nodeClass.Spec.SystemDisk.VolumeSize = resources.Quantity(fmt.Sprintf("%dG", *nodeClass.Spec.SystemDisk.Size))
53+
}
54+
if !equality.Semantic.DeepEqual(stored, nodeClass) {
55+
if err := c.kubeClient.Patch(ctx, nodeClass, client.MergeFrom(stored)); err != nil {
56+
return reconcile.Result{}, err
57+
}
58+
}
59+
60+
return reconcile.Result{}, nil
61+
}
62+
63+
func (c *Controller) Register(_ context.Context, m manager.Manager) error {
64+
return controllerruntime.NewControllerManagedBy(m).
65+
Named("nodeclass.volumesize").
66+
For(&v1alpha1.ECSNodeClass{}).
67+
WithOptions(controller.Options{
68+
RateLimiter: reasonable.RateLimiter(),
69+
MaxConcurrentReconciles: 10,
70+
}).
71+
Complete(reconcile.AsReconciler(m.GetClient(), c))
72+
}

0 commit comments

Comments
 (0)