{"id":4083,"date":"2025-02-25T16:18:08","date_gmt":"2025-02-25T16:18:08","guid":{"rendered":"https:\/\/code2deploy.com\/blog\/?p=4083"},"modified":"2025-02-21T16:20:31","modified_gmt":"2025-02-21T16:20:31","slug":"exposing-a-kubernetes-service-using-a-custom-domain","status":"publish","type":"post","link":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/","title":{"rendered":"Exposing a Kubernetes Service Using a Custom Domain"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Scenario<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You have a Kubernetes service and want to expose it using a custom domain (e.g., <code>myapp.example.com<\/code>). This requires configuring an Ingress controller and setting up DNS properly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution: Using Ingress with a Custom Domain<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">An Ingress resource allows HTTP and HTTPS traffic routing to your services based on defined rules.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example: NGINX Ingress<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: my-app-ingress\n  annotations:\n    nginx.ingress.kubernetes.io\/rewrite-target: \/\nspec:\n  rules:\n    - host: myapp.example.com\n      http:\n        paths:\n          - path: \/\n            pathType: Prefix\n            backend:\n              service:\n                name: my-app\n                port:\n                  number: 80<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Steps to Configure:<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Deploy an Ingress Controller<\/strong> (e.g., NGINX, Traefik, HAProxy).<\/li>\n\n\n\n<li><strong>Create an Ingress Resource<\/strong> (as shown above).<\/li>\n\n\n\n<li><strong>Configure DNS<\/strong>: Add an A record pointing <code>myapp.example.com<\/code> to your cluster&#8217;s external IP.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Alternative Solutions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Using Traefik<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: my-app-ingress\n  annotations:\n    traefik.ingress.kubernetes.io\/router.entrypoints: web\nspec:\n  rules:\n    - host: myapp.example.com\n      http:\n        paths:\n          - path: \/\n            pathType: Prefix\n            backend:\n              service:\n                name: my-app\n                port:\n                  number: 80<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Using HAProxy Ingress<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>apiVersion: networking.k8s.io\/v1\nkind: Ingress\nmetadata:\n  name: my-app-ingress\nspec:\n  rules:\n    - host: myapp.example.com\n      http:\n        paths:\n          - path: \/\n            pathType: Prefix\n            backend:\n              service:\n                name: my-app\n                port:\n                  number: 80<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Using an Ingress controller is an effective way to expose services with a custom domain in Kubernetes. Choosing between NGINX, Traefik, or HAProxy depends on your specific needs, such as ease of configuration, performance, and feature set.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scenario You have a Kubernetes service and want to expose it using a custom domain (e.g., myapp.example.com). This requires configuring an Ingress controller and setting up DNS properly. Solution: Using Ingress with a Custom Domain An Ingress resource allows HTTP and HTTPS traffic routing to your services based on defined rules. Example: NGINX Ingress Steps [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,216],"tags":[543,541,10,19,542],"class_list":["post-4083","post","type-post","status-publish","format-standard","hentry","category-kubernetes","category-kubernetes-basic","tag-haproxy","tag-ingress","tag-kubernetes","tag-nginx","tag-traefik"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com\" \/>\n<meta property=\"og:description\" content=\"Scenario You have a Kubernetes service and want to expose it using a custom domain (e.g., myapp.example.com). This requires configuring an Ingress controller and setting up DNS properly. Solution: Using Ingress with a Custom Domain An Ingress resource allows HTTP and HTTPS traffic routing to your services based on defined rules. Example: NGINX Ingress Steps [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/\" \/>\n<meta property=\"og:site_name\" content=\"code2deploy.com\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-25T16:18:08+00:00\" \/>\n<meta name=\"author\" content=\"enam\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"enam\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/\"},\"author\":{\"name\":\"enam\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"headline\":\"Exposing a Kubernetes Service Using a Custom Domain\",\"datePublished\":\"2025-02-25T16:18:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/\"},\"wordCount\":138,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"keywords\":[\"HAProxy\",\"Ingress\",\"kubernetes\",\"Nginx\",\"Traefik\"],\"articleSection\":[\"Kubernetes\",\"Kubernetes Basic\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/\",\"name\":\"Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\"},\"datePublished\":\"2025-02-25T16:18:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/exposing-a-kubernetes-service-using-a-custom-domain\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exposing a Kubernetes Service Using a Custom Domain\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/\",\"name\":\"code2deploy.com\\\/blog\",\"description\":\"TechOps\",\"publisher\":{\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/#\\\/schema\\\/person\\\/e46930c19b999a87f12566fa8357481b\",\"name\":\"enam\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\",\"caption\":\"enam\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/code2deploy.com\\\/blog\"],\"url\":\"https:\\\/\\\/code2deploy.com\\\/blog\\\/author\\\/enam\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/","og_locale":"en_US","og_type":"article","og_title":"Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com","og_description":"Scenario You have a Kubernetes service and want to expose it using a custom domain (e.g., myapp.example.com). This requires configuring an Ingress controller and setting up DNS properly. Solution: Using Ingress with a Custom Domain An Ingress resource allows HTTP and HTTPS traffic routing to your services based on defined rules. Example: NGINX Ingress Steps [&hellip;]","og_url":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/","og_site_name":"code2deploy.com","article_published_time":"2025-02-25T16:18:08+00:00","author":"enam","twitter_card":"summary_large_image","twitter_misc":{"Written by":"enam","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/#article","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/"},"author":{"name":"enam","@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"headline":"Exposing a Kubernetes Service Using a Custom Domain","datePublished":"2025-02-25T16:18:08+00:00","mainEntityOfPage":{"@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/"},"wordCount":138,"commentCount":0,"publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"keywords":["HAProxy","Ingress","kubernetes","Nginx","Traefik"],"articleSection":["Kubernetes","Kubernetes Basic"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/","url":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/","name":"Exposing a Kubernetes Service Using a Custom Domain - code2deploy.com","isPartOf":{"@id":"https:\/\/code2deploy.com\/blog\/#website"},"datePublished":"2025-02-25T16:18:08+00:00","breadcrumb":{"@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/code2deploy.com\/blog\/exposing-a-kubernetes-service-using-a-custom-domain\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/code2deploy.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Exposing a Kubernetes Service Using a Custom Domain"}]},{"@type":"WebSite","@id":"https:\/\/code2deploy.com\/blog\/#website","url":"https:\/\/code2deploy.com\/blog\/","name":"code2deploy.com\/blog","description":"TechOps","publisher":{"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/code2deploy.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/code2deploy.com\/blog\/#\/schema\/person\/e46930c19b999a87f12566fa8357481b","name":"enam","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g","caption":"enam"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d864e2f082f4499f8f1b33f004ec166eea77b9e94738553b120b6dca2410f203?s=96&d=mm&r=g"},"sameAs":["https:\/\/code2deploy.com\/blog"],"url":"https:\/\/code2deploy.com\/blog\/author\/enam\/"}]}},"_links":{"self":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4083","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/comments?post=4083"}],"version-history":[{"count":1,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4083\/revisions"}],"predecessor-version":[{"id":4084,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/posts\/4083\/revisions\/4084"}],"wp:attachment":[{"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/media?parent=4083"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/categories?post=4083"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code2deploy.com\/blog\/wp-json\/wp\/v2\/tags?post=4083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}