mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-12-24 11:51:13 +08:00
hotfix: envoy control-plane detect enable ipv6 or not to add route (#389)
This commit is contained in:
@@ -42,7 +42,7 @@ type Rule struct {
|
||||
PortMap map[int32]int32
|
||||
}
|
||||
|
||||
func (a *Virtual) To() (
|
||||
func (a *Virtual) To(enableIPv6 bool) (
|
||||
listeners []types.Resource,
|
||||
clusters []types.Resource,
|
||||
routes []types.Resource,
|
||||
@@ -56,7 +56,13 @@ func (a *Virtual) To() (
|
||||
|
||||
var rr []*route.Route
|
||||
for _, rule := range a.Rules {
|
||||
for _, ip := range []string{rule.LocalTunIPv4, rule.LocalTunIPv6} {
|
||||
var ips []string
|
||||
if enableIPv6 {
|
||||
ips = []string{rule.LocalTunIPv4, rule.LocalTunIPv6}
|
||||
} else {
|
||||
ips = []string{rule.LocalTunIPv4}
|
||||
}
|
||||
for _, ip := range ips {
|
||||
clusterName := fmt.Sprintf("%s_%v", ip, rule.PortMap[port.ContainerPort])
|
||||
clusters = append(clusters, ToCluster(clusterName))
|
||||
endpoints = append(endpoints, ToEndPoint(clusterName, ip, rule.PortMap[port.ContainerPort]))
|
||||
|
||||
@@ -17,6 +17,8 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
utilcache "k8s.io/apimachinery/pkg/util/cache"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/wencaiwulue/kubevpn/v2/pkg/util"
|
||||
)
|
||||
|
||||
type Processor struct {
|
||||
@@ -50,6 +52,7 @@ func (p *Processor) ProcessFile(file NotifyMessage) error {
|
||||
p.logger.Errorf("error parsing yaml file: %+v", err)
|
||||
return err
|
||||
}
|
||||
enableIPv6, _ := util.DetectSupportIPv6()
|
||||
for _, config := range configList {
|
||||
if len(config.Uid) == 0 {
|
||||
continue
|
||||
@@ -62,7 +65,7 @@ func (p *Processor) ProcessFile(file NotifyMessage) error {
|
||||
}
|
||||
p.logger.Debugf("update config, version %d, config %v", p.version, config)
|
||||
|
||||
listeners, clusters, routes, endpoints := config.To()
|
||||
listeners, clusters, routes, endpoints := config.To(enableIPv6)
|
||||
resources := map[resource.Type][]types.Resource{
|
||||
resource.ListenerType: listeners, // listeners
|
||||
resource.RouteType: routes, // routes
|
||||
|
||||
Reference in New Issue
Block a user