Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual-cherry-pick-for-1.23: kubeadm: apply registry.k8s.io changes #113393

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
readonly KUBE_BUILD_IMAGE_REPO=kube-build
readonly KUBE_BUILD_IMAGE_CROSS_TAG="$(cat "${KUBE_ROOT}/build/build-image/cross/VERSION")"

readonly KUBE_DOCKER_REGISTRY="${KUBE_DOCKER_REGISTRY:-k8s.gcr.io}"
readonly KUBE_BASE_IMAGE_REGISTRY="${KUBE_BASE_IMAGE_REGISTRY:-k8s.gcr.io/build-image}"
readonly KUBE_DOCKER_REGISTRY="${KUBE_DOCKER_REGISTRY:-registry.k8s.io}"
readonly KUBE_BASE_IMAGE_REGISTRY="${KUBE_BASE_IMAGE_REGISTRY:-registry.k8s.io/build-image}"

# This version number is used to cause everyone to rebuild their data containers
# and build image. This is especially useful for automated build systems like
Expand Down
6 changes: 5 additions & 1 deletion build/dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ dependencies:
- path: build/pause/Makefile
match: TAG\s*\?=

- name: "k8s.gcr.io/pause: dependents"
- name: "registry.k8s.io/pause: dependents"
version: 3.6
refPaths:
- path: cmd/kubeadm/app/constants/constants.go
Expand All @@ -168,6 +168,10 @@ dependencies:
match: validTmplOut\s+=
- path: cmd/kubeadm/app/util/template_test.go
match: doNothing\s+=

