Skip to content

Commit

Permalink
Feat/schedule autoscale (#2667)
Browse files Browse the repository at this point in the history
* fix: push options for local development

* chore: update deploy-agent for local development

* feat: scheduled autoscale

* test: scheduled autoscale

* docs: update api with schedule autoscale spec

* refactor: use interface

* Replace exec.Stream with exec.StreamWithContext

* refactor: review suggestions

* refactor: more review suggetions

---------

Co-authored-by: Wilson Júnior <wilsonpjunior@gmail.com>
  • Loading branch information
crgisch and wpjunior committed Nov 22, 2023
1 parent 912853d commit aeeacbc
Show file tree
Hide file tree
Showing 16 changed files with 955 additions and 414 deletions.
2 changes: 1 addition & 1 deletion app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2705,7 +2705,7 @@ func (s *S) TestAppMarshalJSONWithAutoscaleProv(c *check.C) {
},
"tags": []interface{}{"tag a", "tag b"},
"autoscale": []interface{}{
map[string]interface{}{"process": "p1", "minUnits": float64(0), "maxUnits": float64(0), "averageCPU": "", "version": float64(0)},
map[string]interface{}{"process": "p1", "minUnits": float64(0), "maxUnits": float64(0), "version": float64(0)},
},
"autoscaleRecommendation": []interface{}{
map[string]interface{}{
Expand Down
1 change: 1 addition & 0 deletions builder/kubernetes/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ func (b *kubernetesBuilder) buildContainerImage(ctx context.Context, app provisi
},
SourceImage: baseImage,
DestinationImages: dstImages,
PushOptions: &buildpb.PushOptions{InsecureRegistry: cc.InsecureRegistry()},
Data: data,
Containerfile: opts.Dockerfile,
}
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:

deploy-agent:
container_name: deploy-agent
image: tsuru/deploy-agent:v2.3.2
image: tsuru/deploy-agent:v2.3.3
command:
- -port=8000
- -buildkit-addr=tcp://buildkit:8001
Expand All @@ -37,7 +37,7 @@ services:
image: moby/buildkit:v0.12.1
privileged: true
volumes:
- ./etc/buildkitd.toml:/etc/buildkit/buildkitd.toml:ro
- ./etc/buildkitd.toml:/etc/buildkit/buildkitd.toml
restart: unless-stopped
depends_on:
- registry
Expand Down
17 changes: 17 additions & 0 deletions docs/reference/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4715,8 +4715,25 @@ definitions:
type: integer
averageCPU:
type: string
schedules:
type: array
items:
type: object
$ref: "#/definitions/AutoScaleSchedule"
version:
type: integer
AutoScaleSchedule:
description: Auto Scale schedules struct
type: object
properties:
minReplicas:
type: integer
start:
type: string
end:
type: string
timezone:
type: string
AppCName:
description: Application CNames
type: object
Expand Down
74 changes: 42 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/hashicorp/go-version v0.0.0-20180716215031-270f2f71b1ee
github.com/imdario/mergo v0.3.12
github.com/imdario/mergo v0.3.13
github.com/kedacore/keda/v2 v2.10.1
github.com/kr/pretty v0.3.0
github.com/lestrrat-go/jwx/v2 v2.0.11
github.com/mattn/go-shellwords v1.0.12
Expand All @@ -28,7 +29,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pmorie/go-open-service-broker-client v0.0.0-20180330214919-dca737037ce6
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.37.0
github.com/prometheus/common v0.42.0
github.com/robfig/cron/v3 v3.0.1
github.com/rs/cors v1.9.0
github.com/sajari/fuzzy v1.0.0
Expand All @@ -42,31 +43,33 @@ require (
go.uber.org/automaxprocs v1.5.3
golang.org/x/crypto v0.9.0
golang.org/x/net v0.10.0
golang.org/x/oauth2 v0.1.0
golang.org/x/oauth2 v0.6.0
golang.org/x/sys v0.8.0
golang.org/x/term v0.8.0
golang.org/x/text v0.9.0
google.golang.org/grpc v1.50.1
google.golang.org/grpc v1.53.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce
k8s.io/api v0.23.17
k8s.io/apiextensions-apiserver v0.20.6
k8s.io/apimachinery v0.23.17
k8s.io/api v0.26.2
k8s.io/apiextensions-apiserver v0.26.2
k8s.io/apimachinery v0.26.2
k8s.io/autoscaler/vertical-pod-autoscaler v0.9.2
k8s.io/client-go v0.23.17
k8s.io/code-generator v0.20.6
k8s.io/client-go v0.26.2
k8s.io/code-generator v0.26.2
k8s.io/ingress-gce v1.20.1
k8s.io/metrics v0.20.6
sigs.k8s.io/yaml v1.2.0
k8s.io/metrics v0.26.2
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/yaml v1.3.0
)

require (
cloud.google.com/go v0.97.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/RobotsAndPencils/go-saml v0.0.0-20150922030833-aa127de49a01 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect
github.com/containerd/containerd v1.6.16 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -75,33 +78,36 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/howeyc/fsnotify v0.9.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kardianos/osext v0.0.0-20151124170342-10da29423eb9 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lestrrat-go/blackmagic v1.0.1 // indirect
github.com/lestrrat-go/httpcc v1.0.1 // indirect
github.com/lestrrat-go/httprc v1.0.4 // indirect
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/moby/patternmatcher v0.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
Expand All @@ -110,31 +116,35 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/opencontainers/runc v1.1.4 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
go.uber.org/atomic v1.4.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/time v0.1.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220706185917-7780775163c4 // indirect
google.golang.org/genproto v0.0.0-20230227214838-9b19f0bdc514 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
k8s.io/component-base v0.26.2 // indirect
k8s.io/gengo v0.0.0-20221011193443-fad74ee6edd9 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d // indirect
knative.dev/pkg v0.0.0-20230306194819-b77a78c6c0ad // indirect
sigs.k8s.io/controller-runtime v0.14.5 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

Expand Down

0 comments on commit aeeacbc

Please sign in to comment.