Skip to content

Commit 6d27714

Browse files
authored
Add Keda Deployer (#3386)
* Add Keda Deployer * Run hack/update-codegen.sh * Fix linter issues * Scale down keda-http-add-on to only one replica in CI to save resources * Allow to specify the cluster-domain * Remove outdated comment * Update comment * Remove port section in external name service * Rename interceptor-proxy service to interceptor-bridge service * Fix: add owner reference in bridge service too * Run `make schema-generate` * Update component-versions via component-versions.json * Remove cluster-domain flag and use cluster.local instead for now * Fix: add "keda" to deployer enum for jsonschema * Remove unneeded blank import * Remove custom roundtripper for keda integration tests * Run `./hack/update-codegen.sh` * Fix linter issue * Fix unit test for component version script * Update to Keda HTTP Add-on 1.12 * Address review comments
1 parent d601180 commit 6d27714

25 files changed

+945
-109
lines changed

cmd/client.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77

88
"github.com/ory/viper"
9+
"knative.dev/func/pkg/keda"
910

1011
"knative.dev/func/cmd/prompt"
1112
"knative.dev/func/pkg/buildpacks"
@@ -68,9 +69,9 @@ func NewClient(cfg ClientConfig, options ...fn.Option) (*fn.Client, func()) {
6869
fn.WithRepositoriesPath(config.RepositoriesPath()),
6970
fn.WithScaffolder(buildpacks.NewScaffolder(cfg.Verbose)),
7071
fn.WithBuilder(buildpacks.NewBuilder(buildpacks.WithVerbose(cfg.Verbose))),
71-
fn.WithRemovers(knative.NewRemover(cfg.Verbose), k8s.NewRemover(cfg.Verbose)),
72-
fn.WithDescribers(knative.NewDescriber(cfg.Verbose), k8s.NewDescriber(cfg.Verbose)),
73-
fn.WithListers(knative.NewLister(cfg.Verbose), k8s.NewLister(cfg.Verbose)),
72+
fn.WithRemovers(knative.NewRemover(cfg.Verbose), k8s.NewRemover(cfg.Verbose), keda.NewRemover(cfg.Verbose)),
73+
fn.WithDescribers(knative.NewDescriber(cfg.Verbose), k8s.NewDescriber(cfg.Verbose), keda.NewDescriber(cfg.Verbose)),
74+
fn.WithListers(knative.NewLister(cfg.Verbose), k8s.NewLister(cfg.Verbose), keda.NewLister(cfg.Verbose)),
7475
fn.WithDeployer(d),
7576
fn.WithPipelinesProvider(pp),
7677
fn.WithPusher(docker.NewPusher(
@@ -170,6 +171,15 @@ func newK8sDeployer(verbose bool) fn.Deployer {
170171
return k8s.NewDeployer(options...)
171172
}
172173

174+
func newKedaDeployer(verbose bool) fn.Deployer {
175+
options := []keda.DeployerOpt{
176+
keda.WithDeployerVerbose(verbose),
177+
keda.WithDeployerDecorator(deployDecorator{}),
178+
}
179+
180+
return keda.NewDeployer(options...)
181+
}
182+
173183
type deployDecorator struct {
174184
oshDec k8s.OpenshiftMetadataDecorator
175185
}

cmd/completion_util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/spf13/cobra"
1212
fn "knative.dev/func/pkg/functions"
1313
"knative.dev/func/pkg/k8s"
14+
"knative.dev/func/pkg/keda"
1415
"knative.dev/func/pkg/knative"
1516
)
1617

@@ -170,6 +171,7 @@ func CompleteDeployerList(cmd *cobra.Command, args []string, complete string) (m
170171
deployers := []string{
171172
knative.KnativeDeployerName,
172173
k8s.KubernetesDeployerName,
174+
keda.KedaDeployerName,
173175
}
174176

175177
d = cobra.ShellCompDirectiveNoFileComp

cmd/deploy.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"knative.dev/func/pkg/config"
1919
fn "knative.dev/func/pkg/functions"
2020
"knative.dev/func/pkg/k8s"
21+
"knative.dev/func/pkg/keda"
2122
"knative.dev/func/pkg/knative"
2223
"knative.dev/func/pkg/utils"
2324
)
@@ -195,7 +196,7 @@ EXAMPLES
195196
cmd.Flags().String("service-account", f.Deploy.ServiceAccountName,
196197
"Service account to be used in the deployed function ($FUNC_SERVICE_ACCOUNT)")
197198
cmd.Flags().String("deployer", f.Deploy.Deployer,
198-
fmt.Sprintf("Type of deployment to use: '%s' for Knative Service (default) or '%s' for Kubernetes Deployment ($FUNC_DEPLOY_TYPE)", knative.KnativeDeployerName, k8s.KubernetesDeployerName))
199+
fmt.Sprintf("Type of deployment to use: '%s' for Knative Service (default), '%s' for Kubernetes Deployment or '%s' for Deployment with a Keda HTTP scaler ($FUNC_DEPLOY_TYPE)", knative.KnativeDeployerName, k8s.KubernetesDeployerName, keda.KedaDeployerName))
199200
// Static Flags:
200201
// Options which have static defaults only (not globally configurable nor
201202
// persisted with the function)
@@ -799,8 +800,10 @@ func (c deployConfig) clientOptions() ([]fn.Option, error) {
799800
o = append(o, fn.WithDeployer(newKnativeDeployer(c.Verbose)))
800801
case k8s.KubernetesDeployerName:
801802
o = append(o, fn.WithDeployer(newK8sDeployer(c.Verbose)))
803+
case keda.KedaDeployerName:
804+
o = append(o, fn.WithDeployer(newKedaDeployer(c.Verbose)))
802805
default:
803-
return o, fmt.Errorf("unsupported deploy type: %s (supported: %s, %s)", deployer, knative.KnativeDeployerName, k8s.KubernetesDeployerName)
806+
return o, fmt.Errorf("unsupported deploy type: %s (supported: %s, %s, %s)", deployer, knative.KnativeDeployerName, k8s.KubernetesDeployerName, keda.KedaDeployerName)
804807
}
805808

806809
return o, nil

docs/reference/func_deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func deploy
119119
-b, --builder string Builder to use when creating the function's container. Currently supported builders are "host", "pack" and "s2i". (default "pack")
120120
--builder-image string Specify a custom builder image for use by the builder other than its default. ($FUNC_BUILDER_IMAGE)
121121
-c, --confirm Prompt to confirm options interactively ($FUNC_CONFIRM)
122-
--deployer string Type of deployment to use: 'knative' for Knative Service (default) or 'raw' for Kubernetes Deployment ($FUNC_DEPLOY_TYPE)
122+
--deployer string Type of deployment to use: 'knative' for Knative Service (default), 'raw' for Kubernetes Deployment or 'keda' for Deployment with a Keda HTTP scaler ($FUNC_DEPLOY_TYPE)
123123
--domain string Domain to use for the function's route. Cluster must be configured with domain matching for the given domain (ignored if unrecognized) ($FUNC_DOMAIN)
124124
-e, --env stringArray Environment variable to set in the form NAME=VALUE. You may provide this flag multiple times for setting multiple environment variables. To unset, specify the environment variable name followed by a "-" (e.g., NAME-).
125125
-t, --git-branch string Git revision (branch) to be used when deploying via the Git repository ($FUNC_GIT_BRANCH)

go.mod

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module knative.dev/func
22

3-
go 1.24.4
3+
go 1.25.5
44

55
// this is required bacause of bad dep in github.com/openshift-pipelines/pipelines-as-code
66
replace github.com/imdario/mergo => dario.cat/mergo v1.0.1
@@ -38,6 +38,7 @@ require (
3838
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
3939
github.com/heroku/color v0.0.6
4040
github.com/hinshun/vt10x v0.0.0-20220228203356-1ab2cad5fd82
41+
github.com/kedacore/http-add-on v0.12.0
4142
github.com/manifestival/client-go-client v0.6.0
4243
github.com/manifestival/manifestival v0.7.2
4344
github.com/modelcontextprotocol/go-sdk v1.1.0
@@ -50,15 +51,15 @@ require (
5051
github.com/pkg/errors v0.9.1
5152
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
5253
github.com/schollz/progressbar/v3 v3.13.1
53-
github.com/spf13/cobra v1.9.1
54+
github.com/spf13/cobra v1.10.2
5455
github.com/spf13/pflag v1.0.10
5556
github.com/tektoncd/cli v0.37.0
5657
github.com/tektoncd/pipeline v0.65.1
5758
gitlab.com/gitlab-org/api/client-go v0.150.0
5859
golang.org/x/crypto v0.47.0
5960
golang.org/x/mod v0.32.0
6061
golang.org/x/net v0.49.0
61-
golang.org/x/oauth2 v0.32.0
62+
golang.org/x/oauth2 v0.34.0
6263
golang.org/x/sync v0.19.0
6364
golang.org/x/sys v0.40.0
6465
golang.org/x/term v0.39.0
@@ -69,6 +70,7 @@ require (
6970
k8s.io/apimachinery v0.34.3
7071
k8s.io/client-go v0.34.3
7172
k8s.io/klog/v2 v2.130.1
73+
k8s.io/utils v0.0.0-20260108192941-914a6e750570
7274
knative.dev/client/pkg v0.0.0-20260128022831-382000a93f17
7375
knative.dev/eventing v0.48.0
7476
knative.dev/hack v0.0.0-20260120115810-bf6758cba446
@@ -93,7 +95,7 @@ require (
9395
github.com/Azure/go-autorest/logger v0.2.2 // indirect
9496
github.com/Azure/go-autorest/tracing v0.6.1 // indirect
9597
github.com/GoogleContainerTools/kaniko v1.24.0 // indirect
96-
github.com/Masterminds/semver/v3 v3.2.1 // indirect
98+
github.com/Masterminds/semver/v3 v3.4.0 // indirect
9799
github.com/Microsoft/hcsshim v0.13.0 // indirect
98100
github.com/ProtonMail/go-crypto v1.2.0 // indirect
99101
github.com/agext/levenshtein v1.2.3 // indirect
@@ -148,38 +150,40 @@ require (
148150
github.com/docker/go-metrics v0.0.1 // indirect
149151
github.com/docker/go-units v0.5.0 // indirect
150152
github.com/dustin/go-humanize v1.0.1 // indirect
151-
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
153+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
152154
github.com/emirpasic/gods v1.18.1 // indirect
153155
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
154-
github.com/fatih/color v1.16.0 // indirect
156+
github.com/fatih/color v1.18.0 // indirect
155157
github.com/felixge/httpsnoop v1.0.4 // indirect
156158
github.com/fsnotify/fsnotify v1.9.0 // indirect
157159
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
158160
github.com/gdamore/encoding v1.0.1 // indirect
159161
github.com/gdamore/tcell/v2 v2.8.1 // indirect
160-
github.com/go-errors/errors v1.4.2 // indirect
162+
github.com/go-errors/errors v1.5.1 // indirect
161163
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
162164
github.com/go-logr/logr v1.4.3 // indirect
163165
github.com/go-logr/stdr v1.2.2 // indirect
164-
github.com/go-openapi/jsonpointer v0.21.1 // indirect
165-
github.com/go-openapi/jsonreference v0.21.0 // indirect
166+
github.com/go-openapi/jsonpointer v0.22.4 // indirect
167+
github.com/go-openapi/jsonreference v0.21.4 // indirect
166168
github.com/go-openapi/swag v0.23.1 // indirect
169+
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
167170
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
168171
github.com/gogo/protobuf v1.3.2 // indirect
169172
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
170173
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
171174
github.com/golang/protobuf v1.5.4 // indirect
172175
github.com/google/btree v1.1.3 // indirect
173176
github.com/google/cel-go v0.26.1 // indirect
174-
github.com/google/gnostic-models v0.7.0 // indirect
177+
github.com/google/gnostic-models v0.7.1 // indirect
175178
github.com/google/go-intervals v0.0.2 // indirect
176179
github.com/google/go-querystring v1.1.0 // indirect
177180
github.com/google/jsonschema-go v0.3.0 // indirect
178181
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
179182
github.com/gorilla/mux v1.8.1 // indirect
180183
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
184+
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
181185
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
182-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
186+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.5 // indirect
183187
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b // indirect
184188
github.com/hashicorp/errwrap v1.1.0 // indirect
185189
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
@@ -202,8 +206,8 @@ require (
202206
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
203207
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
204208
github.com/magiconair/properties v1.8.7 // indirect
205-
github.com/mailru/easyjson v0.9.0 // indirect
206-
github.com/mattn/go-colorable v0.1.13 // indirect
209+
github.com/mailru/easyjson v0.9.1 // indirect
210+
github.com/mattn/go-colorable v0.1.14 // indirect
207211
github.com/mattn/go-isatty v0.0.20 // indirect
208212
github.com/mattn/go-runewidth v0.0.19 // indirect
209213
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
@@ -231,7 +235,7 @@ require (
231235
github.com/morikuni/aec v1.0.0 // indirect
232236
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
233237
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
234-
github.com/onsi/gomega v1.37.0 // indirect
238+
github.com/onsi/gomega v1.39.0 // indirect
235239
github.com/opencontainers/go-digest v1.0.0 // indirect
236240
github.com/opencontainers/runtime-spec v1.2.1 // indirect
237241
github.com/opencontainers/selinux v1.12.0 // indirect
@@ -243,7 +247,7 @@ require (
243247
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
244248
github.com/prometheus/client_golang v1.23.2 // indirect
245249
github.com/prometheus/client_model v0.6.2 // indirect
246-
github.com/prometheus/common v0.67.4 // indirect
250+
github.com/prometheus/common v1.20.99 // indirect
247251
github.com/prometheus/procfs v0.19.2 // indirect
248252
github.com/prometheus/statsd_exporter v0.28.0 // indirect
249253
github.com/rickb777/date v1.20.2 // indirect
@@ -253,7 +257,7 @@ require (
253257
github.com/robfig/cron/v3 v3.0.1 // indirect
254258
github.com/russross/blackfriday/v2 v2.1.0 // indirect
255259
github.com/sagikazarmark/locafero v0.12.0 // indirect
256-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
260+
github.com/sergi/go-diff v1.4.0 // indirect
257261
github.com/sirupsen/logrus v1.9.3 // indirect
258262
github.com/skeema/knownhosts v1.3.1 // indirect
259263
github.com/spf13/afero v1.15.0 // indirect
@@ -285,31 +289,30 @@ require (
285289
go.uber.org/zap v1.27.1 // indirect
286290
go.yaml.in/yaml/v2 v2.4.3 // indirect
287291
go.yaml.in/yaml/v3 v3.0.4 // indirect
288-
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
292+
golang.org/x/exp v0.0.0-20260112195511-716be5621a96 // indirect
289293
golang.org/x/text v0.33.0 // indirect
290-
golang.org/x/time v0.12.0 // indirect
294+
golang.org/x/time v0.14.0 // indirect
291295
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
292296
google.golang.org/api v0.233.0 // indirect
293-
google.golang.org/genproto/googleapis/api v0.0.0-20251202230838-ff82c1b0f217 // indirect
294-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251202230838-ff82c1b0f217 // indirect
295-
google.golang.org/grpc v1.77.0 // indirect
296-
google.golang.org/protobuf v1.36.10 // indirect
297-
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
297+
google.golang.org/genproto/googleapis/api v0.0.0-20260122232226-8e98ce8d340d // indirect
298+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260122232226-8e98ce8d340d // indirect
299+
google.golang.org/grpc v1.78.0 // indirect
300+
google.golang.org/protobuf v1.36.11 // indirect
301+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
298302
gopkg.in/inf.v0 v0.9.1 // indirect
299303
gopkg.in/ini.v1 v1.67.0 // indirect
300304
gopkg.in/warnings.v0 v0.1.2 // indirect
301305
k8s.io/apiextensions-apiserver v0.34.3 // indirect
302306
k8s.io/apiserver v0.34.3 // indirect
303307
k8s.io/cli-runtime v0.34.1 // indirect
304-
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
305-
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
308+
k8s.io/kube-openapi v0.0.0-20251125145642-4e65d59e963e // indirect
306309
knative.dev/networking v0.0.0-20260120131110-a7cdca238a0d // indirect
307-
sigs.k8s.io/controller-runtime v0.20.4 // indirect
308-
sigs.k8s.io/gateway-api v1.1.0 // indirect
309-
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
310-
sigs.k8s.io/kustomize/api v0.20.1 // indirect
311-
sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect
310+
sigs.k8s.io/controller-runtime v0.22.1 // indirect
311+
sigs.k8s.io/gateway-api v1.4.1 // indirect
312+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
313+
sigs.k8s.io/kustomize/api v0.21.0 // indirect
314+
sigs.k8s.io/kustomize/kyaml v0.21.0 // indirect
312315
sigs.k8s.io/randfill v1.0.0 // indirect
313-
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
316+
sigs.k8s.io/structured-merge-diff/v6 v6.3.1 // indirect
314317
sigs.k8s.io/yaml v1.6.0 // indirect
315318
)

0 commit comments

Comments
 (0)