mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
use subpath for coredns only for default repository
This commit is contained in:
parent
5edccec32b
commit
97ba90cbfb
@ -326,7 +326,7 @@ const (
|
|||||||
CoreDNSDeploymentName = "coredns"
|
CoreDNSDeploymentName = "coredns"
|
||||||
|
|
||||||
// CoreDNSImageName specifies the name of the image for CoreDNS add-on
|
// CoreDNSImageName specifies the name of the image for CoreDNS add-on
|
||||||
CoreDNSImageName = "coredns/coredns"
|
CoreDNSImageName = "coredns"
|
||||||
|
|
||||||
// CoreDNSVersion is the version of CoreDNS to be deployed if it is used
|
// CoreDNSVersion is the version of CoreDNS to be deployed if it is used
|
||||||
CoreDNSVersion = "v1.8.0"
|
CoreDNSVersion = "v1.8.0"
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
|
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
|
||||||
)
|
)
|
||||||
@ -46,6 +47,10 @@ func GetDNSImage(cfg *kubeadmapi.ClusterConfiguration) string {
|
|||||||
if cfg.DNS.ImageRepository != "" {
|
if cfg.DNS.ImageRepository != "" {
|
||||||
dnsImageRepository = cfg.DNS.ImageRepository
|
dnsImageRepository = cfg.DNS.ImageRepository
|
||||||
}
|
}
|
||||||
|
// Handle the renaming of the official image from "k8s.gcr.io/coredns" to "k8s.gcr.io/coredns/coredns
|
||||||
|
if dnsImageRepository == kubeadmapiv1beta2.DefaultImageRepository {
|
||||||
|
dnsImageRepository = fmt.Sprintf("%s/coredns", dnsImageRepository)
|
||||||
|
}
|
||||||
// DNS uses an imageTag that corresponds to the DNS version matching the Kubernetes version
|
// DNS uses an imageTag that corresponds to the DNS version matching the Kubernetes version
|
||||||
dnsImageTag := constants.GetDNSVersion(cfg.DNS.Type)
|
dnsImageTag := constants.GetDNSVersion(cfg.DNS.Type)
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
|
kubeadmapiv1beta2 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta2"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -229,3 +230,52 @@ func TestGetAllImages(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetDNSImage(t *testing.T) {
|
||||||
|
var tests = []struct {
|
||||||
|
expected string
|
||||||
|
cfg *kubeadmapi.ClusterConfiguration
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
expected: "foo.io/coredns:v1.8.0",
|
||||||
|
cfg: &kubeadmapi.ClusterConfiguration{
|
||||||
|
ImageRepository: "foo.io",
|
||||||
|
DNS: kubeadmapi.DNS{
|
||||||
|
Type: kubeadmapi.CoreDNS,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
expected: kubeadmapiv1beta2.DefaultImageRepository + "/coredns/coredns:v1.8.0",
|
||||||
|
cfg: &kubeadmapi.ClusterConfiguration{
|
||||||
|
ImageRepository: kubeadmapiv1beta2.DefaultImageRepository,
|
||||||
|
DNS: kubeadmapi.DNS{
|
||||||
|
Type: kubeadmapi.CoreDNS,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
expected: "foo.io/coredns/coredns:v1.8.0",
|
||||||
|
cfg: &kubeadmapi.ClusterConfiguration{
|
||||||
|
ImageRepository: "foo.io",
|
||||||
|
DNS: kubeadmapi.DNS{
|
||||||
|
Type: kubeadmapi.CoreDNS,
|
||||||
|
ImageMeta: kubeadmapi.ImageMeta{
|
||||||
|
ImageRepository: "foo.io/coredns",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
actual := GetDNSImage(test.cfg)
|
||||||
|
if actual != test.expected {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to GetDNSImage:\n\texpected: %s\n\t actual: %s",
|
||||||
|
test.expected,
|
||||||
|
actual,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user