问题描述
我已遵循本指南 https://knative.dev/docs/serving/using-a-custom-domain/ .
使用命令
kubectl edit cm config-domain --namespace knative-serving
我将 yaml 文件中的 example.com 替换为 mydomain.com。我确实删除了 _example 措辞,但不确定是否删除了正确的语法。
保存后,yaml似乎有很多变化。
但是当我部署 knative 服务时,域 url 仍在使用 example.com。
这是当前的 yaml 内容:
# Please edit the object below. Lines beginning with a '#' will be ignored,# and an empty file will abort the edit. If an error occurs while saving this file will be
# reopened with the relevant failures.
#
apiVersion: v1
data:
mydomain.com: |
selector:
app: nonprofit
svc.cluster.local: |
selector:
app: secret
kind: ConfigMap
Metadata:
annotations:
knative.dev/example-checksum: 74c3fc6a
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","data":{"_example":"################################\n# #\n# EXAMPLE CONfigURATION #\n# #\n################################\n\n# This block is not actually functional configuration,\n# but serves to illustrate the available configuration\n# options and document them in a way that is accessible\n# to users that `kubectl edit` this config map.\n#\n# These sample configuration options may be copied out of\n# this example block and unindented to be in the data block\n# to actually change the configuration.\n\n# Default value for domain.\n# Although it will match all routes,it is the least-specific rule so it\n# will only be used if no other domain matches.\nmydomain.com: |\n\n# These are example settings of domain.\n# example.org will be used for routes having app=nonprofit.\nexample.org: |\n selector:\n app: nonprofit\n\n# Routes having the cluster domain suffix (by default 'svc.cluster.local')\n# will not be exposed through Ingress. You can define your own label\n# selector to assign that domain suffix to your Route here,or you can set\n# the label\n# \"serving.knative.dev/visibility=cluster-local\"\n# to achieve the same effect. This shows how to make routes having\n# the label app=secret only exposed to the local cluster.\nsvc.cluster.local: |\n selector:\n app: secret\n"},"kind":"ConfigMap","Metadata":{"annotations":{"knative.dev/example-checksum":"74c3fc6a"},"labels":{"serving.knative.dev/release":"v0.22.0"},"name":"config-domain","namespace":"knative-serving"}}
creationTimestamp: "2021-05-11T06:43:42Z"
labels:
serving.knative.dev/release: v0.22.0
managedFields:
- apiVersion: v1
fieldsType: FieldsV1
fieldsV1:
f:data:
.: {}
f:mydomain.com: {}
f:svc.cluster.local: {}
f:Metadata:
f:annotations:
.: {}
f:knative.dev/example-checksum: {}
f:kubectl.kubernetes.io/last-applied-configuration: {}
f:labels:
.: {}
f:serving.knative.dev/release: {}
manager: kubectl.exe
operation: Update
time: "2021-05-20T02:15:57Z"
name: config-domain
namespace: knative-serving
resourceVersion: "18217995"
selfLink: /api/v1/namespaces/knative-serving/configmaps/config-domain
uid: 8fe4aac5-0413-45c5-8d3e-f7b9ff4e32ed
解决方法
您部署的服务是否具有匹配的标签?就像这样:
metadata:
labels:
app: non-prod
或
metadata:
labels:
app: secret
至于 yaml 的许多更改,有一些自动生成的字段,例如装饰 k8s 资源的 managedFields。 https://kubernetes.io/docs/reference/using-api/server-side-apply/
,确保在编辑配置映射时不要编辑注释,而是移动缩进
我建议不要更改 example.com,而是添加带有键和字段的新行。
我强烈建议像这样使用 CLI 进行编辑
导出 KNATIVE_DOMAIN=konk.dev kubectl patch configmap -n knative-serving config-domain -p "{"data": {"$KNATIVE_DOMAIN": ""}}"
您可以在 https://konk.dev
中查看本教程中如何使用它