Add Ingress host, path and annotations support (#1325)

For each ingress controller, the format of ingress host,
path and annotations are different. To support different
kinds of controller, this PR adds new ingress config field
to http trigger spec. A user can set annotations, host and
path based on the type of underlying ingress controller
with CLI.

Command example:

fission route create --name foo \
    --url /foo/{bar} --function foofn --createingress \
    --ingressannotation "nginx.ingress.kubernetes.io/ssl-redirect=false" \
    --ingressannotation "nginx.ingress.kubernetes.io/use-regex=true" \
    --ingressrule "*=/foo/*"
This commit is contained in:
Ta-Ching Chen
2019-09-26 16:54:16 +08:00
committed by GitHub
parent 82a7acf408
commit 49d60b19f3
14 changed files with 1421 additions and 138 deletions
+14 -4
View File
@@ -29,6 +29,7 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
ferror "github.com/fission/fission/pkg/error"
"github.com/fission/fission/pkg/fission-cli/cmd/httptrigger"
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
"github.com/fission/fission/pkg/fission-cli/log"
"github.com/fission/fission/pkg/fission-cli/util"
@@ -143,12 +144,14 @@ func htCreate(c *cli.Context) error {
}
}
createIngress := false
if c.IsSet("createingress") {
createIngress = c.Bool("createingress")
}
createIngress := c.Bool("createingress")
ingressConfig, err := httptrigger.GetIngressConfig(c.StringSlice("ingressannotation"), c.String("ingressrule"), triggerUrl, nil)
util.CheckErr(err, "parse ingress configuration")
host := c.String("host")
if c.IsSet("host") {
log.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
}
// just name triggers by uuid.
if triggerName == "" {
@@ -166,6 +169,7 @@ func htCreate(c *cli.Context) error {
Method: getMethod(method),
FunctionReference: *functionRef,
CreateIngress: createIngress,
IngressConfig: *ingressConfig,
},
}
@@ -264,6 +268,12 @@ func htUpdate(c *cli.Context) error {
if c.IsSet("host") {
ht.Spec.Host = c.String("host")
log.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
}
if c.IsSet("ingressrule") || c.IsSet("ingressannotation") {
_, err = httptrigger.GetIngressConfig(c.StringSlice("ingressannotation"), c.String("ingressrule"), ht.Spec.RelativeURL, &ht.Spec.IngressConfig)
util.CheckErr(err, "parse ingress configuration")
}
_, err = client.HTTPTriggerUpdate(ht)