<p>I have a kubernetes setup with the configuration like below:</p>
<p>I am using this mandatory file:</p>
<p><a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.26.1/deploy/static/mandatory.yaml" rel="nofollow noreferrer">https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.26.1/deploy/static/mandatory.yaml</a>
<a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.26.1/deploy/static/provider/cloud-generic.yaml" rel="nofollow noreferrer">https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.26.1/deploy/static/provider/cloud-generic.yaml</a></p>
<p>My ingress:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: api-ingress
  annotations:
    kubernetes.io/ingress.class: &quot;nginx&quot;
    cert-manager.io/cluster-issuer: &quot;letsencrypt-prod&quot;
spec:
  tls:
    - hosts:
      - api.service.com
      secretName: api-tls
  rules:
  - host: api.service.com
    http:
      paths:
      - backend:
          serviceName: api-service
          servicePort: 80
</code></pre>
<p>My service:</p>
<pre class="lang-yaml prettyprint-override"><code>#########################################################
# Service for API Gateway service
#########################################################
apiVersion: v1
kind: Service
metadata:
  name: api-service
  labels:
    name: api
spec:
  selector:
    app: api
  ports:
  - name: http
    port: 80
    targetPort: 3000
    nodePort: 30000
    protocol: TCP
  - name: https
    port: 443
    targetPort: 3000
    nodePort: 30001
    protocol: TCP
  type: NodePort
  sessionAffinity: ClientIP
</code></pre>
<p>My deployment:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: api
  name: api
spec:
  replicas: 1
  selector:
    matchLabels:
      name: api
  template:
    metadata:
      labels:
        name: api
        app: api
    spec:
      containers:
      - env:
        - name: CACHER
          value: redis://redis:6379
        - name: LOGLEVEL
          value: info
        - name: NAMESPACE
          value: myName
        - name: PORT
          value: &quot;3000&quot;
        - name: SERVICEDIR
          value: services
        - name: SERVICES
          value: api
        - name: TRANSPORTER
          value: nats://nats:4222
        ports:
          - containerPort: 3000
        image: registry.digitalocean.com/my-registry/my-image:latest
        imagePullPolicy: &quot;&quot;
        name: api
        resources: {}
      imagePullSecrets:
      - name: my-registry
      restartPolicy: Always
      serviceAccountName: &quot;&quot;
      volumes: null
      
status: {}
</code></pre>
<p>If I use Service NodePort with port 30001 and its own IP, I don't have any problem, but with LoadBalancer always throws a 502 Bad gateway.</p>
<p>Any idea?</p>
<p>Thanks!</p>

Marcela Romero
<p>Please, avoid using these files manually. This file seems outdated too. Use helm if you don't like surprises. Because these are managed services.</p>
<p>First, install Helm on your laptop. Then log in to your Digitalocean in the command panel. Delete existing Nginx ingress implementations. Then run these commands one by one.</p>
<p>At first add the ingress controller to the default namespace</p>
<pre class="lang-sh prettyprint-override"><code>helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
</code></pre>
<p>Then update the helm repo</p>
<pre class="lang-sh prettyprint-override"><code>helm repo update
</code></pre>
<p>Then finally run this command</p>
<pre class="lang-sh prettyprint-override"><code>helm install nginx-ingress ingress-nginx/ingress-nginx --set controller.publishService.enabled=true
</code></pre>
<p>To check the installation run this command</p>
<pre class="lang-sh prettyprint-override"><code>kubectl --namespace default get services -o wide -w nginx-ingress-ingress-nginx-controller

</code></pre>
<p>There is also a digital ocean recommended approach. You can use Digital Ocean Marketplace to install Nginx-Ingress too. Digitalocean will then automatically run these aforementioned commands for you! If you check their Github account, you will find that they are also using helm for their marketplace services. It's time to adopt Helm.</p>
