mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #64881 from chuckha/ci-cross
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Use repo prefix when generating image names CI defines its own custom repository. The function responsible for listing all images now takes this into account. Closes kubernetes/kubeadm#901 Signed-off-by: Chuck Ha <ha.chuck@gmail.com> **What this PR does / why we need it**: This fixes ci-cross. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes/kubeadm#901 **Special notes for your reviewer**: ```release-note NONE ```
This commit is contained in:
commit
16921ae7a8
@ -27,7 +27,10 @@ go_test(
|
|||||||
name = "go_default_test",
|
name = "go_default_test",
|
||||||
srcs = ["images_test.go"],
|
srcs = ["images_test.go"],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = ["//cmd/kubeadm/app/constants:go_default_library"],
|
deps = [
|
||||||
|
"//cmd/kubeadm/app/apis/kubeadm:go_default_library",
|
||||||
|
"//cmd/kubeadm/app/constants:go_default_library",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
|
@ -47,11 +47,14 @@ func GetCoreImage(image, repoPrefix, k8sVersion, overrideImage string) string {
|
|||||||
|
|
||||||
// GetAllImages returns a list of container images kubeadm expects to use on a control plane node
|
// GetAllImages returns a list of container images kubeadm expects to use on a control plane node
|
||||||
func GetAllImages(cfg *kubeadmapi.MasterConfiguration) []string {
|
func GetAllImages(cfg *kubeadmapi.MasterConfiguration) []string {
|
||||||
|
repoPrefix := cfg.GetControlPlaneImageRepository()
|
||||||
imgs := []string{}
|
imgs := []string{}
|
||||||
imgs = append(imgs, GetCoreImage(constants.KubeAPIServer, cfg.ImageRepository, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
imgs = append(imgs, GetCoreImage(constants.KubeAPIServer, repoPrefix, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
||||||
imgs = append(imgs, GetCoreImage(constants.KubeControllerManager, cfg.ImageRepository, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
imgs = append(imgs, GetCoreImage(constants.KubeControllerManager, repoPrefix, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
||||||
imgs = append(imgs, GetCoreImage(constants.KubeScheduler, cfg.ImageRepository, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
imgs = append(imgs, GetCoreImage(constants.KubeScheduler, repoPrefix, cfg.KubernetesVersion, cfg.UnifiedControlPlaneImage))
|
||||||
imgs = append(imgs, fmt.Sprintf("%v/%v-%v:%v", cfg.ImageRepository, constants.KubeProxy, runtime.GOARCH, kubeadmutil.KubernetesVersionToImageTag(cfg.KubernetesVersion)))
|
imgs = append(imgs, fmt.Sprintf("%v/%v-%v:%v", repoPrefix, constants.KubeProxy, runtime.GOARCH, kubeadmutil.KubernetesVersionToImageTag(cfg.KubernetesVersion)))
|
||||||
|
|
||||||
|
// pause, etcd and kube-dns are not available on the ci image repository so use the default image repository.
|
||||||
imgs = append(imgs, fmt.Sprintf("%v/pause-%v:%v", cfg.ImageRepository, runtime.GOARCH, "3.1"))
|
imgs = append(imgs, fmt.Sprintf("%v/pause-%v:%v", cfg.ImageRepository, runtime.GOARCH, "3.1"))
|
||||||
|
|
||||||
// if etcd is not external then add the image as it will be required
|
// if etcd is not external then add the image as it will be required
|
||||||
|
@ -19,8 +19,10 @@ package images
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,3 +75,46 @@ func TestGetCoreImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetAllImages(t *testing.T) {
|
||||||
|
testcases := []struct {
|
||||||
|
name string
|
||||||
|
cfg *kubeadmapi.MasterConfiguration
|
||||||
|
expect string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "defined CIImageRepository",
|
||||||
|
cfg: &kubeadmapi.MasterConfiguration{
|
||||||
|
CIImageRepository: "test.repo",
|
||||||
|
},
|
||||||
|
expect: "test.repo",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "undefined CIImagerRepository should contain the default image prefix",
|
||||||
|
cfg: &kubeadmapi.MasterConfiguration{
|
||||||
|
ImageRepository: "real.repo",
|
||||||
|
},
|
||||||
|
expect: "real.repo",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "test that etcd is returned when it is not external",
|
||||||
|
cfg: &kubeadmapi.MasterConfiguration{
|
||||||
|
Etcd: kubeadmapi.Etcd{
|
||||||
|
Local: &kubeadmapi.LocalEtcd{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
expect: constants.Etcd,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testcases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
imgs := GetAllImages(tc.cfg)
|
||||||
|
for _, img := range imgs {
|
||||||
|
if strings.Contains(img, tc.expect) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Fatalf("did not find %q in %q", tc.expect, imgs)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user