Service-mesh, envoy, upstream config. Blocks of type "config" are not expected here

I am trying to configure service-mesh using docker, nomad and consul. I need to configure the retry policy of the envoy proxy server. When registering the service through consul, I solved it through proxy.upstream[*].config section of the config.

But when I try to repeat this configuration in the service description via nomad, I get an error. That this block is not supported. Maybe there are ideas how to solve this.
I attach the test configuration of the service for nomads below

job "srvexm-test" {
   datacenters = ["mesh"]
   type = "service"
   group "test" {
     network {
       mode = "bridge"
       port "im-port" {
       static = 40200
       to = 30405
       }
       port "envoy_metrics" {
       to = 9102
       }
     }

     task "im1-test" {
       driver = "docker"

        template {
        data        = "{{ key \"services/srvexm-im/config\" }}"
        destination = "local/appsettings.json"
        }

       config {
         image = "registry.mydomain/mesh:last"
      auth {
         username = "user"
         password = "user"
      }
      volumes = [
      "local/appsettings.json:/opt/work_apps/appsettings.Production.json",
        ]

       }

     }

service {
  name = "test-service"
  port = 40200
  connect {
    sidecar_service {
      port = 20000

      proxy {
                                config {
          envoy_local_cluster_json = <<EOL
           {
             "@type": "type.googleapis.com/envoy.api.v2.Cluster",
             "name": "local_app",
             "connect_timeout": "5s",
             "circuit_breakers": {
               "thresholds": [
                 {
                   "priority": "HIGH",
                   "max_requests": 1
                 }
               ]
             },
             "load_assignment": {
              "cluster_name": "local_app",
              "endpoints": [
               {
                "lb_endpoints": [
                 {
                  "endpoint": {
                   "address": {
                    "socket_address": {
                     "address": "127.0.0.1",
                     "port_value": 40200
                    }
                   }
                  }
                 }
                ]
               }
              ]
             }
           }
        EOL
        }

        upstreams {
          destination_name = "upstream"
          local_bind_port = 9001

          config {
            envoy_cluster_json = <<EOL
              {
                "@type": "type.googleapis.com/envoy.api.v2.Cluster",
                "name": "upstream",
                "type": "EDS",
                "eds_cluster_config": {
                  "eds_config": {
                    "ads": {}
                  }
                },
                "connect_timeout": "5s",
                "outlier_detection": {
                  "consecutive_5xx": 10,
                  "consecutive_gateway_failure": 10,
                  "base_ejection_time": "30s"
                }
              }
            EOL

            envoy_listener_json = <<EOL
              {
              "@type": "type.googleapis.com/envoy.api.v2.Listener",
              "name": "upstream:127.0.0.1:9001",
              "address": {
                "socketAddress": {
                  "address": "127.0.0.1",
                  "portValue": 9001
                }
              },
              "filterChains": [
                {
                  "filters": [
                    {
                      "name": "envoy.http_connection_manager",
                      "config": {
                        "stat_prefix": "upstream",
                        "route_config": {
                          "name": "local_route",
                          "virtual_hosts": [
                            {
                              "name": "backend",
                              "domains": ["*"],
                              "routes": [
                                {
                                  "match": {
                                    "prefix": "/"
                                  },
                                  "route": {
                                    "cluster": "upstream",
                                    "timeout": "6s",
                                    "retry_policy": {
                                      "retry_on": "5xx",
                                      "num_retries": 5,
                                      "per_try_timeout": "2s"
                                    }
                                  }
                                }
                              ]
                            }
                          ]
                        },
                        "http_filters": [
                          {
                            "name": "envoy.router",
                            "config": {}
                          }
                        ]
                      }
                    }
                  ]
                }
              ]
            }
            EOL
          }
        }
      }
    }
  }
}
}
}
Summary

This text will be hidden

1 Like

Facing the same issue here. The documentation talks about setting upstreams[*].config via consul service configuration. The same does not work with nomad jobs.

Hi @sergey.gorbatov :wave:

Would it be possible to send us the full log message so we can investigate this further?

Same for you @jawahars16 if you can.

Thanks!

There are no logs. The error occurs when working with the console as a reaction of nomad to the command. The text of job.nomad is presented in the post above.

root@yenisey01:~# nomad job run job.nomad
Error getting job struct: Error parsing job file from job.nomad:
job.nomad:87,11-17: Unsupported block type; Blocks of type "config" are not expected here.

Ahh got it, thanks.

Could you trying running it like this:

service {
  name = "test-service"
  port = 40200
  connect {
    sidecar_service {
      port = 20000

      proxy {
        config = {
          envoy_local_cluster_json = <<EOL
# ...

This attribute is a map, so it must be passed with the = instead of as a block.