Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add dns controller to sync cluster node dns records #270

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/yurt-tunnel-server/app/config/config.go
Original file line number Diff line number Diff line change
@@ -28,7 +28,9 @@ import (
type Config struct {
EgressSelectorEnabled bool
EnableIptables bool
EnableDNSController bool
IptablesSyncPeriod int
DNSSyncPeriod int
CertDNSNames []string
CertIPs []net.IP
ListenAddrForAgent string
8 changes: 8 additions & 0 deletions cmd/yurt-tunnel-server/app/options/options.go
Original file line number Diff line number Diff line change
@@ -43,8 +43,10 @@ type ServerOptions struct {
CertIPs string
Version bool
EnableIptables bool
EnableDNSController bool
EgressSelectorEnabled bool
IptablesSyncPeriod int
DNSSyncPeriod int
TunnelAgentConnectPort string
SecurePort string
InsecurePort string
@@ -59,7 +61,9 @@ func NewServerOptions() *ServerOptions {
BindAddr: "0.0.0.0",
InsecureBindAddr: "127.0.0.1",
EnableIptables: true,
EnableDNSController: true,
IptablesSyncPeriod: 60,
DNSSyncPeriod: 1800,
ServerCount: 1,
TunnelAgentConnectPort: constants.YurttunnelServerAgentPort,
SecurePort: constants.YurttunnelServerMasterPort,
@@ -88,8 +92,10 @@ func (o *ServerOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&o.CertDNSNames, "cert-dns-names", o.CertDNSNames, "DNS names that will be added into server's certificate. (e.g., dns1,dns2)")
fs.StringVar(&o.CertIPs, "cert-ips", o.CertIPs, "IPs that will be added into server's certificate. (e.g., ip1,ip2)")
fs.BoolVar(&o.EnableIptables, "enable-iptables", o.EnableIptables, "If allow iptable manager to set the dnat rule.")
fs.BoolVar(&o.EnableDNSController, "enable-dns-controller", o.EnableDNSController, "If allow DNS controller to set the dns rules.")
fs.BoolVar(&o.EgressSelectorEnabled, "egress-selector-enable", o.EgressSelectorEnabled, "If the apiserver egress selector has been enabled.")
fs.IntVar(&o.IptablesSyncPeriod, "iptables-sync-period", o.IptablesSyncPeriod, "The synchronization period of the iptable manager.")
fs.IntVar(&o.DNSSyncPeriod, "dns-sync-period", o.DNSSyncPeriod, "The synchronization period of the DNS controller.")
fs.IntVar(&o.ServerCount, "server-count", o.ServerCount, "The number of proxy server instances, should be 1 unless it is an HA server.")
fs.StringVar(&o.ProxyStrategy, "proxy-strategy", o.ProxyStrategy, "The strategy of proxying requests from tunnel server to agent.")
fs.StringVar(&o.TunnelAgentConnectPort, "tunnel-agent-connect-port", o.TunnelAgentConnectPort, "The port on which to serve tcp packets from tunnel agent")
@@ -103,7 +109,9 @@ func (o *ServerOptions) Config() (*config.Config, error) {
cfg := &config.Config{
EgressSelectorEnabled: o.EgressSelectorEnabled,
EnableIptables: o.EnableIptables,
EnableDNSController: o.EnableDNSController,
IptablesSyncPeriod: o.IptablesSyncPeriod,
DNSSyncPeriod: o.DNSSyncPeriod,
CertDNSNames: make([]string, 0),
CertIPs: make([]net.IP, 0),
ServerCount: o.ServerCount,
12 changes: 12 additions & 0 deletions cmd/yurt-tunnel-server/app/start.go
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import (
"github.com/openyurtio/openyurt/cmd/yurt-tunnel-server/app/options"
"github.com/openyurtio/openyurt/pkg/projectinfo"
"github.com/openyurtio/openyurt/pkg/yurttunnel/constants"
"github.com/openyurtio/openyurt/pkg/yurttunnel/dns"
"github.com/openyurtio/openyurt/pkg/yurttunnel/handlerwrapper/initializer"
"github.com/openyurtio/openyurt/pkg/yurttunnel/handlerwrapper/wraphandler"
"github.com/openyurtio/openyurt/pkg/yurttunnel/iptables"
@@ -73,6 +74,17 @@ func NewYurttunnelServerCommand(stopCh <-chan struct{}) *cobra.Command {

// run starts the yurttunel-server
func Run(cfg *config.CompletedConfig, stopCh <-chan struct{}) error {
// 0. start the DNS controller
if cfg.EnableDNSController {
dnsController, err := dns.NewCoreDNSRecordController(cfg.Client,
cfg.SharedInformerFactory,
cfg.ListenInsecureAddrForMaster,
cfg.DNSSyncPeriod)
if err != nil {
return fmt.Errorf("fail to create a new dnsController, %v", err)
}
go dnsController.Run(stopCh)
}
// 1. start the IP table manager
if cfg.EnableIptables {
iptablesMgr := iptables.NewIptablesManager(cfg.Client,
1 change: 1 addition & 0 deletions config/setup/yurt-tunnel-server.yaml
Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ spec:
- yurt-tunnel-server
args:
- --bind-address=$(NODE_IP)
- --insecure-bind-address=$(NODE_IP)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the tunnel-server listening address can be accessed by other cloud nodes in the cluster.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, tunnel-server need to listen on node ip for insecure requests.

- --proxy-strategy=destHost
- --v=2
env:
1 change: 1 addition & 0 deletions config/yaml-template/yurt-tunnel-server.yaml
Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ spec:
- __project_prefix__-tunnel-server
args:
- --bind-address=$(NODE_IP)
- --insecure-bind-address=$(NODE_IP)
- --proxy-strategy=destHost
- --v=2
env:
1 change: 1 addition & 0 deletions pkg/yurtctl/constants/yurt-tunnel-server-tmpl.go
Original file line number Diff line number Diff line change
@@ -152,6 +152,7 @@ spec:
- yurt-tunnel-server
args:
- --bind-address=$(NODE_IP)
- --insecure-bind-address=$(NODE_IP)
- --server-count=1
env:
- name: NODE_IP
Loading