gpt4 book ai didi

kubernetes - 在 knative 服务定义中更改公共(public) url

转载 作者:行者123 更新时间:2023-12-02 11:56:39 25 4
gpt4 key购买 nike

我目前正在玩 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

感谢您的帮助!

最佳答案

这可以通过 ConfigMap 进行配置。命名为 config-network在命名空间 knative-serving .查看 deployment resources 中的 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配置附加到您的服务的域名。

关于kubernetes - 在 knative 服务定义中更改公共(public) url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58106188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com