Skip to content

Commit

Permalink
✨ feat: support hpa api version v2
Browse files Browse the repository at this point in the history
  • Loading branch information
lwnmengjing committed Mar 20, 2024
1 parent 795eb7e commit e0ed520
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 497 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.22'
- name: Test
run: go test -v ./...
tag:
Expand All @@ -42,7 +42,7 @@ jobs:
- name: Setup
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: '1.22'
- name: New Artifact Dir
run: mkdir artifact
- name: Build ${{ matrix.os }}
Expand Down
16 changes: 8 additions & 8 deletions chart/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ import (
func NewHpaChart(scope constructs.Construct, id string, props *cdk8s.ChartProps) cdk8s.Chart {
chart := cdk8s.NewChart(scope, jsii.String(id), props)

k8s.NewKubeHorizontalPodAutoscalerV2Beta2(chart, jsii.String("hpa"), &k8s.KubeHorizontalPodAutoscalerV2Beta2Props{
k8s.NewKubeHorizontalPodAutoscalerV2(chart, jsii.String("hpa"), &k8s.KubeHorizontalPodAutoscalerV2Props{
Metadata: &k8s.ObjectMeta{
Labels: props.Labels,
Name: &config.Cfg.Service,
},
Spec: &k8s.HorizontalPodAutoscalerSpecV2Beta2{
Spec: &k8s.HorizontalPodAutoscalerSpecV2{
MinReplicas: jsii.Number(float64(config.Cfg.MinReplicas)),
MaxReplicas: jsii.Number(float64(config.Cfg.MaxReplicas)),
ScaleTargetRef: &k8s.CrossVersionObjectReferenceV2Beta2{
ScaleTargetRef: &k8s.CrossVersionObjectReferenceV2{
Kind: jsii.String(config.Cfg.WorkloadType),
Name: jsii.String(config.Cfg.Service),
ApiVersion: jsii.String("apps/v1"),
},
Metrics: &[]*k8s.MetricSpecV2Beta2{
Metrics: &[]*k8s.MetricSpecV2{
{
Type: jsii.String("Resource"),
Resource: &k8s.ResourceMetricSourceV2Beta2{
Resource: &k8s.ResourceMetricSourceV2{
Name: jsii.String("memory"),
Target: &k8s.MetricTargetV2Beta2{
Target: &k8s.MetricTargetV2{
Type: jsii.String("Utilization"),
AverageUtilization: jsii.Number(80),
},
},
},
{
Type: jsii.String("Resource"),
Resource: &k8s.ResourceMetricSourceV2Beta2{
Resource: &k8s.ResourceMetricSourceV2{
Name: jsii.String("cpu"),
Target: &k8s.MetricTargetV2Beta2{
Target: &k8s.MetricTargetV2{
Type: jsii.String("Utilization"),
AverageUtilization: jsii.Number(80),
},
Expand Down
48 changes: 25 additions & 23 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
module github.com/mss-boot-io/cd-template

go 1.18
go 1.20

require (
github.com/aws/constructs-go/constructs/v10 v10.1.145
github.com/aws/jsii-runtime-go v1.70.0
github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2 v2.5.34
github.com/spf13/viper v1.13.0
github.com/aws/constructs-go/constructs/v10 v10.3.0
github.com/aws/jsii-runtime-go v1.95.0
github.com/cdk8s-team/cdk8s-core-go/cdk8s/v2 v2.68.49
github.com/spf13/viper v1.18.2
)

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/yuin/goldmark v1.4.13 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/yuin/goldmark v1.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240318143956-a85f2c67cd81 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.12 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.19.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit e0ed520

Please sign in to comment.