{"id":32946,"date":"2023-03-02T08:54:48","date_gmt":"2023-03-02T08:54:48","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32946"},"modified":"2025-01-13T12:15:24","modified_gmt":"2025-01-13T12:15:24","slug":"knative-serving-api-resources-domainmapping","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/knative-serving-api-resources-domainmapping\/","title":{"rendered":"KNative Serving API Resources: Domainmapping"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"488\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/03\/image-2-1024x488.png\" alt=\"\" class=\"wp-image-32947\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/03\/image-2-1024x488.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/03\/image-2-300x143.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/03\/image-2-768x366.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2023\/03\/image-2.png 1278w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>native Domain Mapping is a feature of Knative that allows you to map custom domains to Knative Services. With Domain Mapping, you can use your own domain name, such as example.com, to access a Knative Service, rather than the default domain name provided by Knative, such as example.default.example.com.<\/p>\n\n\n\n<p>To use Domain Mapping, you need to have a custom domain name that you control, such as example.com. You can then create a Domain Mapping in Knative that maps your custom domain name to a Knative Service. Once you have created the Domain Mapping, you can access your Knative Service using your custom domain name.<\/p>\n\n\n\n<p>Domain Mapping in Knative works by creating a Kubernetes Ingress resource that routes traffic from your custom domain name to the Knative Service. The Ingress resource uses the Istio Gateway service to route traffic to the appropriate Knative Service based on the domain name.<\/p>\n\n\n\n<p>To create a Domain Mapping in Knative, you can use the <code>kubectl<\/code> command line tool to create a Kubernetes Ingress resource with the appropriate annotations. For example:<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">apiVersion: networking.k8s.io\/v1beta1\r\nkind: Ingress\r\nmetadata:\r\n  name: example-domain-mapping\r\n  annotations:\r\n    kubernetes.io\/ingress.class: istio\r\n    networking.knative.dev\/ingress.class: istio\r\nspec:\r\n  rules:\r\n  - host: example.com\r\n    http:\r\n      paths:\r\n      - backend:\r\n          serviceName: my-knative-service\r\n          servicePort: 80\r\n<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>In this example, the Ingress resource maps the domain name <code>example.com<\/code> to the Knative Service named <code>my-knative-service<\/code>, which is running on port 80.<\/p>\n\n\n\n<p>Once you have created the Ingress resource, Knative will automatically create the necessary Istio Gateway and VirtualService resources to route traffic from your custom domain name to the Knative Service.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>native Domain Mapping is a feature of Knative that allows you to map custom domains to Knative Services. With Domain Mapping, you can use your own domain name, such as example.com, to access a Knative Service, rather than the default domain name provided by Knative, such as example.default.example.com. To use Domain Mapping, you need to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[8921],"tags":[],"class_list":["post-32946","post","type-post","status-publish","format-standard","hentry","category-knative"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32946","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32946"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32946\/revisions"}],"predecessor-version":[{"id":32948,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32946\/revisions\/32948"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32946"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32946"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32946"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}