Using Consul or Kubernetes Discovery Client depending on environment variable

Solution 1:

Ok, i found way to do that, you must disable all k8s, not only discovery:

  cloud:
    retry:
      initial-interval: 10
      max-interval: 20
    kubernetes:
      discovery:
        enabled: ${K8S_ENABLED:true}
      enabled: ${K8S_ENABLED:true}
    consul:
      host: ${CONSUL_HOST:localhost}
      port: ${CONSUL_PORT:8500}
      discovery:
        enabled: ${CONSUL_ENABLED:false}
        fail-fast: true
        instance-id: ${spring.application.name}-${server.port}-${instance-id}
        health-check-path: /actuator/health
        health-check-interval: 20s

But is there a way to combine K8S_ENABLED and CONSUL_ENABLED variable to one?