Skip to content
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.

Commit

Permalink
Update LB
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Dec 8, 2020
1 parent 3cb26f0 commit 1c8ca7e
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV CGO_ENABLED=0
RUN go install ./cmd/pipe-xds

FROM alpine
COPY --from=pipeproxy/pipe:v0.4.15 /usr/local/bin/pipe /usr/local/bin/
COPY --from=pipeproxy/pipe:v0.5.1 /usr/local/bin/pipe /usr/local/bin/
COPY --from=builder /go/bin/pipe-xds /usr/local/bin/
RUN apk add -U --no-cache curl iptables ip6tables
WORKDIR /etc/istio/proxy
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ var defaultServices = []bind.DefServiceConfig{
Tag: "health",
Service: bind.StreamServiceConfig{
Listener: bind.ListenerStreamListenConfigConfig{
Network: bind.ListenerStreamListenConfigListenerNetworkEnumEnumTCP,
Network: bind.ListenerStreamListenConfigNetworkEnumEnumNetworkTCP,
Address: ":15021",
},
Handler: bind.HTTP1StreamHandlerConfig{
Expand All @@ -311,7 +311,7 @@ var defaultServices = []bind.DefServiceConfig{
Tag: "metric",
Service: bind.StreamServiceConfig{
Listener: bind.ListenerStreamListenConfigConfig{
Network: bind.ListenerStreamListenConfigListenerNetworkEnumEnumTCP,
Network: bind.ListenerStreamListenConfigNetworkEnumEnumNetworkTCP,
Address: ":15090",
},
Handler: bind.HTTP1StreamHandlerConfig{
Expand All @@ -326,7 +326,7 @@ var defaultServices = []bind.DefServiceConfig{
Tag: "admin",
Service: bind.StreamServiceConfig{
Listener: bind.ListenerStreamListenConfigConfig{
Network: bind.ListenerStreamListenConfigListenerNetworkEnumEnumTCP,
Network: bind.ListenerStreamListenConfigNetworkEnumEnumNetworkTCP,
Address: ":15000",
},
Handler: bind.HTTP1StreamHandlerConfig{
Expand Down
2 changes: 1 addition & 1 deletion convert/xds_config_endpoint_v3_clusterloadassignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Convert_config_endpoint_v3_ClusterLoadAssignment(conf *config.ConfigCtx, c
d = dialers[0].Dialer
default:
d = bind.LbStreamDialerConfig{
Policy: bind.LbStreamDialerLoadBalancePolicyEnumEnumRoundRobin,
Policy: bind.RoundRobinBalancePolicy{},
Dialers: dialers,
}
}
Expand Down
2 changes: 1 addition & 1 deletion convert/xds_config_endpoint_v3_lbendpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func Convert_config_endpoint_v3_LbEndpoint(conf *config.ConfigCtx, c *envoy_conf
return nil, err
}
return bind.DialerStreamDialerConfig{
Network: bind.DialerStreamDialerDialerNetworkEnum(network),
Network: bind.DialerStreamDialerNetworkEnum(network),
Address: address,
}, nil
case *envoy_config_endpoint_v3.LbEndpoint_EndpointName:
Expand Down
2 changes: 1 addition & 1 deletion convert/xds_config_endpoint_v3_localitylbendpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Convert_config_endpoint_v3_LocalityLbEndpoints(conf *config.ConfigCtx, c *e
d = dialers[0].Dialer
default:
d = bind.LbStreamDialerConfig{
Policy: bind.LbStreamDialerLoadBalancePolicyEnumEnumRoundRobin,
Policy: bind.RoundRobinBalancePolicy{},
Dialers: dialers,
}
}
Expand Down
2 changes: 1 addition & 1 deletion convert/xds_config_listener_v3_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func Convert_config_listener_v3_Listener(conf *config.ConfigCtx, c *envoy_config
d = bind.StreamServiceConfig{
DisconnectOnClose: true,
Listener: bind.ListenerStreamListenConfigConfig{
Network: bind.ListenerStreamListenConfigListenerNetworkEnum(network),
Network: bind.ListenerStreamListenConfigNetworkEnum(network),
Address: address,
Virtual: c.DeprecatedV1 != nil && !c.DeprecatedV1.BindToPort.GetValue(),
},
Expand Down
2 changes: 1 addition & 1 deletion convert/xds_config_route_v3_routeaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func Convert_config_route_v3_RouteAction(conf *config.ConfigCtx, c *envoy_config

case *envoy_config_route_v3.RouteAction_WeightedClusters:
d := bind.LbNetHTTPHandlerConfig{
Policy: bind.LbNetHTTPHandlerLoadBalancePolicyEnumEnumRoundRobin,
Policy: bind.RoundRobinBalancePolicy{},
}
for _, weighted := range s.WeightedClusters.Clusters {
w, err := Convert_config_route_v3_WeightedCluster_ClusterWeight(conf, weighted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Convert_extensions_filters_network_tcp_proxy_v3_TcpProxy(conf *config.Confi
d = dialers[0].Dialer
default:
d = bind.LbStreamDialerConfig{
Policy: bind.LbStreamDialerLoadBalancePolicyEnumEnumRoundRobin,
Policy: bind.RoundRobinBalancePolicy{},
Dialers: dialers,
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ replace (
require (
github.com/envoyproxy/go-control-plane v0.9.8-0.20201019204000-12785f608982
github.com/golang/protobuf v1.4.3
github.com/pipeproxy/pipe v0.4.15
github.com/pipeproxy/pipe v0.5.1
github.com/spf13/cobra v1.1.1
github.com/wzshiming/gotype v0.6.3
github.com/wzshiming/notify v0.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,8 @@ github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4/v3 v3.3.2 h1:QTUOCbMNDbK4PYtkuHyOBd28C0UhPBw3T4OH4WpFDik=
github.com/pierrec/lz4/v3 v3.3.2/go.mod h1:280XNCGS8jAcG++AHdd6SeWnzyJ1w9oow2vbORyey8Q=
github.com/pipeproxy/pipe v0.4.15 h1:/pp61UdVIe5GgVHaY1jJT6edrnrjE5NmBT1feNFkMno=
github.com/pipeproxy/pipe v0.4.15/go.mod h1:fVvEupWbJ2ihcyWk/iSLYtBz/9wlZnshG8dWTCnlQ8k=
github.com/pipeproxy/pipe v0.5.1 h1:C4xZPNwbMdnNdV5tYdptDxinHGm9kD+uG+mRC79iSXY=
github.com/pipeproxy/pipe v0.5.1/go.mod h1:fVvEupWbJ2ihcyWk/iSLYtBz/9wlZnshG8dWTCnlQ8k=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
6 changes: 5 additions & 1 deletion internal/cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var (
podNameVar = env.RegisterStringVar("POD_NAME", "", "")
podNamespaceVar = env.RegisterStringVar("POD_NAMESPACE", "", "")
clusterIDVar = env.RegisterStringVar("ISTIO_META_CLUSTER_ID", "", "")
nodeID = env.RegisterStringVar("NODE_ID", "", "")

url = env.RegisterStringVar("ISTIOD_ADDRESS", "istiod.istio-system.svc:15010", "")

Expand Down Expand Up @@ -110,7 +111,10 @@ var (
metadataJSON := string(metadataBytes)
log.Println("xds server", url.Get())
log.Println("metadata", metadataJSON)
nodeId := fmt.Sprintf("%s~%s~%s.%s~%s", proxyType, podIP, podName, podNamespace, DNSDomain)
nodeId := nodeID.Get()
if nodeId == "" {
nodeId = fmt.Sprintf("%s~%s~%s.%s~%s", proxyType, podIP, podName, podNamespace, DNSDomain)
}
log.Println("node id", nodeId)

notify.OnSlice([]os.Signal{syscall.SIGQUIT, syscall.SIGINT, syscall.SIGTERM}, cancel)
Expand Down

0 comments on commit 1c8ca7e

Please sign in to comment.