Skip to content

Commit

Permalink
fix(registry): registry dns support ha
Browse files Browse the repository at this point in the history
  • Loading branch information
wl-chen committed Apr 28, 2022
1 parent aec4502 commit b9daacc
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions cmd/tke-installer/app/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,11 @@ func (t *TKE) completeProviderConfigForRegistry() error {
}
c.Registry.Prefix = t.Para.Config.Registry.Prefix()

if t.Para.Config.Registry.TKERegistry != nil {
if t.Para.Config.Registry.TKERegistry != nil {
ip, err := utilnet.GetSourceIP(t.Para.Cluster.Spec.Machines[0].IP)
if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
ip = t.Para.Config.HA.VIP()
}
if err != nil {
return errors.Wrap(err, "get ip for registry error")
}
Expand Down Expand Up @@ -2414,14 +2417,20 @@ func (t *TKE) preparePushImagesToTKERegistry(ctx context.Context) error {
t.Para.Config.Registry.Domain(),
constants.DefaultTeantID + "." + t.Para.Config.Registry.Domain(),
}

ip := t.servers[0]
if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
ip = t.Para.Config.HA.VIP()
}

for _, domain := range domains {
localHosts := hosts.LocalHosts{Host: domain, File: "hosts"}
err := localHosts.Set(t.servers[0])
err := localHosts.Set(ip)
if err != nil {
return err
}
localHosts.File = "/app/hosts"
err = localHosts.Set(t.servers[0])
err = localHosts.Set(ip)
if err != nil {
return err
}
Expand Down Expand Up @@ -2786,6 +2795,11 @@ func (t *TKE) setGlobalClusterHosts(ctx context.Context) error {
t.Cluster.Spec.TenantID + "." + t.Para.Config.Registry.Domain(),
}

ip := t.Cluster.Spec.Machines[0].IP
if t.Para.Config.HA != nil && len(t.Para.Config.HA.VIP()) > 0 {
ip = t.Para.Config.HA.VIP()
}

for _, machine := range t.Cluster.Spec.Machines {
sshConfig := &ssh.Config{
User: machine.Username,
Expand All @@ -2801,7 +2815,7 @@ func (t *TKE) setGlobalClusterHosts(ctx context.Context) error {
}
for _, one := range domains {
remoteHosts := hosts.RemoteHosts{Host: one, SSH: s}
err := remoteHosts.Set(t.Cluster.Spec.Machines[0].IP)
err := remoteHosts.Set(ip)
if err != nil {
return err
}
Expand Down

0 comments on commit b9daacc

Please sign in to comment.