Skip to content

Commit

Permalink
feat: make egctl x translate output struct
Browse files Browse the repository at this point in the history
Signed-off-by: bitliu <bitliu@tencent.com>
  • Loading branch information
Xunzhuo committed Feb 22, 2023
1 parent b97859d commit 5c5697c
Show file tree
Hide file tree
Showing 7 changed files with 498 additions and 365 deletions.
332 changes: 168 additions & 164 deletions docs/latest/user/egctl.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This subcommand allows users to translate from an input configuration type to an
In the below example, we will translate the Kubernetes resources (including the Gateway API resources) into xDS
resources.

```
```shell
cat <<EOF | egctl x translate --from gateway-api --to xds -f -
apiVersion: gateway.networking.k8s.io/v1beta1
kind: GatewayClass
Expand Down Expand Up @@ -76,176 +76,180 @@ spec:
type: PathPrefix
value: /
EOF
```

```

xDS
Key: default-eg
Bootstrap:
admin:
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/null
address:
socket_address:
address: 127.0.0.1
port_value: 19000
dynamic_resources:
cds_config:
resource_api_version: V3
api_config_source:
api_type: DELTA_GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
set_node_on_first_message_only: true
lds_config:
resource_api_version: V3
api_config_source:
api_type: DELTA_GRPC
transport_api_version: V3
grpc_services:
- envoy_grpc:
cluster_name: xds_cluster
set_node_on_first_message_only: true
static_resources:
clusters:
- connect_timeout: 1s
load_assignment:
cluster_name: xds_cluster
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: envoy-gateway
port_value: 18000
typed_extension_protocol_options:
"envoy.extensions.upstreams.http.v3.HttpProtocolOptions":
"@type": "type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions"
"explicit_http_config":
"http2_protocol_options": {}
name: xds_cluster
type: STRICT_DNS
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
common_tls_context:
tls_params:
tls_maximum_protocol_version: TLSv1_3
tls_certificate_sds_secret_configs:
- name: xds_certificate
sds_config:
path_config_source:
path: "/sds/xds-certificate.json"
resource_api_version: V3
validation_context_sds_secret_config:
name: xds_trusted_ca
sds_config:
path_config_source:
path: "/sds/xds-trusted-ca.json"
resource_api_version: V3
layered_runtime:
layers:
- name: runtime-0
rtds_layer:
rtds_config:
resource_api_version: V3
api_config_source:
transport_api_version: V3
api_type: DELTA_GRPC
grpc_services:
envoy_grpc:
cluster_name: xds_cluster
name: runtime-0
Listeners:
- accessLog:
- filter:
responseFlagFilter:
flags:
- NR
name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
portValue: 10080
defaultFilterChain:
filters:
- name: envoy.filters.network.http_connection_manager
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
accessLog:
- name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
httpFilters:
- name: envoy.filters.http.router
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
rds:
configSource:
```yaml
resourceKey: default-eg
resourceType: xds
configs:
- '@type': type.googleapis.com/envoy.admin.v3.BootstrapConfigDump
bootstrap:
admin:
accessLog:
- name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/null
address:
socketAddress:
address: 127.0.0.1
portValue: 19000
dynamicResources:
cdsConfig:
apiConfigSource:
apiType: DELTA_GRPC
grpcServices:
- envoyGrpc:
clusterName: xds_cluster
setNodeOnFirstMessageOnly: true
transportApiVersion: V3
resourceApiVersion: V3
ldsConfig:
apiConfigSource:
apiType: DELTA_GRPC
grpcServices:
- envoyGrpc:
clusterName: xds_cluster
setNodeOnFirstMessageOnly: true
transportApiVersion: V3
resourceApiVersion: V3
layeredRuntime:
layers:
- name: runtime-0
rtdsLayer:
name: runtime-0
rtdsConfig:
apiConfigSource:
apiType: DELTA_GRPC
grpcServices:
- envoyGrpc:
clusterName: xds_cluster
setNodeOnFirstMessageOnly: true
transportApiVersion: V3
resourceApiVersion: V3
routeConfigName: default-eg-http
statPrefix: http
upgradeConfigs:
- upgradeType: websocket
useRemoteAddress: true
name: default-eg-http
Routes:
- name: default-eg-http
virtualHosts:
- domains:
- '*'
name: default-eg-http
routes:
- match:
headers:
- name: :authority
stringMatch:
exact: www.example.com
prefix: /
route:
cluster: default-backend-rule-0-match-0-www.example.com
Clusters:
- commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 5s
dnsLookupFamily: V4_ONLY
loadAssignment:
clusterName: default-backend-rule-0-match-0-www.example.com
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: default-backend-rule-0-match-0-www.example.com
outlierDetection: {}
type: STATIC
staticResources:
clusters:
- connectTimeout: 1s
loadAssignment:
clusterName: xds_cluster
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: envoy-gateway
portValue: 18000
name: xds_cluster
transportSocket:
name: envoy.transport_sockets.tls
typedConfig:
'@type': type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
commonTlsContext:
tlsCertificateSdsSecretConfigs:
- name: xds_certificate
sdsConfig:
pathConfigSource:
path: /sds/xds-certificate.json
resourceApiVersion: V3
tlsParams:
tlsMaximumProtocolVersion: TLSv1_3
validationContextSdsSecretConfig:
name: xds_trusted_ca
sdsConfig:
pathConfigSource:
path: /sds/xds-trusted-ca.json
resourceApiVersion: V3
type: STRICT_DNS
typedExtensionProtocolOptions:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
'@type': type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
explicitHttpConfig:
http2ProtocolOptions: {}
- '@type': type.googleapis.com/envoy.admin.v3.ClustersConfigDump
staticClusters:
- cluster:
'@type': type.googleapis.com/envoy.config.cluster.v3.Cluster
commonLbConfig:
localityWeightedLbConfig: {}
connectTimeout: 5s
dnsLookupFamily: V4_ONLY
loadAssignment:
clusterName: default-backend-rule-0-match-0-www.example.com
endpoints:
- lbEndpoints:
- endpoint:
address:
socketAddress:
address: 1.1.1.1
portValue: 3000
loadBalancingWeight: 1
loadBalancingWeight: 1
locality: {}
name: default-backend-rule-0-match-0-www.example.com
outlierDetection: {}
type: STATIC
- '@type': type.googleapis.com/envoy.admin.v3.ListenersConfigDump
staticListeners:
- listener:
'@type': type.googleapis.com/envoy.config.listener.v3.Listener
accessLog:
- filter:
responseFlagFilter:
flags:
- NR
name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
address:
socketAddress:
address: 0.0.0.0
portValue: 10080
defaultFilterChain:
filters:
- name: envoy.filters.network.http_connection_manager
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
accessLog:
- name: envoy.access_loggers.file
typedConfig:
'@type': type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
httpFilters:
- name: envoy.filters.http.router
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
rds:
configSource:
apiConfigSource:
apiType: DELTA_GRPC
grpcServices:
- envoyGrpc:
clusterName: xds_cluster
setNodeOnFirstMessageOnly: true
transportApiVersion: V3
resourceApiVersion: V3
routeConfigName: default-eg-http
statPrefix: http
upgradeConfigs:
- upgradeType: websocket
useRemoteAddress: true
name: default-eg-http
- '@type': type.googleapis.com/envoy.admin.v3.RoutesConfigDump
staticRouteConfigs:
- routeConfig:
'@type': type.googleapis.com/envoy.config.route.v3.RouteConfiguration
name: default-eg-http
virtualHosts:
- domains:
- '*'
name: default-eg-http
routes:
- match:
headers:
- name: :authority
stringMatch:
exact: www.example.com
prefix: /
route:
cluster: default-backend-rule-0-match-0-www.example.com
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"resourceKey":"default-eg","resourceType":"xds","configs":[{"@type":"type.googleapis.com/envoy.admin.v3.BootstrapConfigDump","bootstrap":{"admin":{"accessLog":[{"name":"envoy.access_loggers.file","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog","path":"/dev/null"}}],"address":{"socketAddress":{"address":"127.0.0.1","portValue":19000}}},"dynamicResources":{"cdsConfig":{"apiConfigSource":{"apiType":"DELTA_GRPC","grpcServices":[{"envoyGrpc":{"clusterName":"xds_cluster"}}],"setNodeOnFirstMessageOnly":true,"transportApiVersion":"V3"},"resourceApiVersion":"V3"},"ldsConfig":{"apiConfigSource":{"apiType":"DELTA_GRPC","grpcServices":[{"envoyGrpc":{"clusterName":"xds_cluster"}}],"setNodeOnFirstMessageOnly":true,"transportApiVersion":"V3"},"resourceApiVersion":"V3"}},"layeredRuntime":{"layers":[{"name":"runtime-0","rtdsLayer":{"name":"runtime-0","rtdsConfig":{"apiConfigSource":{"apiType":"DELTA_GRPC","grpcServices":[{"envoyGrpc":{"clusterName":"xds_cluster"}}],"transportApiVersion":"V3"},"resourceApiVersion":"V3"}}}]},"staticResources":{"clusters":[{"connectTimeout":"1s","loadAssignment":{"clusterName":"xds_cluster","endpoints":[{"lbEndpoints":[{"endpoint":{"address":{"socketAddress":{"address":"envoy-gateway","portValue":18000}}}}]}]},"name":"xds_cluster","transportSocket":{"name":"envoy.transport_sockets.tls","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext","commonTlsContext":{"tlsCertificateSdsSecretConfigs":[{"name":"xds_certificate","sdsConfig":{"pathConfigSource":{"path":"/sds/xds-certificate.json"},"resourceApiVersion":"V3"}}],"tlsParams":{"tlsMaximumProtocolVersion":"TLSv1_3"},"validationContextSdsSecretConfig":{"name":"xds_trusted_ca","sdsConfig":{"pathConfigSource":{"path":"/sds/xds-trusted-ca.json"},"resourceApiVersion":"V3"}}}}},"type":"STRICT_DNS","typedExtensionProtocolOptions":{"envoy.extensions.upstreams.http.v3.HttpProtocolOptions":{"@type":"type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions","explicitHttpConfig":{"http2ProtocolOptions":{}}}}}]}}},{"@type":"type.googleapis.com/envoy.admin.v3.ClustersConfigDump","staticClusters":[{"cluster":{"@type":"type.googleapis.com/envoy.config.cluster.v3.Cluster","commonLbConfig":{"localityWeightedLbConfig":{}},"connectTimeout":"5s","dnsLookupFamily":"V4_ONLY","loadAssignment":{"clusterName":"default-backend-rule-0-match-0-www.example.com","endpoints":[{"lbEndpoints":[{"endpoint":{"address":{"socketAddress":{"address":"1.1.1.1","portValue":3000}}},"loadBalancingWeight":1}],"loadBalancingWeight":1,"locality":{}}]},"name":"default-backend-rule-0-match-0-www.example.com","outlierDetection":{},"type":"STATIC"}}]},{"@type":"type.googleapis.com/envoy.admin.v3.ListenersConfigDump","staticListeners":[{"listener":{"@type":"type.googleapis.com/envoy.config.listener.v3.Listener","accessLog":[{"filter":{"responseFlagFilter":{"flags":["NR"]}},"name":"envoy.access_loggers.file","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog","path":"/dev/stdout"}}],"address":{"socketAddress":{"address":"0.0.0.0","portValue":10080}},"defaultFilterChain":{"filters":[{"name":"envoy.filters.network.http_connection_manager","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager","accessLog":[{"name":"envoy.access_loggers.file","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog","path":"/dev/stdout"}}],"httpFilters":[{"name":"envoy.filters.http.router","typedConfig":{"@type":"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"}}],"rds":{"configSource":{"apiConfigSource":{"apiType":"DELTA_GRPC","grpcServices":[{"envoyGrpc":{"clusterName":"xds_cluster"}}],"setNodeOnFirstMessageOnly":true,"transportApiVersion":"V3"},"resourceApiVersion":"V3"},"routeConfigName":"default-eg-http"},"statPrefix":"http","upgradeConfigs":[{"upgradeType":"websocket"}],"useRemoteAddress":true}}]},"name":"default-eg-http"}}]},{"@type":"type.googleapis.com/envoy.admin.v3.RoutesConfigDump","staticRouteConfigs":[{"routeConfig":{"@type":"type.googleapis.com/envoy.config.route.v3.RouteConfiguration","name":"default-eg-http","virtualHosts":[{"domains":["*"],"name":"default-eg-http","routes":[{"match":{"headers":[{"name":":authority","stringMatch":{"exact":"www.example.com"}}],"prefix":"/"},"route":{"cluster":"default-backend-rule-0-match-0-www.example.com"}}]}]}}]}]}
Loading

0 comments on commit 5c5697c

Please sign in to comment.