Configuration overview

The overview of the MOSN configuration file.

The MOSN configuration file comprises the following four parts:

  • Server configurations: Currently, only one server can be configured. The server supports some basic configurations and corresponding listener configurations.
  • ClusterManager configurations: This part supports configuring detailed upstream information of MOSN.
  • xDS configurations for connecting to the control plane (Pilot)
  • Other configurations
    • Configurations for Trace, Metrics, Debug, and Admin API
    • Extension configurations: the custom extension configurations

Configuration file overview

The basic configurations of MOSN are shown as follows.

  1. {
  2. "servers": [],
  3. "cluster_manager": {},
  4. "dynamic_resources": {},
  5. "static_resources": {},
  6. "admin":{},
  7. "pprof":{},
  8. "tracing":{},
  9. "metrics":{}
  10. }

Configuration modes

MOSN supports the following configuration modes:

  • Static configuration
  • Dynamic configuration
  • Hybrid configuration

Static configuration

  • In the static configuration mode, MOSN starts without connecting to Pilot of the control plane. This mode applies to some relatively fixed and simple scenarios (for example, demonstration of MOSN).
  • Even if MOSN starts in the static configuration mode, you can use the extension code to call the dynamic configuration update API to dynamically modify the configuration.
  • To start MOSN in the static configuration mode, one server and at least one cluster are required.

Dynamic configuration

  • In the dynamic configuration mode, MOSN starts with only configurations for accessing the control plane, but no configuration for running.

  • After starting in dynamic configuration mode, MOSN will request the control plane to provide configurations required for running. The control plane can also push configuration updates when MOSN is running.

  • To start MOSN in the dynamic configuration mode, the DynamicResources and StaticResources configurations are required.

Hybrid configuration

MOSN can start in a hybrid mode with both static and dynamic configurations. In this mode, MOSN first completes initialization in the static configuration mode and then obtains configuration updates from the control plane.

Configuration examples

Static configuration example

The example of static configuration is as follows.

  1. {
  2. "servers": [
  3. {
  4. "default_log_path": "/home/admin/logs/mosn/default.log",
  5. "default_log_level": "DEBUG",
  6. "processor": 4,
  7. "listeners": [
  8. {
  9. "address": "0.0.0.0:12220",
  10. "bind_port": true,
  11. "filter_chains": [
  12. {
  13. "filters": [
  14. {
  15. "type": "proxy",
  16. "config": {
  17. "downstream_protocol": "SofaRpc",
  18. "upstream_protocol": "SofaRpc",
  19. "router_config_name": "test_router"
  20. }
  21. },
  22. {
  23. "type": "connection_manager",
  24. "config": {
  25. "router_config_name": "test_router",
  26. "virtual_hosts": []
  27. }
  28. }
  29. ]
  30. }
  31. ]
  32. }
  33. ]
  34. }
  35. ],
  36. "cluster_manager": {
  37. "clusters": [
  38. {
  39. "name":"example",
  40. "lb_type": "LB_ROUNDROBIN",
  41. "hosts": [
  42. {"address": "127.0.0.1:12200"}
  43. ]
  44. }
  45. ]
  46. }
  47. }

Dynamic configuration example

The example of dynamic configuration is as follows.

  1. {
  2. "servers": [
  3. {
  4. "default_log_path": "stdout",
  5. "default_log_level": "DEBUG"
  6. }
  7. ],
  8. "static_resources": {
  9. "clusters": [
  10. {
  11. "connect_timeout": "1s",
  12. "load_assignment": {
  13. "cluster_name": "xds_cluster",
  14. "endpoints": [
  15. {
  16. "lb_endpoints": [
  17. {
  18. "endpoint": {
  19. "address": {
  20. "socket_address": {
  21. "address": "127.0.0.1",
  22. "port_value": 9002
  23. }
  24. }
  25. }
  26. }
  27. ]
  28. }
  29. ]
  30. },
  31. "http2_protocol_options": {},
  32. "name": "xds_cluster"
  33. }
  34. ]
  35. },
  36. "dynamic_resources": {
  37. "ads_config": {
  38. "api_type": "GRPC",
  39. "transport_api_version": "V3",
  40. "grpc_services": [
  41. {
  42. "envoy_grpc": {
  43. "cluster_name": "xds_cluster"
  44. }
  45. }
  46. ],
  47. "set_node_on_first_message_only": true
  48. },
  49. "cds_config": {
  50. "resource_api_version": "V3",
  51. "api_config_source": {
  52. "api_type": "GRPC",
  53. "transport_api_version": "V3",
  54. "grpc_services": [
  55. {
  56. "envoy_grpc": {
  57. "cluster_name": "xds_cluster"
  58. }
  59. }
  60. ],
  61. "set_node_on_first_message_only": true
  62. }
  63. },
  64. "lds_config": {
  65. "resource_api_version": "V3",
  66. "api_config_source": {
  67. "api_type": "GRPC",
  68. "transport_api_version": "V3",
  69. "grpc_services": [
  70. {
  71. "envoy_grpc": {
  72. "cluster_name": "xds_cluster"
  73. }
  74. }
  75. ],
  76. "set_node_on_first_message_only": true
  77. }
  78. }
  79. },
  80. "node": {
  81. "cluster": "test-cluster",
  82. "id": "test-id"
  83. },
  84. "layered_runtime": {
  85. "layers": [
  86. {
  87. "name": "runtime-0",
  88. "rtds_layer": {
  89. "rtds_config": {
  90. "resource_api_version": "V3",
  91. "api_config_source": {
  92. "transport_api_version": "V3",
  93. "api_type": "GRPC",
  94. "grpc_services": {
  95. "envoy_grpc": {
  96. "cluster_name": "xds_cluster"
  97. }
  98. }
  99. }
  100. },
  101. "name": "runtime-0"
  102. }
  103. }
  104. ]
  105. },
  106. "admin": {
  107. "access_log_path": "/dev/null",
  108. "address": {
  109. "socket_address": {
  110. "address": "127.0.0.1",
  111. "port_value": 9003
  112. }
  113. }
  114. }
  115. }

Listener configurations

The listener configurations of MOSN.

Server configurations

The server configurations of MOSN.

Trace configurations

The trace configurations of MOSN.

Custom configurations

The custom configurations of MOSN.

Last modified October 28, 2022: docs: Changes to the v1.2.0 configuration (#217) (d237414)