You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/03/03 11:28:25 UTC
[camel-k] branch master updated: knative(serving): add support for
additional annotations
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 98cb0fc knative(serving): add support for additional annotations
98cb0fc is described below
commit 98cb0fc599f482a6e585b928e73cd4b8caaeec16
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Sat Mar 2 00:04:09 2019 +0100
knative(serving): add support for additional annotations
---
pkg/trait/knative_service.go | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/pkg/trait/knative_service.go b/pkg/trait/knative_service.go
index 5b2abb9..2f16c84 100644
--- a/pkg/trait/knative_service.go
+++ b/pkg/trait/knative_service.go
@@ -32,15 +32,21 @@ import (
)
const (
- knativeMinScaleAnnotation = "autoscaling.knative.dev/minScale"
- knativeMaxScaleAnnotation = "autoscaling.knative.dev/maxScale"
+ knativeServingClassAnnotation = "autoscaling.knative.dev/class"
+ knativeServingMetricAnnotation = "autoscaling.knative.dev/metric"
+ knativeServingTargetAnnotation = "autoscaling.knative.dev/target"
+ knativeServingMinScaleAnnotation = "autoscaling.knative.dev/minScale"
+ knativeServingMaxScaleAnnotation = "autoscaling.knative.dev/maxScale"
)
type knativeServiceTrait struct {
BaseTrait `property:",squash"`
- MinScale *int `property:"min-scale"`
- MaxScale *int `property:"max-scale"`
- Auto *bool `property:"auto"`
+ Class string `property:"autoscaling-class"`
+ Metric string `property:"autoscaling-metric"`
+ Target *int `property:"autoscaling-target"`
+ MinScale *int `property:"min-scale"`
+ MaxScale *int `property:"max-scale"`
+ Auto *bool `property:"auto"`
}
func newKnativeServiceTrait() *knativeServiceTrait {
@@ -211,11 +217,24 @@ func (t *knativeServiceTrait) getServiceFor(e *Environment) (*serving.Service, e
annotations := make(map[string]string)
// Resolve registry host names when used
annotations["alpha.image.policy.openshift.io/resolve-names"] = "*"
+
+ //
+ // Set Knative Scaling behavior
+ //
+ if t.Class != "" {
+ annotations[knativeServingClassAnnotation] = t.Class
+ }
+ if t.Metric != "" {
+ annotations[knativeServingMetricAnnotation] = t.Metric
+ }
+ if t.Target != nil {
+ annotations[knativeServingTargetAnnotation] = strconv.Itoa(*t.Target)
+ }
if t.MinScale != nil {
- annotations[knativeMinScaleAnnotation] = strconv.Itoa(*t.MinScale)
+ annotations[knativeServingMinScaleAnnotation] = strconv.Itoa(*t.MinScale)
}
if t.MaxScale != nil {
- annotations[knativeMaxScaleAnnotation] = strconv.Itoa(*t.MaxScale)
+ annotations[knativeServingMaxScaleAnnotation] = strconv.Itoa(*t.MaxScale)
}
svc := serving.Service{