Bibin
Bibin

Reputation: 562

Linking a website or domain with AKS cluster

In Azure Kubernetes, the services or load balancer exposes IP Address to access a container's app. If one of the container has a web application, then it will be externally exposed as an IP like 115.111.0.145. Suppose I have a website www.example.com purchased from GoDaddy, then how can I link this domain with AKS cluster, so that the end user will be accessing the website by name and not IP?

Upvotes: 0

Views: 1213

Answers (2)

Tushar Mahajan
Tushar Mahajan

Reputation: 2160

You can take the DNS zone serivce of Microsoft azure in this case and can defines the set of canonical names for your site like -

  1. example.com can be tagged to 'A' type record i.e. the IP of your Nginx controller's service exposed to load balancer.

  2. Then you can create the multiple canonical names like - api.example.com and can map this to example.com as a CNAME type record in DNS zone.

This helps you direct the traffic from multiple domains to the cluster.

kubectl get svc shall give you the external IP for the nginx service and you can give that external IP in the A record of DNS zone.

Hope this helps !!

Upvotes: 1

Sahadat Hossain
Sahadat Hossain

Reputation: 4351

You can use Ingress. Ingress is an API object that manages external access to the services in a cluster, typically HTTP. An Ingress may be configured to give Services externally-reachable URLs, load balance traffic, terminate SSL / TLS, and offer name-based virtual hosting. You can see the offical kubernetes Ingress-doc for more details.

Here as an example a simple yaml manifest of ingress is given:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: simple-fanout-example
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - path: /foo
        pathType: Prefix
        backend:
          service:
            name: service1
            port:
              number: 4200
      - path: /bar
        pathType: Prefix
        backend:
          service:
            name: service2
            port:
              number: 8080

Upvotes: 3

Related Questions