Setting up a custom domain
To change the {default-domain} value there are a few steps involved:
Edit the domain configuration config-map to replace
example.com
with your own domain, for examplemydomain.com
:This command opens your default text editor and allows you to edit the config map.
apiVersion: v1
data:
_example: |
################################
# EXAMPLE CONFIGURATION #
# #
################################
# ...
example.com: |
Edit the file to replace
example.com
with the domain you’d like to use, remove the_example
key and save your changes. In this example, we configuremydomain.com
for all routes:apiVersion: v1
data:
mydomain.com: ""
kind: ConfigMap
[...]
Apply from a file
You can also apply an updated domain configuration:
Create a new file,
config-domain.yaml
and paste the following text, replacing theexample.org
andexample.com
values with the new domain you want to use:
Deploy an app (for example, helloworld-go
), to your cluster as normal. You can retrieve the URL in Knative Route “helloworld-go” with the following command:
You should see the full customized domain: helloworld-go.default.mydomain.com
.
And you can check the IP address of your Knative gateway by running:
Local DNS setup
You can map the domain to the IP address of your Knative gateway in your local machine with:
INGRESSGATEWAY=istio-ingressgateway
export GATEWAY_IP=`kubectl get svc $INGRESSGATEWAY --namespace istio-system --output jsonpath="{.status.loadBalancer.ingress[*]['ip']}"`
# helloworld-go is the generated Knative Route of "helloworld-go" sample.
# You need to replace it with your own Route in your project.
export DOMAIN_NAME=`kubectl get route helloworld-go --output jsonpath="{.status.url}" | cut -d'/' -f 3`
# Add the record of Gateway IP and domain name into file "/etc/hosts"
echo -e "$GATEWAY_IP\t$DOMAIN_NAME" | sudo tee -a /etc/hosts
You can now access your domain from the browser in your machine and do some quick checks.
Follow these steps to make your domain publicly accessible:
You might want to set a static IP for your Knative gateway, so that the gateway IP does not change each time your cluster is restarted.
Update your DNS records
Create a wildcard record for the namespace and custom domain to the ingress IP Address, which would enable hostnames for multiple services in the same namespace to work without creating additional DNS entries.
Create an A record to point from the fully qualified domain name to the IP address of your Knative gateway. This step needs to be done for each Knative Service or Route created.
If you are using Google Cloud DNS, you can find step-by-step instructions in the .
Once the domain update has propagated, you can access your app using the fully qualified domain name of the deployed route, for example http://helloworld-go.default.mydomain.com
Feedback
Was this page helpful?
Glad to hear it! Please .
Sorry to hear that. Please tell us how we can improve.