How to configure passive heath check circuit breaker in declarative kong config

I am deploying kong 2.8 in db-less mode. I would like to know how to specify its declarative configuration to enable passive health checks i.e. circuit breaker. It would be great if some one can share an example configuration file.

Thanks.

One reading more on this I could move a step further by configuring a upstream and a target object like mentioned below but I don’t understand how to link them with the service object defined above in the config.

Thanks.

_format_version: "2.1"

services:
  - name: dev-app
    url: http://172.19.0.1:8080/my-service
    routes:
      - name: dev-app-route
        paths:
          - /api/v1
        strip_path: false

upstreams:
  - name: dev-app-upstream
    targets:
      - target: localhost:8000
        weight: 100
    healthchecks:
      threshold: 3
      passive:
        unhealthy:
          http_statuses: [400,500]
          timeouts: 2
          tcp_failures: 2
          http_failures: 2
        healthy:
          http_statuses: [200,201,204]
          successes: 5
    slots: 10000

Playing around with the config I could get the below config working. I have a few questions around its behavior

  1. How do we customize the message returned by kong when the upstream target is unhealthy. Right now it is failure to get a peer from the ring-balancer
  2. When the backend service is down, only first time we get the message “The upstream server is currently unavailable”. Post that we get the message as noted in #1. I didn’t understand this behavior. Shouldn’t it be showing this message always?
  3. It seems we need to call a REST service to mark the target healthy again after it is marked unhealthy as documented here. Can it not enable it automatically by checking with the backend service when the api call is made?

Any inputs? Thanks.

_format_version: "2.1"

services:
  - name: dev-app
    host: dev-app-upstream
    protocol: http
    port: 8000
    path: /my-service
    routes:
      - name: dev-app-route
        paths:
          - /api/v1
        strip_path: false

upstreams:
  - name: dev-app-upstream
    targets:
      - target: 172.19.0.1:8080
        weight: 100
    healthchecks:
      threshold: 3
      passive:
        unhealthy:
          http_statuses: [500]
          timeouts: 2
          tcp_failures: 2
          http_failures: 2
        healthy:
          http_statuses: [200,201,204]
          successes: 5
    slots: 10000