Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid value for field 'namedPorts[*].port': '0' #75

Closed
stevenbarragan opened this issue Nov 9, 2017 · 8 comments
Closed

Invalid value for field 'namedPorts[*].port': '0' #75

stevenbarragan opened this issue Nov 9, 2017 · 8 comments

Comments

@stevenbarragan
Copy link

stevenbarragan commented Nov 9, 2017

I'm trying to create a new ingress controller but I'm getting this error:

googleapi: Error 400: Invalid value for field 'namedPorts[12].port': '0'. Must be greater than or equal to 1, invalid

Then I checked the other ingresses, they still work but I'm getting the same exact error. The new ingress does not work at all.

I found this answer but I have not port0 in my ports. I notice I have exactly 12 named ports in my instance group, and I'm guessing the array namedPorts is a zero-based so accessing the 12 element might be causing the issue.

I'm not exactly sure what triggered it, but I updated to 1.8.2 recently.

This is my ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.gcp.kubernetes.io/pre-shared-cert: certificate
    ingress.kubernetes.io/force-ssl-redirect: "true"
    kubernetes.io/ingress.allow-http: "false"
    kubernetes.io/ingress.global-static-ip-name: static-ip-name
  generation: 1
  labels:
    app: core
    chart: core-0.1.0
    heritage: Tiller
    release: core
  name: core
  namespace: develop
spec:
  backend:
    serviceName: core
    servicePort: 80
  rules:
  - host: example.com
    http:
      paths:
      - backend:
          serviceName: core
          servicePort: 80
status:
  loadBalancer: {}
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", BuildDate:"2017-09-14T06:55:55Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8+", GitVersion:"v1.8.2-gke.0", GitCommit:"52ea03646e64b35a5b092ab32bb529400c296aa6", GitTreeState:"clean", BuildDate:"2017-10-24T23:31:18Z", GoVersion:"go1.8.3b4", Compiler:"gc", Platform:"linux/amd64"}

Any ideas?

it may be related to #43

@nicksardo
Copy link
Contributor

You probably have an ingress referencing a service that's not type NodePort. It may not be the newly added ingress, it could be any GCE ingress.

@stevenbarragan
Copy link
Author

stevenbarragan commented Nov 16, 2017

You where right, it wasn't even the ingress I just created, it was another one I lost track of.

Thanks for the help.

Better errors would be nice though 😬

@FossPrime
Copy link

I was able to solve it by adding an annotation to disable the Google LB for my ingress.

metadata:
  name: test-deployment
  annotations:
    kubernetes.io/ingress.class: "nginx"

http://blog.chronos-technology.nl/post/disabling-gke-load-balancer-in-kubernetes/

@ddehghan
Copy link

Yes. kubernetes.io/ingress.class: nginx can handle services that are exposed by ClusterIp. We have it working in production

@FossPrime
Copy link

@ddehghan I definitely tried that in GKE with no luck, I'm having to use a dynamic IP on a node, which changes every k8s update. Are you sure you're using cluster ip and not node ip?

@ddehghan
Copy link

Here is my settings. nginx-ingress-controller is deployed in the cluster and gets the traffic from the External Load balancer on GKE. We dont expose our pods to the GCE ingress. We just use it to bring the traffic to our own nginx-ingress. With the settings below the traffic gets routed correctly. But we still see this error

"googleapi: Error 400: Invalid value for field 'namedPorts[4].port': '0'. Must be greater than or equal to 1, invalid"

I am pretty sure this is just a bug. I deleted the ingress and recreated it and the error went away.
It actually happens consistently. I changed the service type form Nodeport to ClusterIP and back and the errors appears. And I deleted the ingress and recreated it and the error goes away.

---
Not shown is the nginx-ingress-controller deployed with helm.
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:

  name: https-ingress

  annotations:
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod-cluster-issuer
spec:

  tls:
  - secretName: example-prod-tls
    hosts:
    - example.io
    - '*.example.io'

  rules:

  - host: test2.example.io
    http:
      paths:
      - path: /
        backend:
          serviceName: dm-django-stage
          servicePort: dm-django-port
---
apiVersion: v1
kind: Service
metadata:
  name: dm-django-stage
spec:
  ports:
  - name: dm-django-port
    port: 5000
    protocol: TCP
    targetPort: 5000
  selector:
    app: dm-django
  type: NodePort            <--  or ClusterIP here. They both work.



@Freyert
Copy link

Freyert commented Sep 10, 2018

I know everyone is going to love this, but the way I was able to fix this was to delete and reinstall the NGINX Ingress controller itself. Now I'm using ClusterIP for my service and the ingress can assign addresses to it!

This is using stable/nginx-ingress-0.28.2 from https://github.com/helm/charts

@FossPrime
Copy link

@Freyert are you on GKE? I suspect their firewalls make this impossible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants