<p>I'm trying to access .NET Web API which I docker-ized and mounted in an Kubernet Cluster on Microsoft Azure.</p>

<p>The application works fine on local docker machine.
The cluster is running, my deployment was correct and the pods where created. Everything I check is fine, but I cannot access my application through the external cluster IP (Load Balancer). This is my YAML deployment file:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ohmioapi-deployment
spec:
  selector:
    matchLabels:
      app: ohmioapi
  replicas: 1
  template:
    metadata:
      labels:
        app: ohmioapi
    spec:
      containers:
      - name: ohmioapi
        image: ohmiocontainers.azurecr.io/ohmioapi:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 15200
      imagePullSecrets:
        - name: acr-auth
---
apiVersion: v1
kind: Service
metadata:
  name: ohmioapi
  labels:
    app: ohmioapi
spec:
  selector:
    app: ohmioapi
  ports:
  - port: 15200
    nodePort: 30200
    protocol: TCP
  type: LoadBalancer
</code></pre>

<p>Can anyone give a hint of where to start looking for?
Thanks!</p>

ericpap
<p>I would give the deployment/pods port a name (e.g. <code>http</code>) and then make the service serve off port 80 but target the pod port by name... that way you don't have to worry about port numbers when connecting to a service.</p>

<p>Also, you shouldn't need or want to use <code>nodePort</code> if you are using type of <code>LoadBalancer</code>.</p>

<p>E.g.</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: ohmioapi-deployment
spec:
  selector:
    matchLabels:
      app: ohmioapi
  replicas: 1
  template:
    metadata:
      labels:
        app: ohmioapi
    spec:
      containers:
      - name: ohmioapi
        image: ohmiocontainers.azurecr.io/ohmioapi:latest
        imagePullPolicy: Always
        ports:
        - name: http
          containerPort: 15200
      imagePullSecrets:
        - name: acr-auth

---
apiVersion: v1
kind: Service
metadata:
  name: ohmioapi
  labels:
    app: ohmioapi
spec:
  selector:
    app: ohmioapi
  ports:
  - name: http
    port: 80
    targetPort: http
    protocol: TCP
  type: LoadBalancer
</code></pre>
