-
Notifications
You must be signed in to change notification settings - Fork 362
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
feat: support ha mode for local registry #1901
Conversation
08cd5ca
to
b9f2f31
Compare
Please make sure it won't break backward compatibility and upgrade |
b9f2f31
to
1f70772
Compare
Codecov ReportBase: 21.11% // Head: 21.70% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1901 +/- ##
==========================================
+ Coverage 21.11% 21.70% +0.58%
==========================================
Files 74 78 +4
Lines 6762 7155 +393
==========================================
+ Hits 1428 1553 +125
- Misses 5148 5395 +247
- Partials 186 207 +21
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@@ -99,17 +95,17 @@ func NewApplyCmd() *cobra.Command { | |||
|
|||
if extension.Type == v12.AppInstaller { |
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.
How about extract a public method to determine if it is an app image?
|
||
logrus.Infof("start to apply with mode(%s)", common.ApplyModeLoadImage) | ||
deployHosts := infraDriver.GetHostIPListByRole(common.MASTER) | ||
master0 := deployHosts[0] |
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.
it will panic here if the length of deploy hosts is zero
cmd/sealer/cmd/utils/cluster.go
Outdated
} | ||
if _, ok := node.Labels["node-role.kubernetes.io/master"]; ok { |
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.
use MasterRoleLabel here
} | ||
|
||
func getNodeAddress(node corev1.Node) net.IP { | ||
if len(node.Status.Addresses) < 1 { |
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.
what will happen if len(node.Status.Addresses)==1?
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.
add comment here if the logic is right
cmd/sealer/cmd/cluster/run-app.go
Outdated
} | ||
|
||
func installApplication(appImageName string, launchCmds []string, extension v12.ImageExtension, | ||
infraDriver infradriver.InfraDriver, imageEngine imageengine.Interface) error { | ||
infraDriver infradriver.InfraDriver, imageEngine imageengine.Interface, createMode string) error { |
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.
installMode ?
cmd/sealer/cmd/cluster/run-app.go
Outdated
DeployHost: infraDriver.GetHostIPListByRole(common.MASTER)[0], | ||
Registry: config, | ||
if createMode == common.ApplyModeLoadImage { | ||
return loadImageMode(infraDriver, distributor) |
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.
loadImageMode
the function name should be a verb
cmd/sealer/cmd/cluster/run.go
Outdated
@@ -148,10 +152,9 @@ func NewRunCmd() *cobra.Command { | |||
return runCmd | |||
} | |||
|
|||
func createNewCluster(clusterImageName string, infraDriver infradriver.InfraDriver, imageEngine imageengine.Interface, cf clusterfile.Interface) error { | |||
func createNewCluster(clusterImageName string, infraDriver infradriver.InfraDriver, imageEngine imageengine.Interface, cf clusterfile.Interface, createMode string) error { |
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.
It looks like the clusterImageName
is unused
func loadImageMode(infraDriver infradriver.InfraDriver, distributor imagedistributor.Distributor) error { | ||
regConfig := infraDriver.GetClusterRegistryConfig() | ||
// only support load image to local registry at present | ||
if regConfig.LocalRegistry == nil { |
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.
add TODO here
pkg/infradriver/infradriver.go
Outdated
@@ -17,6 +17,8 @@ package infradriver | |||
import ( | |||
"net" | |||
|
|||
v2 "github.com/sealerio/sealer/types/api/v2" | |||
|
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.
unused blank
if err := checkAllHostsSameFamily(ret.hosts); err != nil { | ||
// check registry config is valid, | ||
// make sure external registry domain is valid | ||
if cluster.Spec.Registry.ExternalRegistry != nil { |
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.
in the future, we should not distinguish the local registry and external registry
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.
add TODO here
set non-ha mode as the default value for the local registry if we support config it, and then we will make sure it won't break backward compatibility and upgrade |
e7fbae0
to
31186ad
Compare
@@ -189,7 +189,9 @@ func NewKubeadmConfig(fromClusterFile KubeadmConfig, fromFile string, | |||
conf.APIServer.ExtraArgs[EtcdServers] = getEtcdEndpointsWithHTTPSPrefix(masters) | |||
conf.IPVS.ExcludeCIDRs = append(conf.KubeProxyConfiguration.IPVS.ExcludeCIDRs, fmt.Sprintf("%s/32", apiServerVIP)) | |||
conf.KubeletConfiguration.CgroupDriver = cgroupDriver | |||
|
|||
// set cluster image repo,kubeadm will pull container image from this registry. | |||
conf.ClusterConfiguration.ImageRepository = imageRepo |
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.
@VinceCui , here will affects the configuration of the ackd image. pls review.
@@ -326,7 +249,7 @@ func (c *localSingletonConfigurator) configureAccessCredential(hosts []net.IP) e | |||
return nil | |||
} | |||
|
|||
func (c *localSingletonConfigurator) copy2RemoteHosts(src, dest string, hosts []net.IP) error { | |||
func (c *localConfigurator) copy2RemoteHosts(src, dest string, hosts []net.IP) error { |
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.
this maybe a common func of infraDriver.
} | ||
} | ||
|
||
type localInstaller struct { |
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.
localInstaller and local registry configurator, difference? why need them both?
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.
Installer provide registry lifecycle management local registry will implement it. Configurator provide registry configuration management, local registry and external registry will implement it.
types/api/v2/cluster_types.go
Outdated
// if LocalRegistry is not specified, default value is true. | ||
HaMode bool `json:"ha_mode,omitempty"` | ||
// InsecureMode indicated that whether the local registry is exposed in HTTPS. | ||
// if true sealer will generate default ssl cert. |
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.
if true, sealer will NOT generate default ssl cert.
fe86cf7
to
bfbfaf3
Compare
update reviews update reviews
bfbfaf3
to
2a2cca2
Compare
LGTM |
LGTM |
* feat: support recover master0 * feat: support ha mode for local registry update reviews update reviews
Describe what this PR does / why we need it
Master0 plays an important role in sealer cluster, it hosts many important components such as sealer builtin registry,
application images launched history and others cluster configuration files. if the master0 node is abnormal, a highly
available solution is required to recover on other master nodes.
Does this pull request fix one issue?
Describe how you did it
ha mode
as default value for local registry.Describe how to verify it
if not set any registry configs, sealer will use non ha mode as default.
if set: below is my test clusterfile, this will prepare to deploy registry service on three nodes(172.16.26.162,172.16.26.163,172.16.26.164) with customized domain port, basic auth and insure mode options.
Special notes for reviews