Skip to content

Commit

Permalink
Merge pull request #2105 from pixiake/registry
Browse files Browse the repository at this point in the history
refine installition of registry logic
  • Loading branch information
ks-ci-bot committed Jan 22, 2024
2 parents e0c9de9 + 9e27bd3 commit a54877c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/kk/pkg/bootstrap/registry/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (g *GenerateCerts) Execute(runtime connector.Runtime) error {

var altName cert.AltNames

dnsList := []string{"localhost", RegistryCertificateBaseName}
dnsList := []string{"localhost", g.KubeConf.Cluster.Registry.PrivateRegistry}
ipList := []net.IP{net.IPv4(127, 0, 0, 1), net.IPv6loopback}

for _, h := range runtime.GetHostsByRole(common.Registry) {
Expand Down
21 changes: 14 additions & 7 deletions cmd/kk/pkg/bootstrap/registry/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package registry

import (
"fmt"
"path/filepath"
"strings"

"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/bootstrap/registry/templates"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/action"
"github.com/kubesphere/kubekey/v3/cmd/kk/pkg/core/util"
"path/filepath"
"strings"

"github.com/pkg/errors"

Expand Down Expand Up @@ -220,15 +221,21 @@ type GenerateHarborConfig struct {
}

func (g *GenerateHarborConfig) Execute(runtime connector.Runtime) error {
host := runtime.RemoteHost()
registryDomain := g.KubeConf.Cluster.Registry.PrivateRegistry

if g.KubeConf.Cluster.Registry.Type == "harbor-ha" {
host := runtime.RemoteHost()
registryDomain = host.GetName()
}

templateAction := action.Template{
Template: templates.HarborConfigTempl,
Dst: "/opt/harbor/harbor.yml",
Data: util.Data{
"Domain": host.GetName(),
"Certificate": fmt.Sprintf("%s.pem", RegistryCertificateBaseName),
"Key": fmt.Sprintf("%s-key.pem", RegistryCertificateBaseName),
"Password": templates.Password(g.KubeConf, RegistryCertificateBaseName),
"Domain": registryDomain,
"Certificate": fmt.Sprintf("%s.pem", g.KubeConf.Cluster.Registry.PrivateRegistry),
"Key": fmt.Sprintf("%s-key.pem", g.KubeConf.Cluster.Registry.PrivateRegistry),
"Password": templates.Password(g.KubeConf, g.KubeConf.Cluster.Registry.PrivateRegistry),
},
}
templateAction.Init(nil, nil)
Expand Down

0 comments on commit a54877c

Please sign in to comment.