Drone server changing ports/protocol

I’m trying to get Drone working in Kubernetes. I had the service and statefulset working yesterday, but it appears I might have made changes to configs that is causing the server port to change, making it inaccessible.

I’ve attached my kibana logs. You can see that yesterday it was starting the server on port 80. Then today its starting it on 443 with the IP address included. But in reality the server is completely inaccessible.

I’ve tried port-forwarding to ports 80, 443 and 8000 of the pod, and when I curl it the connection is always refused:

$ kc port-forward pod/drone-server-0 8000:80 -n drone
Forwarding from 127.0.0.1:8000 -> 80
Forwarding from [::1]:8000 -> 80
Handling connection for 8000
E0328 13:04:53.046536    5562 portforward.go:331] an error occurred forwarding 8000 -> 80: error forwarding port 80 to pod d3e349ef5ae522344e350de9508ae93df598f8ae18c20c22611eb3a9e6eb8c37, uid : exit status 1: 2019/03/28 19:04:53 socat[29230] E connect(5, AF=2 127.0.0.1:80, 16): Connection refused

The same thing happens for ports 443 and 8000 on the pod. I’ve also tried kubectl execing into the pod and trying to curl from there. Same thing…connection is always refused.

$ kc exec -it drone-server-0 -n drone -- /bin/sh
... (install curl)
/ # curl localhost:80
curl: (7) Failed to connect to localhost port 80: Connection refused
/ # curl localhost:443
curl: (7) Failed to connect to localhost port 443: Connection refused
/ # curl localhost:8000
curl: (7) Failed to connect to localhost port 8000: Connection refused
/ # curl tcp://localhost:80

What could be causing drone to change the server? You can also see I changed the ENV variable DRONE_SERVER_PROTO from http to https and that doesn’t seem to make any difference either.

did you deploy Drone on Kubernetes with a service called drone-server? This causes kubernetes to automatically set DRONE_SERVER_* variables including DRONE_SERVER_PROTO which causes problems because these are actual variables used by Drone. You should disable these default Kubernetes variables, or rename the service.

1 Like

Yes I did! I’m trying to get secrets to work so I renamed the statefulset and service from just drone to drone-server to be more explicit (drone secrets deployment named drone-secrets. It sounds like I should undo that and just leave it as drone? Let me give that a shot.

I think you can also try and override the variable. This will reset the value to what Drone is expecting and should override the Kubernetes service variables

env:
- name: DRONE_SERVER_PORT
  value: ":80"
1 Like

Just tried changing DRONE_SERVER_PROTO to :80 and that doesn’t seem to fix it. Specifically the URL portion of the log message looks broken:

{"acme":false,"host":"drone.organization.io","level":"info","msg":"starting the http server","port":"tcp://100.67.65.37:443","proto":":80","time":"2019-03-28T19:53:01Z","url":":80://drone.organization.io"}

I’m going to try renaming things back to just “drone”. Stand by…

Okay, changed all the names back to drone instead of drone-server and everything is working again.

{"acme":false,"host":"drone.organization.io","level":"info","msg":"starting the http server","port":":80","proto":"https","time":"2019-03-28T20:01:42Z","url":"https://drone.organization.io"}

Thanks for your help - this was a subtle bug.

also my previous message had a typo / error … I meant to suggest setting DRONE_SERVER_PORT=:80, not DRONE_SERVER_PROTO

This threat is very old, but i think there should be a note in the kubernetes part of the documentation, that the service name shouldn’t be drone-server :slight_smile:

I ran into this again :slight_smile: Is this bug already logged?