<p>Say, the pod has one container which hosts a webserver serving static page on port 80.</p>

<p>When creating the pod, how to set a subdomain <code>x.example.com</code> to a pod? Is a service necessary here?</p>

<p>What role does kube-dns play here?</p>

<p>I don't want to do a use nodePort binding. The pod should be accessible to the public via <code>x.example.com</code>. Is it possible to access it at <code>example.com</code> with query param as CIDR?</p>

<p>Assuming you aren't deploying to a cloud environment, you would use an <a href="https://kubernetes.io/docs/user-guide/ingress/#ingress-controllers" rel="noreferrer">Ingress Controller</a>
Deploy an ingress controller as a standard pod, with a service that uses NodePort or HostPort.</p>

<p>Once you've deployed your ingress controller, you can add an Ingress resource.</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
spec:
  rules:
  - host: x.example.com
    http:
      paths:
      - path: /
        backend:
          serviceName: web-app-service
          servicePort: 80
</code></pre>

<p>Point DNS to the host your ingress controller pod was scheduled on, and you can access the pod on x.example.com</p>

<p>If you're deploying to GKE or AWS etc, you can use a L<a href="https://kubernetes.io/docs/user-guide/load-balancer/" rel="noreferrer">oad Balancer resource</a></p>
