DNS resolution issue with Kubernetes native


I’m facing to a strange issue with the last version of Drone with Kubernetes mode.

Here is the simple pipeline :

kind: pipeline
name: default

  - name: nats
    image: nats-streaming
      - -cid
      - libmed
  - name: postgres
    image: postgres
      POSTGRES_PASSWORD: password
  - name: build
    image: golang
      DB_PASSWORD: password
      DB_NAME: postgres
      DB_HOST: postgres
      NATS_URL: nats://nats:4222
      - go build
      - go test

The Drone itself has been of course deployed with :
value: “true”
value: “drone”
value: “drone”

The services are spawned but when my tests begins :
2019/04/08 18:31:54 connecting to PostgreSQL database
2019/04/08 18:31:54 error when trying to connect to PostgreSQL : dial tcp: lookup postgres on no such host is the K8s DNS server.
I’ve I missed something ?

With kubernetes native you need to define ports for your service. See https://docs.drone.io/examples/service/nats/

Good point!

But it seems the syntax has changed :

default: Service "nats" is invalid: [spec.ports[0].name: Required value, spec.ports[1].name: Required value]

With the syntax used in your sample.

I’ve tried with a K8s syntax:


  • name: nats
    image: nats-streaming
    • -cid
    • libmed
    • port: 4222
      name: nats
    • port: 8222
      name: monitoring`

But same result.

Not sure, but we have a thread that you can use to help debug issues with the Kubernetes runtime and recommend changes/ improvements. See Contributing to Drone for Kubernetes

The code seems clear.
I will take a look tomorrow.

Thank you.

Thanks! Please let me know what you find and how I can help :slight_smile:

Ok, I’ve checked :

  • drone-yaml code : everything looks good
  • drone-runtime code : everything looks good

The spec.ports[0].name and spec.ports[0].name is well filled via func toService(spec *engine.Spec, step *engine.Step) *v1.Service on util.go.

If I take my .chrono.yml file, I translate them with drone-yaml into a json file and I use this json file through drone-runtime and pointing to my current Kubernetes cluster, everything run fine…

But fail on my drone server deployed with the latest docker image available yesterday.

The only suspect could be the old version of k8s.io/client-go (v9) you use, incompatible with my cluster version (v1.13.4).
The only suggestion I can do is to try to build a a docker version that use k8s.io/client-go v11.0.0 (the last available)…

P.S. This only fail for service(s) that had more than one listen port (because in this case, the port name is mandatory in K8s)

I have the same issue.


  - name: mongo
    image: mongo:4
    command: [--smallfiles]
      - 27017
  - name: mailcatcher
    image: schickling/mailcatcher
      - name: smtp
        port: 1025
      - name: api
        port: 1080

Mongo service works fine, while mailcatcher fails with

default: Service “mailcatcher” is invalid: [spec.ports[0].name: Required value, spec.ports[1].name: Required value]