<p>I'm trying to learn Kubernetes fundamentals, and although I've played around with <code>kubectl</code> and <code>minikube</code> locally, I'd like to expose the basic nginx docker image, over the internet, on a domain I have access to (for this example, <code>nginx.mydomain.com</code>), using DigitalOcean managed Kubernetes. My stumbling point seems to be all-networking related (services and ingress controllers).</p>
<p>However, I'd also like to avoid having to spin up tons of cloud resources, and without use too many dependencies to abstract the problem away from me—so no LoadBalancers or Helm please. Right now, the majority of the answers I've seen for problems like this either solve the problem by invoking these two pieces of tooling.</p>
<p>Here's my <code>nginx.deployment.yaml</code> file:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  strategy:
    rollingUpdate:
      maxSurge: 1
  replicas: 1
  selector:
    matchLabels:
      app: nginx-deployment
  template:
    metadata:
      labels:
        app: nginx-deployment
    spec:
      containers:
        - name: nginx-app
          image: nginx
          ports:
            - containerPort: 80
</code></pre>
<p>I apply this to my cluster: <code>kubectl apply -f k8s/nginx.deployment.yaml</code>. My understanding is that is creates an <code>nginx</code> container, in a pod, able to accept connections on port 80 (ideal for nginx). I also expose my pod using a <code>NodePort</code> service:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl expose deployment nginx-deployment --port=8080 --type=NodePort --name=nginx-service
</code></pre>
<p>From here, I also create an nginx Ingress controller, and apply that via <code>kubectl</code> also:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: testing-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: nginx.mydomain.com
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: nginx-service
                port:
                  number: 8080
</code></pre>
<p>I can confirm this ran, but for some reason, the <code>address</code> field is blank? I take it this shouldn't be the case?</p>
<pre class="lang-sh prettyprint-override"><code>~ % kubectl get ingress
NAME              CLASS    HOSTS                         ADDRESS   PORTS   AGE
testing-ingress   &lt;none&gt;   nginx.mydomain.com                      80      83m
</code></pre>
<p>Given I have then added an A DNS record to bind <code>nginx.mydomain.com</code> to the DigitalOcean droplet running my node in my cluster, shouldn't I be able to access <code>nginx.mydomain.com</code> on port 80 and see the nginx welcome page? Right now, I simply get connection refused:</p>
<pre class="lang-sh prettyprint-override"><code>curl http://nginx.mydomain.com
curl: (7) Failed to connect to http://nginx.mydomain.com port 80: Connection refused
</code></pre>
<p>What am I missing here?</p>

marked-down
<p>i am not sure which <strong>IP</strong> address you have added in your <strong>DNS</strong> to resolve your domain address.</p>
<p>the idea flow for ingress gose something like :</p>
<pre><code>internet traffic &gt; ingress &gt; ingress controller &gt; service &gt; deployment &gt; Pod
</code></pre>
<p>respective ingress controller is required to run &amp; manage the <strong>ingress</strong> object.</p>
<p>When you set up the ingress controller it will create the service with <strong>LoadBalancer</strong> type and provide you one external IP.</p>
<p>you can add this external IP into DNS as <strong>A</strong> record and after that, you can create the ingress for a specific domain.</p>
<p>For example, you have added a record in <strong>DNS</strong> :</p>
<pre><code>*.beta.example.com A 30 TTL 192.168.1.52(whatever your loadbalancer IP)
</code></pre>
<p>DNS will divert all the traffic to the ingress controller and the ingress controller will check the ingress object configuration redirect traffic to specific <strong>Kubernetes</strong> service.</p>
<p>you will might also require in future to use the cert-manager for managing the SSL/TLS certificates please refer this nice blog post from digital ocean for setting up <strong>Nginx controller</strong>: <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes" rel="nofollow noreferrer">https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nginx-ingress-with-cert-manager-on-digitalocean-kubernetes</a></p>
<p><strong>OR</strong></p>
<p>Still, if you are looking forward with not running LoadBalancer and all</p>
<p>it's possible to run Nginx ingress controller without LoadBalancer however personally I would not suggest it.</p>
<p>you can follow this : <a href="https://stackoverflow.com/a/43190775/5525824">https://stackoverflow.com/a/43190775/5525824</a></p>
<p><strong>Note</strong> : in any case, you require to install the <strong>ingress controller</strong> and use it. with <strong>NodePort</strong> issue is that you have to use the <strong>External</strong> <strong>IP</strong> of <strong>Node (VM)</strong>, now during the scale down or scaling up if <strong>node</strong> get crashed your IP won't work and traffic to the cluster gets stop.</p>
