0

我已遵循本指南https://knative.dev/docs/serving/using-a-custom-domain/

使用命令

kubectl edit cm config-domain --namespace knative-serving

我在 yaml 文件中用 mydomain.com 替换了 example.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

    
4

2 回答 2

1

您部署的服务是否具有匹配的标签?就像这样:

metadata:
  labels:
    app: non-prod

或者

metadata:
  labels:
    app: secret

就 yaml 的许多更改而言,有一些自动生成的字段,例如装饰 k8s 资源的 managedFields。 https://kubernetes.io/docs/reference/using-api/server-side-apply/

于 2021-05-20T09:58:39.930 回答
0

Be sure when you edit the config map you don’t edit the comments and instead move the indentation

I would recommend to not change example.com and instead add the new new line with key and field.

I would strongly recommend to edit with CLI like this

export KNATIVE_DOMAIN=konk.dev kubectl patch configmap -n knative-serving config-domain -p "{"data": {"$KNATIVE_DOMAIN": ""}}"

You can see how it is used in this tutorial at https://konk.dev

于 2021-05-20T11:38:12.420 回答