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 port in upstream #53

Closed
gianrubio opened this issue Dec 12, 2016 · 3 comments · Fixed by #58
Closed

Invalid port in upstream #53

gianrubio opened this issue Dec 12, 2016 · 3 comments · Fixed by #58

Comments

@gianrubio
Copy link
Contributor

I figure out an an issue running the master branch. The nginx-ingress mapped an invalid port "0". I have 2 ports (22/80) exposed in this pod, the port 22 was mapped incorrectly.

nginx.conf

    upstream gitlab-gitlab-80 {
        least_conn;
        server 10.1.5.21:0 max_fails=0 fail_timeout=0;
        server 10.1.5.21:80 max_fails=0 fail_timeout=0;
    }

Cmd

 ./nginx-ingress-controller --default-backend-service=kube-system/new-default-http-backend --tcp-services-configmap=kube-system/tcp-configmap --configmap=kube-system/nginx-load-balancer-conf

Pod description

Name:		gitlab-***
Namespace:	***
Node:		***
Start Time:	Tue, 06 Dec 2016 11:36:11 +0100
Labels:		component=***
		k8s-app=***
		pod-template-hash=***
Status:		Running
IP:		10.1.5.21
Controllers:	ReplicaSet/gitlab-***
Containers:
  gitlab:
    Container ID:	docker://***
    Image:		quay.io/***
    Image ID:		docker://***
    Ports:		80/TCP, 22/TCP
....

Logs

I1212 13:59:35.924606    1132 template.go:95] NGINX configuration: {"BacklogSize":511,"Backends":[
....
{"name":"gitlab-gitlab-80","secure":false,"endpoints":[
{"address":"10.1.5.21","port":"0","maxFails":0,"failTimeout":0},
{"address":"10.1.5.21","port":"80","maxFails":0,"failTimeout":0}]}] 
...
Error: exit status 1
2016/12/12 13:59:35 [emerg] 1153#1153: invalid port in upstream "10.1.5.21:0" in /tmp/nginx-cfg141892828:265
nginx: [emerg] invalid port in upstream "10.1.5.21:0" in /tmp/nginx-cfg141892828:265
nginx: configuration file /tmp/nginx-cfg141892828 test failed

@aledbf
Copy link
Member

aledbf commented Dec 12, 2016

@gianrubio please post the Ingress and service yaml

@gianrubio
Copy link
Contributor Author

@aledbf

svc.yml

apiVersion: v1
kind: Service
metadata:
  labels:
    name: gitlab
  name: gitlab
  namespace: ***
  selfLink: /api/v1/namespaces/gitlab/services/gitlab
spec:
  clusterIP: ***
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  - name: ssh
    port: 22
    protocol: TCP
    targetPort: 22
  selector:
    component: gitlab
    k8s-app: gitlab
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

Ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    ingress.kubernetes.io/whitelist-source-range: ***
    kubernetes.io/tls-acme: "true"
  generation: 1
  name: gitlab
  namespace: ***
  selfLink: /apis/extensions/v1beta1/namespaces/gitlab/ingresses/gitlab
spec:
  rules:
  - host: gitlab.mydomain.com
    http:
      paths:
      - backend:
          serviceName: gitlab
          servicePort: 80
        path: /
  tls:
  - hosts:
    - gitlab.mydomain.com
    secretName: ****
status:
  loadBalancer:
    ingress:
    - ip: ***
    - ip: ***

@gianrubio
Copy link
Contributor Author

@aledbf I just realised the error. I don't have ingress mapping to this port 22.

$ kubectl get ingress -n gitlab gitlab -o wide
NAME      HOSTS            ADDRESS                                PORTS     AGE
gitlab    ***              ip1, ip2                               80, 443   19d

I'm submiting a PR to fix this issue

gianrubio pushed a commit to gianrubio/ingress that referenced this issue Dec 14, 2016
hnrytrn pushed a commit to hnrytrn/ingress-nginx that referenced this issue Jun 20, 2018
Emit response StatsD metrics about upstreams when dynamic configuration is enabled
haoqing0110 referenced this issue in stolostron/management-ingress Mar 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants