<p>I am new to Kubernetes and I am currently deploying a cluster in AWS using Kubeadm. The containers are deployed just fine, but I can't seem to access them with by browser. When I used to do this via Docker Swarm I could simply use the IP address of the AWS node to access and login in my application with by browser, but this does not seem to work with my current Kubernetes setting.</p>

<p>Therefore my question is how can I access my running application under these new settings?</p>

João Matos
<p>Both answers were helpful in my pursuit for a solution to my problem, but I ended up getting lost in the details. Here is an example that may help others with a similar situation:</p>

<p>1) Consider the following application yaml:</p>

<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: my-web-app
  labels:
    app: my-web-app
spec:
  serviceName: my-web-app
  replicas: 1
  selector:
    matchLabels:
      app: my-web-app
  template:
    metadata:
      labels:
        app: my-web-app
    spec:
      containers:
      - name: my-web-app
        image: myregistry:443/mydomain/my-web-app
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
          name: cp
</code></pre>

<p>2) I decided to adopt Node Port (thank you @Leandro for pointing it out) to expose my service, hence I added the following to my application yaml:</p>

<pre><code>---
apiVersion: v1
kind: Service
metadata:
  name: my-web-app
  labels:
    name: my-web-app
spec:
  type: NodePort
  ports:
    - name: http1
      port: 80
      nodePort: 30036
      targetPort: 8080
      protocol: TCP
  selector:
     name: my-web-app
</code></pre>

<p>One thing that I was missing is that the label names in both sets must match in order to link <code>my-web-app:StatefulSet</code> (1) to <code>my-web-app:Service</code> (2). Then, <code>my-web-app:StatefulSet:containerPort</code> must be the same as <code>my-web-app:Service:targetPort</code> (8080). Finally, <code>my-web-app:Service:nodePort</code> is the port that we expose publicly and it must be a value between 30000-32767.</p>

<p>3) The last step is to ensure that the security group in AWS allows inbound traffic for the chosen <code>my-web-app:Service:nodePort</code>, in this case 30036, if not add the rule. </p>

<p>After following these steps I was able to access my application via <code>aws-node-ip:30036/my-web-app</code>.</p>
