<p>I am having difficulties accessing a NodePort service on my Kubernetes cluster.</p>

<p><strong>Goal</strong></p>

<p>set up ALB Ingress controller so that i can use websockets and http/2</p>

<p>setup NodePort service as required by that controller</p>

<p><strong>Steps taken</strong></p>

<p>Previously a Kops (Version 1.6.2) cluster was created on AWS eu-west-1. The kops addons for nginx ingress was added as well as Kube-lego. ELB ingress working fine.</p>

<p>Setup the ALB Ingress Controller with custom AWS keys using IAM profile specified by that project.</p>

<p>Changed service type from LoadBalancer to NodePort using kubectl replace --force</p>

<pre><code>&gt; kubectl describe svc my-nodeport-service
Name:                   my-node-port-service
Namespace:              default
Labels:                 &lt;none&gt;
Selector:               service=my-selector
Type:                   NodePort
IP:                     100.71.211.249
Port:                   &lt;unset&gt; 80/TCP
NodePort:               &lt;unset&gt; 30176/TCP
Endpoints:              100.96.2.11:3000
Session Affinity:       None
Events:                 &lt;none&gt;

&gt; kubectl describe pods my-nodeport-pod
Name:           my-nodeport-pod
Node:           &lt;ip&gt;.eu-west-1.compute.internal/&lt;ip&gt;
Labels:         service=my-selector
Status:         Running
IP:             100.96.2.11
Containers:
  update-center:
    Port:               3000/TCP
    Ready:              True
    Restart Count:      0

(ssh into node)
$ sudo netstat -nap | grep 30176
tcp6       0      0 :::30176                :::*                    LISTEN      2093/kube-proxy
</code></pre>

<p><strong>Results</strong></p>

<p>Curl from ALB hangs</p>

<p>Curl from <code>&lt;public ip address of all nodes&gt;:&lt;node port for service&gt;</code> hangs</p>

<p><strong>Expected</strong></p>

<p>Curl from both ALB and directly to the node:node-port should return 200 "Ok" (the service's http response to the root)</p>

<p>Update:
Issues created on github referencing above with some further details in some cases:</p>

<ul>
<li><a href="https://github.com/kubernetes/kubernetes/issues/50261" rel="noreferrer">https://github.com/kubernetes/kubernetes/issues/50261</a></li>
<li><a href="https://github.com/coreos/alb-ingress-controller/issues/169" rel="noreferrer">https://github.com/coreos/alb-ingress-controller/issues/169</a></li>
<li><a href="https://github.com/kubernetes/kops/issues/3146" rel="noreferrer">https://github.com/kubernetes/kops/issues/3146</a></li>
</ul>

<p>By default Kops does not configure the EC2 instances to allows NodePort traffic from outside.</p>

<p>In order for traffic outside of the cluster to reach the NodePort you must edit the configuration for your EC2 instances that are your Kubernetes nodes in the EC2 Console on AWS. </p>

<p>Once in the EC2 console click "Security groups." Kops should have annotated the original Security groups that it made for your cluster as <code>nodes.&lt;your cluster name&gt;</code> and <code>master.&lt;your cluster name&gt;</code></p>

<p>We need to modify these Security Groups to forward traffic from the default port range for NodePorts to the instances.</p>

<p>Click on the security group, click on rules and add the following rule. </p>

<p><strong>Port range to open on the nodes and master</strong>: 30000-32767</p>

<p><a href="https://i.stack.imgur.com/LNUpr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LNUpr.png" alt="security group rule"></a></p>

<p>This will allow anyone on the internet to access a NodePort on your cluster, so make sure you want these exposed.</p>

<p>Alternatively instead of allowing it from any origin you can allow it only from the security group created by for the ALB by the alb-ingress-controller. However, since these can be re-created it will likely be necessary to modify the rule on modifications to the kubernetes service. I suggest specifying the NodePort explicitly to it is a predetermined known NodePort rather than a randomly assigned one.</p>
