0

I tried to fllowing sample. https://github.com/kubernetes/ingress-nginx/tree/d27829ce7ebc5f202816c52f69985bc102db9a63/docs/examples/static-ip

so, I write here settings file.

  apiVersion: extensions/v1beta1
  kind: Ingress
  metadata:
    name: ingress-nginx
  spec:
    tls:
    # This assumes tls-secret exists.
    - secretName: tls-secret
    rules:
    - http:
        paths:
        - backend:
            # This assumes http-svc exists and routes to healthy endpoints.
            serviceName: http-svc
            servicePort: 80

  ---

  apiVersion: extensions/v1beta1
  kind: Deployment
  metadata:
    name: http-svc
  spec:
    replicas: 1
    template:
      metadata:
        labels:
          app: http-svc
      spec:
        containers:
        - name: http-svc
          image: gcr.io/google_containers/echoserver:1.8
          ports:
          - containerPort: 8080

  ---

  apiVersion: v1
  kind: Service
  metadata:
    name: http-svc
    labels:
      app: http-svc
  spec:
    ports:
    - port: 80
      targetPort: 8080
      protocol: TCP
      name: http
    selector:
      app: http-svc

And execute following command.

kubectl create -f http-svc.yaml

But I got following error.

  $ kubectl describe ingress
  Name:             ingress-nginx
  Namespace:        default
  Address:
  Default backend:  default-http-backend:80 (10.56.2.5:8080)
  TLS:
    tls-secret terminates
  Rules:
    Host  Path  Backends
    ----  ----  --------
    *
             http-svc:80 (<none>)
  Annotations:
  Events:
    Type     Reason  Age               From                     Message
    ----     ------  ----              ----                     -------
    Normal   ADD     8m                loadbalancer-controller  default/ingress-nginx
    Warning  GCE     2m (x17 over 7m)  loadbalancer-controller  googleapi: Error 400: Invalid value for field 'namedPorts[1].port': '0'. Must be greater than or equal to 1, invalid

If such an error occurs, what is the cause? kubectl version = v1.8.1

  $ kubectl version
  Client Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.1", GitCommit:"f38e43b221d08850172a9a4ea785a86a3ffa3b3a", GitTreeState:"clean", BuildDate:"2017-10-12T00:45:05Z", GoVersion:"go1.9.1", Compiler:"gc", Platform:"darwin/amd64"}
  Server Version: version.Info{Major:"1", Minor:"7+", GitVersion:"v1.7.6-gke.1", GitCommit:"407dbfe965f3de06b332cc22d2eb1ca07fb4d3fb", GitTreeState:"clean", BuildDate:"2017-09-27T21:21:34Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Sinaesthetic
  • 11,426
  • 28
  • 107
  • 176
todoroki
  • 9
  • 4
  • There was a similar issue that was solved for some over here: https://stackoverflow.com/questions/45738404/gce-loadbalancer-invalid-value-for-field-namedports0-port-0-must-be-gr but it apparently didn't apply to me. I'm currently experiencing the same problem even with the gke lb – Sinaesthetic Nov 07 '17 at 23:43

1 Answers1

0

GCE load balancers don't work with services of type ClusterIP:

nodeport is a requirement of the GCE Ingress controller (and cloud controllers in general). "On-prem" controllers like the nginx ingress controllers work with clusterip

Your service doesn't have a type defined, so it is of type ClusterIP by default. This change should do the trick:

---
apiVersion: v1
kind: Service
metadata:
  name: http-svc
  labels:
    app: http-svc
spec:
  type: NodePort
  ports:
  - port: 80
    targetPort: 8080
    protocol: TCP
    name: http
  selector:
    app: http-svc
danielepolencic
  • 4,905
  • 1
  • 26
  • 25