Kubenetes pipeline services not working

Issue: Kubenetes pipeline “services” do not work

Documentation states:

Service containers share the same network as your pipeline steps and can be access at the localhost address. In our previous example, the redis container can be accessed from the pipeline at tcp://127.0.0.1:6379

Reference:
https://docs.drone.io/pipeline/kubernetes/syntax/services/
hxxps://github.com/drone/drone-runtime/issues/69#issuecomment-550074783

Using the redis examples provided here: https://docs.drone.io/pipeline/kubernetes/syntax/services/
results in no connection to the service.
output from connecting container:

redis-cli -h 127.0.0.1 ping
2 Could not connect to Redis at 127.0.0.1:6379: Connection refused

You are able to make the connection via the POD network, but not localhost.

Kubernetes pods usually speaks via a “service” ClusterIP/LoadBalancer, but since services(drone) are only a single container there is no service(kubernetes) being defined.

Doing some troubleshooting I can prove that the port is not accessible via localhost, only via the pod ip

steps
  - name: test
    image: alpine
    commands:
      - apk add busybox-extras
      - apk add bind-tools
      - sleep 3000

services:
  - name: cache
    image: redis
    commands:
      - awk '/32 host LOCAL/ { print f } {f=$2}' </proc/net/fib_trie | grep -v '127.0.0.1' | uniq > /drone/src/redis.ip

Running the above allows me to exec to the test container(in kubernetes) and run telnet to test tcp connections

/drone/src # cat redis.ip 
10.42.3.87
/drone/src # telnet 10.42.3.87 6379
MONITOR
+OK
/drone/src # telnet localhost 6379
telnet: can't connect to remote host (127.0.0.1): Connection refused

Also, I am running drone on a 3 node kubernetes cluster, not minikube. If the worker pods spin up on different nodes in the kube cluster, how does it talk over localhost?

Thanks

Service containers do work for the Kubernetes runner. Here is the example we use in our integration tests to verify: https://github.com/drone-runners/drone-runner-kube/blob/master/samples/services.yml

The issue in your example is that you are trying to use commands for a service container, which in turn overrides the default entrypoint which prevents redis from starting.

Also please make sure you have installed the Kubernetes runner (drone/drone-runner-kube). Please note that the stable Helm chart does not install the Kubernetes runner, but instead installs an experimental Kubernetes implementation that was deprecated earlier this year.