Изменение публичного URL в определении родного сервиса - PullRequest
0 голосов
/ 25 сентября 2019

В настоящее время я играю с 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

Спасибо за вашу помощь!

1 Ответ

2 голосов
/ 26 сентября 2019

Это настраивается через 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 для настройки доменного имени, которое добавляется к вашим услугам.

...