0

我目前正在玩 knative,并使用 gloo 和 glooctl 引导了一个简单的安装。开箱即用,一切正常。但是,我只是问自己是否有可能更改生成的 url,该服务在哪里可用。

我已经更改了域,但我想知道是否可以选择一个不包含命名空间的域名,所以helloworld-go.namespace.mydomain.com会变成helloworld-go.mydomain.com.

当前的 YAML 定义如下所示:

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  labels:
  name: helloworld-go
  namespace: default
spec:
  template:
    spec:
      containers:
      - image: gcr.io/knative-samples/helloworld-go
        env:
        - name: TARGET
          value: Go Sample v1

感谢您的帮助!

4

2 回答 2

3

这可以通过ConfigMap命名config-network空间中的命名进行配置knative-serving请参阅部署资源中的 ConfigMap :

apiVersion: v1
data:
  _example: |
    ...
    # domainTemplate specifies the golang text template string to use
    # when constructing the Knative service's DNS name. The default
    # value is "{{.Name}}.{{.Namespace}}.{{.Domain}}". And those three
    # values (Name, Namespace, Domain) are the only variables defined.
    #
    # Changing this value might be necessary when the extra levels in
    # the domain name generated is problematic for wildcard certificates
    # that only support a single level of domain name added to the
    # certificate's domain. In those cases you might consider using a value
    # of "{{.Name}}-{{.Namespace}}.{{.Domain}}", or removing the Namespace
    # entirely from the template. When choosing a new value be thoughtful
    # of the potential for conflicts - for example, when users choose to use
    # characters such as `-` in their service, or namespace, names.
    # {{.Annotations}} can be used for any customization in the go template if needed.
    # We strongly recommend keeping namespace part of the template to avoid domain name clashes
    # Example '{{.Name}}-{{.Namespace}}.{{ index .Annotations "sub"}}.{{.Domain}}'
    # and you have an annotation {"sub":"foo"}, then the generated template would be {Name}-{Namespace}.foo.{Domain}
    domainTemplate: "{{.Name}}.{{.Namespace}}.{{.Domain}}"
    ...
kind: ConfigMap
metadata:
  labels:
    serving.knative.dev/release: "v0.8.0"
  name: config-network
  namespace: knative-serving

因此,您config-network应该如下所示:

apiVersion: v1
data:
  domainTemplate: {{ '"{{.Name}}.{{.Domain}}"' }}
kind: ConfigMap
metadata:
  name: config-network
  namespace: knative-serving

您还可以查看并自定义config-domain以配置附加到您的服务的域名。

于 2019-09-25T22:57:29.700 回答
0

假设您在 istio 服务网格上运行 knative,在knative 文档Virtual Service中有一个如何使用 Istio在服务级别完成此操作的示例。

于 2021-08-15T00:57:24.887 回答