- name: "k8s.gcr.io/pause: dependents"
version: 3.6
refPaths:
- path: cmd/kubelet/app/options/container_runtime.go
match: defaultPodSandboxImageVersion\s+=
- path: hack/testdata/pod-with-precision.json
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/apis/kubeadm/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type ClusterConfiguration struct {
CertificatesDir string

// ImageRepository sets the container registry to pull images from.
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
// will be used for all the other images.
ImageRepository string

Expand Down
3 changes: 2 additions & 1 deletion cmd/kubeadm/app/apis/kubeadm/v1beta2/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const (
// DefaultCertificatesDir defines default certificate directory
DefaultCertificatesDir = "/etc/kubernetes/pki"
// DefaultImageRepository defines default image registry
DefaultImageRepository = "k8s.gcr.io"
// (previously this defaulted to k8s.gcr.io)
DefaultImageRepository = "registry.k8s.io"
// DefaultManifestsDir defines default manifests directory
DefaultManifestsDir = "/etc/kubernetes/manifests"
// DefaultClusterName defines the default cluster name
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/apis/kubeadm/v1beta2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ limitations under the License.
// etcd:
// # one of local or external
// local:
// imageRepository: "k8s.gcr.io"
// imageRepository: "registry.k8s.io"
// imageTag: "3.2.24"
// dataDir: "/var/lib/etcd"
// extraArgs:
Expand Down Expand Up @@ -240,7 +240,7 @@ limitations under the License.
// readOnly: false
// pathType: File
// certificatesDir: "/etc/kubernetes/pki"
// imageRepository: "k8s.gcr.io"
// imageRepository: "registry.k8s.io"
// useHyperKubeImage: false
// clusterName: "example-cluster"
// ---
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/apis/kubeadm/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ type ClusterConfiguration struct {
CertificatesDir string `json:"certificatesDir,omitempty"`

// ImageRepository sets the container registry to pull images from.
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
// will be used for all the other images.
ImageRepository string `json:"imageRepository,omitempty"`

Expand Down
3 changes: 2 additions & 1 deletion cmd/kubeadm/app/apis/kubeadm/v1beta3/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const (
// DefaultCertificatesDir defines default certificate directory
DefaultCertificatesDir = "/etc/kubernetes/pki"
// DefaultImageRepository defines default image registry
DefaultImageRepository = "k8s.gcr.io"
// (previously this defaulted to k8s.gcr.io)
DefaultImageRepository = "registry.k8s.io"
// DefaultManifestsDir defines default manifests directory
DefaultManifestsDir = "/etc/kubernetes/manifests"
// DefaultClusterName defines the default cluster name
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/apis/kubeadm/v1beta3/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ limitations under the License.
// etcd:
// # one of local or external
// local:
// imageRepository: "k8s.gcr.io"
// imageRepository: "registry.k8s.io"
// imageTag: "3.2.24"
// dataDir: "/var/lib/etcd"
// extraArgs:
Expand Down Expand Up @@ -249,7 +249,7 @@ limitations under the License.
// readOnly: false
// pathType: File
// certificatesDir: "/etc/kubernetes/pki"
// imageRepository: "k8s.gcr.io"
// imageRepository: "registry.k8s.io"
// clusterName: "example-cluster"
// ---
// apiVersion: kubelet.config.k8s.io/v1beta1
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/apis/kubeadm/v1beta3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ type ClusterConfiguration struct {
CertificatesDir string `json:"certificatesDir,omitempty"`

// ImageRepository sets the container registry to pull images from.
// If empty, `k8s.gcr.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `k8s.gcr.io`
// If empty, `registry.k8s.io` will be used by default; in case of kubernetes version is a CI build (kubernetes version starts with `ci/`)
// `gcr.io/k8s-staging-ci-images` will be used as a default for control plane components and for kube-proxy, while `registry.k8s.io`
// will be used for all the other images.
// +optional
ImageRepository string `json:"imageRepository,omitempty"`
Expand Down
60 changes: 30 additions & 30 deletions cmd/kubeadm/app/cmd/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,13 @@ func TestConfigImagesListOutput(t *testing.T) {
KubernetesVersion: dummyKubernetesVersionStr,
},
outputFormat: "text",
expectedOutput: `k8s.gcr.io/kube-apiserver:{{.KubeVersion}}
k8s.gcr.io/kube-controller-manager:{{.KubeVersion}}
k8s.gcr.io/kube-scheduler:{{.KubeVersion}}
k8s.gcr.io/kube-proxy:{{.KubeVersion}}
k8s.gcr.io/pause:{{.PauseVersion}}
k8s.gcr.io/etcd:{{.EtcdVersion}}
k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
expectedOutput: `registry.k8s.io/kube-apiserver:{{.KubeVersion}}
registry.k8s.io/kube-controller-manager:{{.KubeVersion}}
registry.k8s.io/kube-scheduler:{{.KubeVersion}}
registry.k8s.io/kube-proxy:{{.KubeVersion}}
registry.k8s.io/pause:{{.PauseVersion}}
registry.k8s.io/etcd:{{.EtcdVersion}}
registry.k8s.io/coredns/coredns:{{.CoreDNSVersion}}
`,
},
{
Expand All @@ -255,13 +255,13 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
"kind": "Images",
"apiVersion": "output.kubeadm.k8s.io/v1alpha2",
"images": [
"k8s.gcr.io/kube-apiserver:{{.KubeVersion}}",
"k8s.gcr.io/kube-controller-manager:{{.KubeVersion}}",
"k8s.gcr.io/kube-scheduler:{{.KubeVersion}}",
"k8s.gcr.io/kube-proxy:{{.KubeVersion}}",
"k8s.gcr.io/pause:{{.PauseVersion}}",
"k8s.gcr.io/etcd:{{.EtcdVersion}}",
"k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}"
"registry.k8s.io/kube-apiserver:{{.KubeVersion}}",
"registry.k8s.io/kube-controller-manager:{{.KubeVersion}}",
"registry.k8s.io/kube-scheduler:{{.KubeVersion}}",
"registry.k8s.io/kube-proxy:{{.KubeVersion}}",
"registry.k8s.io/pause:{{.PauseVersion}}",
"registry.k8s.io/etcd:{{.EtcdVersion}}",
"registry.k8s.io/coredns/coredns:{{.CoreDNSVersion}}"
]
}
`,
Expand All @@ -274,13 +274,13 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
outputFormat: "yaml",
expectedOutput: `apiVersion: output.kubeadm.k8s.io/v1alpha2
images:
- k8s.gcr.io/kube-apiserver:{{.KubeVersion}}
- k8s.gcr.io/kube-controller-manager:{{.KubeVersion}}
- k8s.gcr.io/kube-scheduler:{{.KubeVersion}}
- k8s.gcr.io/kube-proxy:{{.KubeVersion}}
- k8s.gcr.io/pause:{{.PauseVersion}}
- k8s.gcr.io/etcd:{{.EtcdVersion}}
- k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
- registry.k8s.io/kube-apiserver:{{.KubeVersion}}
- registry.k8s.io/kube-controller-manager:{{.KubeVersion}}
- registry.k8s.io/kube-scheduler:{{.KubeVersion}}
- registry.k8s.io/kube-proxy:{{.KubeVersion}}
- registry.k8s.io/pause:{{.PauseVersion}}
- registry.k8s.io/etcd:{{.EtcdVersion}}
- registry.k8s.io/coredns/coredns:{{.CoreDNSVersion}}
kind: Images
`,
},
Expand All @@ -290,13 +290,13 @@ kind: Images
KubernetesVersion: dummyKubernetesVersionStr,
},
outputFormat: `go-template={{range .images}}{{.}}{{"\n"}}{{end}}`,
expectedOutput: `k8s.gcr.io/kube-apiserver:{{.KubeVersion}}
k8s.gcr.io/kube-controller-manager:{{.KubeVersion}}
k8s.gcr.io/kube-scheduler:{{.KubeVersion}}
k8s.gcr.io/kube-proxy:{{.KubeVersion}}
k8s.gcr.io/pause:{{.PauseVersion}}
k8s.gcr.io/etcd:{{.EtcdVersion}}
k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
expectedOutput: `registry.k8s.io/kube-apiserver:{{.KubeVersion}}
registry.k8s.io/kube-controller-manager:{{.KubeVersion}}
registry.k8s.io/kube-scheduler:{{.KubeVersion}}
registry.k8s.io/kube-proxy:{{.KubeVersion}}
registry.k8s.io/pause:{{.PauseVersion}}
registry.k8s.io/etcd:{{.EtcdVersion}}
registry.k8s.io/coredns/coredns:{{.CoreDNSVersion}}
`,
},
{
Expand All @@ -305,8 +305,8 @@ k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}}
KubernetesVersion: dummyKubernetesVersionStr,
},
outputFormat: `jsonpath={range.images[*]}{@} {end}`,
expectedOutput: "k8s.gcr.io/kube-apiserver:{{.KubeVersion}} k8s.gcr.io/kube-controller-manager:{{.KubeVersion}} k8s.gcr.io/kube-scheduler:{{.KubeVersion}} " +
"k8s.gcr.io/kube-proxy:{{.KubeVersion}} k8s.gcr.io/pause:{{.PauseVersion}} k8s.gcr.io/etcd:{{.EtcdVersion}} k8s.gcr.io/coredns/coredns:{{.CoreDNSVersion}} ",
expectedOutput: "registry.k8s.io/kube-apiserver:{{.KubeVersion}} registry.k8s.io/kube-controller-manager:{{.KubeVersion}} registry.k8s.io/kube-scheduler:{{.KubeVersion}} " +
"registry.k8s.io/kube-proxy:{{.KubeVersion}} registry.k8s.io/pause:{{.PauseVersion}} registry.k8s.io/etcd:{{.EtcdVersion}} registry.k8s.io/coredns/coredns:{{.CoreDNSVersion}} ",
},
}

Expand Down
9 changes: 9 additions & 0 deletions cmd/kubeadm/app/cmd/upgrade/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/features"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/upgrade"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
"k8s.io/kubernetes/cmd/kubeadm/app/preflight"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
Expand Down Expand Up @@ -72,6 +73,14 @@ func loadConfig(cfgPath string, client clientset.Interface, skipComponentConfigs
// This is probably 90% of the time. So we handle it first.
if cfgPath == "" {
cfg, err := configutil.FetchInitConfigurationFromCluster(client, os.Stdout, logPrefix, false, skipComponentConfigs)
// In case we fetch a configuration from the cluster, mutate the ImageRepository field
// to be 'registry.k8s.io', if it was 'k8s.gcr.io'.
// https://github.com/kubernetes/kubeadm/issues/2671
if err == nil {
if err := uploadconfig.MutateImageRepository(cfg, client); err != nil {
return nil, false, err
}
}
return cfg, false, err
}

Expand Down
8 changes: 8 additions & 0 deletions cmd/kubeadm/app/cmd/upgrade/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
cmdutil "k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/controlplane"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
kubeadmutil "k8s.io/kubernetes/cmd/kubeadm/app/util"
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
kubeconfigutil "k8s.io/kubernetes/cmd/kubeadm/app/util/kubeconfig"
Expand Down Expand Up @@ -120,6 +121,13 @@ func runDiff(flags *diffFlags, args []string) error {
return errors.Wrapf(err, "couldn't create a Kubernetes client from file %q", flags.kubeConfigPath)
}
cfg, err = configutil.FetchInitConfigurationFromCluster(client, flags.out, "upgrade/diff", false, false)
// In case we fetch a configuration from the cluster, mutate the ImageRepository field
// to be 'registry.k8s.io', if it was 'k8s.gcr.io'. Don't mutate the in-cluster value by passing
// nil as the client field; this is done only on "apply".
// https://github.com/kubernetes/kubeadm/issues/2671
if err == nil {
_ = uploadconfig.MutateImageRepository(cfg, nil)
}
}
if err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions cmd/kubeadm/app/cmd/upgrade/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
phases "k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/upgrade/node"
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/phases/workflow"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
configutil "k8s.io/kubernetes/cmd/kubeadm/app/util/config"
)

Expand Down Expand Up @@ -142,6 +143,11 @@ func newNodeData(cmd *cobra.Command, args []string, options *nodeOptions) (*node
if err != nil {
return nil, errors.Wrap(err, "unable to fetch the kubeadm-config ConfigMap")
}
// In case we fetch a configuration from the cluster, mutate the ImageRepository field
// to be 'registry.k8s.io', if it was 'k8s.gcr.io'. Don't mutate the in-cluster value by passing
// nil as the client field; this is done only on "apply".
// https://github.com/kubernetes/kubeadm/issues/2671
_ = uploadconfig.MutateImageRepository(cfg, nil)

ignorePreflightErrorsSet, err := validation.ValidateIgnorePreflightErrors(options.ignorePreflightErrors, cfg.NodeRegistration.IgnorePreflightErrors)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/componentconfigs/fakeconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ var (
etcd:
local:
dataDir: /var/lib/etcd
imageRepository: k8s.gcr.io
imageRepository: registry.k8s.io
kind: ClusterConfiguration
kubernetesVersion: 1.2.3
networking:
Expand All @@ -234,7 +234,7 @@ var (
ClusterName: "LeCluster",
KubernetesVersion: "1.2.3",
CertificatesDir: "/etc/kubernetes/pki",
ImageRepository: "k8s.gcr.io",
ImageRepository: "registry.k8s.io",
Networking: kubeadmapiv1.Networking{
DNSDomain: "cluster.local",
ServiceSubnet: "10.96.0.0/12",
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func GetDNSImage(cfg *kubeadmapi.ClusterConfiguration) string {
if 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
// Handle the renaming of the official image from "registry.k8s.io/coredns" to "registry.k8s.io/coredns/coredns
if dnsImageRepository == kubeadmapiv1beta2.DefaultImageRepository {
dnsImageRepository = fmt.Sprintf("%s/coredns", dnsImageRepository)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/images/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
const (
testversion = "v10.1.2-alpha.1.100+0123456789abcdef+SOMETHING"
expected = "v10.1.2-alpha.1.100_0123456789abcdef_SOMETHING"
gcrPrefix = "k8s.gcr.io"
gcrPrefix = "registry.k8s.io"
)

func TestGetGenericImage(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/phases/kubelet/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ func TestBuildKubeletArgMap(t *testing.T) {
nodeRegOpts: &kubeadmapi.NodeRegistrationOptions{
CRISocket: "/var/run/dockershim.sock",
},
pauseImage: "k8s.gcr.io/pause:3.6",
pauseImage: "registry.k8s.io/pause:3.6",
},
expected: map[string]string{
"network-plugin": "cni",
"pod-infra-container-image": "k8s.gcr.io/pause:3.6",
"pod-infra-container-image": "registry.k8s.io/pause:3.6",
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kubeadm/app/phases/upgrade/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ metadata:
spec:
containers:
- name: etcd
image: k8s.gcr.io/etcd:` + fakeCurrentEtcdVersion
image: registry.k8s.io/etcd:` + fakeCurrentEtcdVersion

func getEtcdVersion(v *versionutil.Version) string {
etcdVer, _, _ := constants.EtcdSupportedVersion(constants.SupportedEtcdVersion, v.String())
Expand Down
4 changes: 2 additions & 2 deletions cmd/kubeadm/app/phases/upgrade/staticpods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ etcd:
local:
dataDir: %%s
image: ""
imageRepository: k8s.gcr.io
imageRepository: registry.k8s.io
kubernetesVersion: %%s
networking:
dnsDomain: cluster.local
Expand Down Expand Up @@ -998,7 +998,7 @@ metadata:
spec:
containers:
- name: etcd
image: k8s.gcr.io/etcd:` + expectedEtcdVersion
image: registry.k8s.io/etcd:` + expectedEtcdVersion

manifestsDir, err := ioutil.TempDir("", "GetEtcdImageTagFromStaticPod-test-manifests")
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions cmd/kubeadm/app/phases/uploadconfig/uploadconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ package uploadconfig
import (
"fmt"

"github.com/pkg/errors"

v1 "k8s.io/api/core/v1"
rbac "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/klog/v2"

kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
Expand Down Expand Up @@ -120,3 +123,24 @@ func UploadConfiguration(cfg *kubeadmapi.InitConfiguration, client clientset.Int
},
})
}

// MutateImageRepository mutates the imageRepository field in the ClusterConfiguration
// to 'registry.k8s.io' in case it was the legacy default 'k8s.gcr.io'
// https://github.com/kubernetes/kubeadm/issues/2671
func MutateImageRepository(cfg *kubeadmapi.InitConfiguration, client clientset.Interface) error {
if cfg.ImageRepository != "k8s.gcr.io" {
return nil
}
cfg.ImageRepository = "registry.k8s.io"
// If the client is nil assume that we don't want to mutate the in-cluster config
if client == nil {
return nil
}
klog.V(1).Info("updating the ClusterConfiguration.ImageRepository field in the kube-system/kubeadm-config " +
"ConfigMap to be 'registry.k8s.io' instead of the legacy default of 'k8s.gcr.io'")
if err := UploadConfiguration(cfg, client); err != nil {
return errors.Wrap(err, "could not mutate the ClusterConfiguration.ImageRepository field in "+
"the kube-system/kubeadm-config ConfigMap")
}
return nil
}