<p>I am new at google kubernetes engine. So I am createing a new cluster. And deploying a sample application on this cluster. And I can access it using an ip address like <code>30.31.32.33/api</code>
So I want to use my domain name (<code>mydomain.com or subdomain products.mydomain.com</code>) for this app</p>
<ol>
<li>Should I set nameserver of domain to ip address <code>30.31.32.33/api</code> . Dose this ip address change if recreate the cluster?</li>
<li>If I want publish a new app on same cluster with different domain, what can I do?</li>
</ol>

barteloma
<p><strong>Ingress example</strong> for mutople hosts</p>
<pre><code>---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-x-host
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: x.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: x
            port:
              number: 80
  - host: y.example.com
    http:
      paths:
      - pathType: Prefix
        path: /
        backend:
          service:
            name: y
            port:
              number: 80
</code></pre>
<blockquote>
<p>Should I set nameserver of domain to ip address 30.31.32.33/api . Dose
this ip address change if recreate the cluster?</p>
</blockquote>
<p>Not sure how you got that <strong>IP</strong>, if you are using the <strong>LoadBalancer</strong> service it's fine you can use it that way. But will work for a single service or I can say deployment. In another word if you have a single application running this approach is fine.</p>
<p>Yes, I get a change if you <strong>recreate</strong> the <strong>service</strong> but you can use <strong>static IP</strong> also.</p>
<blockquote>
<p>If I want publish a new app on same cluster with a different domain,
what can I do?</p>
</blockquote>
<p>You have to use the <strong>Ingress</strong> object of Kubernetes and <strong>ingress</strong> <strong>controller</strong> to manage the multiple application and expose all those with the different Host name.</p>
<p>Ingress will save your configuration about <strong>host</strong> and <strong>routing</strong>, while the controller will manage <strong>ingress rules</strong>. Once you will install the controller it will give you the same IP that will create the <strong>service type :</strong> <strong>LoadBalancer</strong>. you can map this <strong>IP</strong> to <strong>DNS</strong> with any domain/sub-domain.</p>
<p>There are many different <strong>ingress controllers</strong> available in the market based on usage you can choose any widely used <strong>Nginx ingress controller</strong>, you can also go with the <strong>GCE</strong> if the requirement to use <strong>HTTPS</strong> with <strong>managed SSL</strong> <strong>certificate</strong> from <strong>GCP</strong>.</p>
<p>Here you can refer the example for <strong>Nginx ingress controller</strong> : <a href="https://cloud.google.com/community/tutorials/nginx-ingress-gke" rel="nofollow noreferrer">https://cloud.google.com/community/tutorials/nginx-ingress-gke</a></p>
<p>What is ingress and Read more about it : <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/ingress/#what-is-ingress</a></p>
<p>You can also follow this approach without using the <strong>Ingress controller</strong> and have details about <strong>HTTPS</strong> certs etc : <a href="https://k8scale-io.medium.com/hosting-multiple-domains-in-gke-ingress-9f8cc61df2ad" rel="nofollow noreferrer">https://k8scale-io.medium.com/hosting-multiple-domains-in-gke-ingress-9f8cc61df2ad</a></p>
