Skip to content

Commit

Permalink
add namespaceOverride support for privateRegistry
Browse files Browse the repository at this point in the history
remove namespaceOverride in v1alpha1
  • Loading branch information
life- committed Feb 10, 2022
1 parent 9d4f7c2 commit be8cda6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apis/kubekey/v1alpha2/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package v1alpha2

import (
"fmt"
"github.com/kubesphere/kubekey/pkg/core/connector"
"regexp"
"strconv"
"strings"

"github.com/kubesphere/kubekey/pkg/core/connector"

"github.com/kubesphere/kubekey/pkg/core/logger"
"github.com/kubesphere/kubekey/pkg/core/util"
"github.com/pkg/errors"
Expand Down Expand Up @@ -173,6 +174,7 @@ type RegistryConfig struct {
RegistryMirrors []string `yaml:"registryMirrors" json:"registryMirrors,omitempty"`
InsecureRegistries []string `yaml:"insecureRegistries" json:"insecureRegistries,omitempty"`
PrivateRegistry string `yaml:"privateRegistry" json:"privateRegistry,omitempty"`
NamespaceOverride string `yaml:"namespaceOverride" json:"namespaceOverride,omitempty"`
PlainHTTP bool `yaml:"plainHTTP" json:"plainHTTP,omitempty"`
Auths runtime.RawExtension `yaml:"auths" json:"auths,omitempty"`
}
Expand Down
1 change: 1 addition & 0 deletions docs/config-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ spec:
registryMirrors: []
insecureRegistries: []
privateRegistry: ""
namespaceOverride: ""
auths: # if docker add by `docker login`, if containerd append to `/etc/containerd/config.toml`
"registry-1.docker.io":
username : "xxx"
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/templates/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
package templates

import (
"text/template"

kubekeyapiv1alpha2 "github.com/kubesphere/kubekey/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/pkg/core/util"
"github.com/lithammer/dedent"
"text/template"
)

// Cluster defines the template of cluster configuration file default.
Expand Down Expand Up @@ -62,6 +63,7 @@ spec:
registry:
plainHTTP: false
privateRegistry: ""
namespaceOverride: ""
registryMirrors: []
insecureRegistries: []
addons: []
Expand Down
10 changes: 7 additions & 3 deletions pkg/images/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
package images

import (
"io/ioutil"
"path/filepath"
"strings"

kubekeyv1alpha2 "github.com/kubesphere/kubekey/apis/kubekey/v1alpha2"
"github.com/kubesphere/kubekey/pkg/common"
"github.com/kubesphere/kubekey/pkg/core/connector"
"github.com/kubesphere/kubekey/pkg/core/logger"
"github.com/pkg/errors"
"io/ioutil"
versionutil "k8s.io/apimachinery/pkg/util/version"
"path/filepath"
"strings"
)

type PullImage struct {
Expand Down Expand Up @@ -127,6 +128,9 @@ func GetImage(runtime connector.ModuleRuntime, kubeConf *common.KubeConf, name s
}

image = ImageList[name]
if kubeConf.Cluster.Registry.NamespaceOverride != "" {
image.NamespaceOverride = kubeConf.Cluster.Registry.NamespaceOverride
}
return image
}

Expand Down

0 comments on commit be8cda6

Please sign in to comment.