-
Notifications
You must be signed in to change notification settings - Fork 408
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
change yurthub's protocol from http to https #368
Changes from 5 commits
2a9460f
0a0e313
4775c54
a3dd98b
2b53769
f2a30e4
229bb3f
55b3ea2
c516d4d
d04af20
8b8f874
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,26 +33,30 @@ import ( | |
|
||
// YurtHubConfiguration represents configuration of yurthub | ||
type YurtHubConfiguration struct { | ||
LBMode string | ||
RemoteServers []*url.URL | ||
YurtHubServerAddr string | ||
YurtHubProxyServerAddr string | ||
YurtHubProxyServerDummyAddr string | ||
GCFrequency int | ||
CertMgrMode string | ||
NodeName string | ||
HeartbeatFailedRetry int | ||
HeartbeatHealthyThreshold int | ||
HeartbeatTimeoutSeconds int | ||
MaxRequestInFlight int | ||
JoinToken string | ||
RootDir string | ||
EnableProfiling bool | ||
EnableDummyIf bool | ||
EnableIptables bool | ||
HubAgentDummyIfName string | ||
StorageWrapper cachemanager.StorageWrapper | ||
SerializerManager *serializer.SerializerManager | ||
LBMode string | ||
RemoteServers []*url.URL | ||
YurtHubServerAddr string | ||
YurtHubProxyServerAddr string | ||
YurtHubProxyServerSecureAddr string | ||
YurtHubProxyServerDummyAddr string | ||
GCFrequency int | ||
CertMgrMode string | ||
NodeName string | ||
HeartbeatFailedRetry int | ||
HeartbeatHealthyThreshold int | ||
HeartbeatTimeoutSeconds int | ||
MaxRequestInFlight int | ||
JoinToken string | ||
RootDir string | ||
EnableProfiling bool | ||
EnableDummyIf bool | ||
EnableIptables bool | ||
HubAgentDummyIfName string | ||
StorageWrapper cachemanager.StorageWrapper | ||
SerializerManager *serializer.SerializerManager | ||
CAFile string | ||
CertFile string | ||
KeyFile string | ||
} | ||
|
||
// Complete converts *options.YurtHubOptions to *YurtHubConfiguration | ||
|
@@ -72,28 +76,33 @@ func Complete(options *options.YurtHubOptions) (*YurtHubConfiguration, error) { | |
|
||
hubServerAddr := net.JoinHostPort(options.YurtHubHost, options.YurtHubPort) | ||
proxyServerAddr := net.JoinHostPort(options.YurtHubHost, options.YurtHubProxyPort) | ||
proxySecureServerAddr := net.JoinHostPort(options.YurtHubHost, options.YurtHubProxySecurePort) | ||
proxyServerDummyAddr := net.JoinHostPort(options.HubAgentDummyIfIP, options.YurtHubProxyPort) | ||
cfg := &YurtHubConfiguration{ | ||
LBMode: options.LBMode, | ||
RemoteServers: us, | ||
YurtHubServerAddr: hubServerAddr, | ||
YurtHubProxyServerAddr: proxyServerAddr, | ||
YurtHubProxyServerDummyAddr: proxyServerDummyAddr, | ||
GCFrequency: options.GCFrequency, | ||
CertMgrMode: options.CertMgrMode, | ||
NodeName: options.NodeName, | ||
HeartbeatFailedRetry: options.HeartbeatFailedRetry, | ||
HeartbeatHealthyThreshold: options.HeartbeatHealthyThreshold, | ||
HeartbeatTimeoutSeconds: options.HeartbeatTimeoutSeconds, | ||
MaxRequestInFlight: options.MaxRequestInFlight, | ||
JoinToken: options.JoinToken, | ||
RootDir: options.RootDir, | ||
EnableProfiling: options.EnableProfiling, | ||
EnableDummyIf: options.EnableDummyIf, | ||
EnableIptables: options.EnableIptables, | ||
HubAgentDummyIfName: options.HubAgentDummyIfName, | ||
StorageWrapper: storageWrapper, | ||
SerializerManager: serializerManager, | ||
LBMode: options.LBMode, | ||
RemoteServers: us, | ||
YurtHubServerAddr: hubServerAddr, | ||
YurtHubProxyServerAddr: proxyServerAddr, | ||
YurtHubProxyServerSecureAddr: proxySecureServerAddr, | ||
YurtHubProxyServerDummyAddr: proxyServerDummyAddr, | ||
GCFrequency: options.GCFrequency, | ||
CertMgrMode: options.CertMgrMode, | ||
NodeName: options.NodeName, | ||
HeartbeatFailedRetry: options.HeartbeatFailedRetry, | ||
HeartbeatHealthyThreshold: options.HeartbeatHealthyThreshold, | ||
HeartbeatTimeoutSeconds: options.HeartbeatTimeoutSeconds, | ||
MaxRequestInFlight: options.MaxRequestInFlight, | ||
JoinToken: options.JoinToken, | ||
RootDir: options.RootDir, | ||
EnableProfiling: options.EnableProfiling, | ||
EnableDummyIf: options.EnableDummyIf, | ||
EnableIptables: options.EnableIptables, | ||
HubAgentDummyIfName: options.HubAgentDummyIfName, | ||
StorageWrapper: storageWrapper, | ||
SerializerManager: serializerManager, | ||
CAFile: options.CAFile, | ||
CertFile: options.CertFile, | ||
KeyFile: options.KeyFile, | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the establishment and configuration of TLS may be better done by yurthub, users do not need to pay attention to the underlying certificate configuration by default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a good idea. I will improve it later. |
||
|
||
return cfg, nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ type YurtHubOptions struct { | |
YurtHubHost string | ||
YurtHubPort string | ||
YurtHubProxyPort string | ||
YurtHubProxySecurePort string | ||
GCFrequency int | ||
CertMgrMode string | ||
NodeName string | ||
|
@@ -55,12 +56,16 @@ type YurtHubOptions struct { | |
HubAgentDummyIfIP string | ||
HubAgentDummyIfName string | ||
DiskCachePath string | ||
CAFile string | ||
CertFile string | ||
KeyFile string | ||
} | ||
|
||
// NewYurtHubOptions creates a new YurtHubOptions with a default config. | ||
func NewYurtHubOptions() *YurtHubOptions { | ||
o := &YurtHubOptions{ | ||
YurtHubHost: "127.0.0.1", | ||
YurtHubProxySecurePort: "10260", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe 10260 is used by k8s, how about 10268? |
||
YurtHubProxyPort: "10261", | ||
YurtHubPort: "10267", | ||
GCFrequency: 120, | ||
|
@@ -92,6 +97,18 @@ func ValidateOptions(options *YurtHubOptions) error { | |
return fmt.Errorf("server-address is empty") | ||
} | ||
|
||
if len(options.CAFile) == 0 { | ||
return fmt.Errorf("CA is empty") | ||
} | ||
|
||
if len(options.CertFile) == 0 { | ||
return fmt.Errorf("tls cert is empty") | ||
} | ||
|
||
if len(options.KeyFile) == 0 { | ||
return fmt.Errorf("tls key is empty") | ||
} | ||
|
||
if !util.IsSupportedLBMode(options.LBMode) { | ||
return fmt.Errorf("lb mode(%s) is not supported", options.LBMode) | ||
} | ||
|
@@ -112,6 +129,7 @@ func (o *YurtHubOptions) AddFlags(fs *pflag.FlagSet) { | |
fs.StringVar(&o.YurtHubHost, "bind-address", o.YurtHubHost, "the IP address on which to listen for the --serve-port port.") | ||
fs.StringVar(&o.YurtHubPort, "serve-port", o.YurtHubPort, "the port on which to serve HTTP requests(like profiling, metrics) for hub agent.") | ||
fs.StringVar(&o.YurtHubProxyPort, "proxy-port", o.YurtHubProxyPort, "the port on which to proxy HTTP requests to kube-apiserver") | ||
fs.StringVar(&o.YurtHubProxySecurePort, "proxy-secure-port", o.YurtHubProxySecurePort, "the port on which to proxy HTTPS requests to kube-apiserver") | ||
fs.StringVar(&o.ServerAddr, "server-addr", o.ServerAddr, "the address of Kubernetes kube-apiserver,the format is: \"server1,server2,...\"") | ||
fs.StringVar(&o.CertMgrMode, "cert-mgr-mode", o.CertMgrMode, "the cert manager mode, kubelet: use certificates that belongs to kubelet, hubself: auto generate client cert for hub agent.") | ||
fs.IntVar(&o.GCFrequency, "gc-frequency", o.GCFrequency, "the frequency to gc cache in storage(unit: minute).") | ||
|
@@ -130,6 +148,9 @@ func (o *YurtHubOptions) AddFlags(fs *pflag.FlagSet) { | |
fs.StringVar(&o.HubAgentDummyIfIP, "dummy-if-ip", o.HubAgentDummyIfIP, "the ip address of dummy interface that used for container connect hub agent(exclusive ips: 169.254.31.0/24, 169.254.1.1/32)") | ||
fs.StringVar(&o.HubAgentDummyIfName, "dummy-if-name", o.HubAgentDummyIfName, "the name of dummy interface that is used for hub agent") | ||
fs.StringVar(&o.DiskCachePath, "disk-cache-path", o.DiskCachePath, "the path for kubernetes to storage metadata") | ||
fs.StringVar(&o.CAFile, "ca-file", "", "the CA for yurthub to verify client") | ||
fs.StringVar(&o.CertFile, "tls-cert-file", "", "the tls cert of yurthub") | ||
fs.StringVar(&o.KeyFile, "tls-private-key-file", "", "the tls key of yurthub") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not convenient for user to setup server certifcates. I think Yurthub shoud generate server certificates by itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The latest code has been commited. Yurthub generated server certificates by itself. |
||
} | ||
|
||
// verifyDummyIP verify the specified ip is valid or not | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,7 +147,7 @@ func Run(cfg *config.YurtHubConfiguration, stopCh <-chan struct{}) error { | |
klog.Infof("%d. new %s server and begin to serve, dummy proxy server: %s", trace, projectinfo.GetHubName(), cfg.YurtHubProxyServerDummyAddr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add |
||
} | ||
|
||
klog.Infof("%d. new %s server and begin to serve, proxy server: %s, hub server: %s", trace, projectinfo.GetHubName(), cfg.YurtHubProxyServerAddr, cfg.YurtHubServerAddr) | ||
klog.Infof("%d. new %s server and begin to serve, proxy server: %s, secure proxy server: %s, hub server: %s", trace, projectinfo.GetHubName(), cfg.YurtHubProxyServerAddr, cfg.YurtHubProxyServerSecureAddr, cfg.YurtHubServerAddr) | ||
s, err := server.NewYurtHubServer(cfg, certManager, yurtProxyHandler) | ||
if err != nil { | ||
klog.Errorf("could not create hub server, %v", err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yurthub's https also need to listen on
HubAgentDummyIfIP
addressThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest code has been commited. Yurthub's https also listens on HubAgentDummyIfIP address