首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将Knative服务的默认URL域从example.com更改为例如mydomain.com

如何将Knative服务的默认URL域从example.com更改为例如mydomain.com
EN

Stack Overflow用户
提问于 2021-05-20 17:27:58
回答 2查看 82关注 0票数 0

我一直在关注这个指南https://knative.dev/docs/serving/using-a-custom-domain/

使用命令

代码语言:javascript
复制
kubectl edit cm config-domain --namespace knative-serving

我在yaml文件中用mydomain.com替换了example.com。我确实删除了_example的措辞,但不确定是否删除了正确的语法。

在保存之后,yaml似乎有很多变化。

但是当我部署一个knative服务时,域url仍然使用example.com。

这是当前的yaml内容:

代码语言:javascript
复制
# 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
EN

回答 2

Stack Overflow用户

发布于 2021-05-20 17:58:40

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

代码语言:javascript
复制
metadata:
  labels:
    app: non-prod

代码语言:javascript
复制
metadata:
  labels:
    app: secret

到目前为止,yaml有许多变化,有一些自动生成的字段,例如装饰k8s资源的managedFields。https://kubernetes.io/docs/reference/using-api/server-side-apply/

票数 1
EN

Stack Overflow用户

发布于 2021-05-20 19:38:12

请确保在编辑配置映射时,不要编辑注释,而是移动缩进

我建议不要更改example.com,而是添加包含键和字段的新行。

我强烈建议使用CLI进行编辑,如下所示

导出KNATIVE_DOMAIN=konk.dev kubectl修补程序配置映射-n本地服务配置域数据“{”-p“:{"$KNATIVE_DOMAIN":""}}”

您可以在https://konk.dev上查看如何在本教程中使用它

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67617648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档