Drone

Drone-runner-kube: Pipeline cannot resolve service hostname that contains underscore '_'

I trying to setup drone on kubernetes runner.
I found a document that Kubernetes runner required to specify a port in yaml file.

Strangely, if hostname contains an underscore, the service cannot be accessed from the pipeline step.
When I was delete underscore on service name, It works properly.

Here is the example.

kind: pipeline
type: kubernetes
name: default
services:
- name: db_db
  image: mysql:5.7
  environment:
    MYSQL_DATABASE: test
    MYSQL_ROOT_PASSWORD: test
  ports:
  - 3306
steps:
- name: ping-mysql
  image: mysql:5.7
  environment:
    DATABASE_HOSTNAME: db_db
    DATABASE_USERNAME: root
    DATABASE_PASSWORD: test
  commands:
  # wait for mysql service to become available
  - |
    export RETRY_COUNT=10

    count=0
    until ( mysqladmin -u$DATABASE_USERNAME -p$DATABASE_PASSWORD -h$DATABASE_HOSTNAME ping --connect_timeout=2 )
    do
      count=$((count+1))
      if [ $count -gt $RETRY_COUNT ]
      then
        echo "Failed to start required services."
        exit 1
      fi
      echo "Checking the services(retry = $count)"
      sleep 10
    done

step ping-mysql output:

mysqladmin: connect to server at 'db_db' failed
error: 'Unknown MySQL server host 'db_db' (0)'
Check that mysqld is running on db_db and that the port is 3306.
You can check this by doing 'telnet db_db 3306'
Checking the services(retry = 1)

I am using kubernetes with kops on AWS.
The kubernetes version was v1.14.8
Drone server Image: docker.io/drone/drone:1.6.1

Here is a reference example:
https://docs.drone.io/pipeline/kubernetes/examples/service/mysql/

One thing that jumps out is that steps with commands should be placed in the steps section, not in the service section. Also can you confirm you installed the drone/drone-kube-runner:1 image? If you installed from Helm stable please read this comment.

also meant to say that Drone uses the host aliases feature to map the hostname to the container. https://kubernetes.io/docs/concepts/services-networking/add-entries-to-pod-etc-hosts-with-host-aliases/#adding-additional-entries-with-hostaliases

I apologize for my inconvenience.
steps are missing while creating example configuration yaml file. I fixed it now.

No, I installed drone enterprise. with helm https://github.com/helm/charts/tree/master/stable/drone

Here is more information for kubernetes executor:
Image: drone/controller:1.6.0

The charts in Helm stable are broken and are not an officially supported installation method. We recommend using gtaylor/drone-charts instead, which we plan to adopt as our official charts in the coming weeks.

If you used helm stable your installation is not going to work.

Here is more information for kubernetes executor:
Image: drone/controller:1.6.0

This image was used by an experimental kubernetes integration that was deprecated almost a year ago. The stable helm chart produces an invalid installation that uses this deprecated feature and should therefore be avoided. Instead use gtaylor/drone-charts.