Skip to content

Commit

Permalink
Use k8s.gcr.io for k8s side-loaded images
Browse files Browse the repository at this point in the history
Signed-off-by: Ciprian Hacman <[email protected]>
  • Loading branch information
hakman committed Mar 23, 2022
1 parent 0c46b5c commit 759172c
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 17 deletions.
3 changes: 3 additions & 0 deletions nodeup/pkg/model/kube_apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,9 @@ func (b *KubeAPIServerBuilder) buildPod(kubeAPIServer *kops.KubeAPIServerConfig)
}

image := kubeAPIServer.Image
if components.IsBaseURL(b.Cluster.Spec.KubernetesVersion) {
image = strings.Replace(image, "registry.k8s.io", "k8s.gcr.io", 1)
}
if b.Architecture != architectures.ArchitectureAmd64 {
image = strings.Replace(image, "-amd64", "-"+string(b.Architecture), 1)
}
Expand Down
4 changes: 4 additions & 0 deletions nodeup/pkg/model/kube_controller_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/k8scodecs"
"k8s.io/kops/pkg/kubemanifest"
"k8s.io/kops/pkg/model/components"
"k8s.io/kops/pkg/rbac"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
Expand Down Expand Up @@ -207,6 +208,9 @@ func (b *KubeControllerManagerBuilder) buildPod(kcm *kops.KubeControllerManagerC
flags = append(flags, "--flex-volume-plugin-dir="+volumePluginDir)

image := kcm.Image
if components.IsBaseURL(b.Cluster.Spec.KubernetesVersion) {
image = strings.Replace(image, "registry.k8s.io", "k8s.gcr.io", 1)
}
if b.Architecture != architectures.ArchitectureAmd64 {
image = strings.Replace(image, "-amd64", "-"+string(b.Architecture), 1)
}
Expand Down
18 changes: 9 additions & 9 deletions nodeup/pkg/model/kube_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/k8scodecs"
"k8s.io/kops/pkg/kubemanifest"
"k8s.io/kops/pkg/model/components"
"k8s.io/kops/pkg/rbac"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
Expand Down Expand Up @@ -162,7 +163,14 @@ func (b *KubeProxyBuilder) buildPod() (*v1.Pod, error) {
"--oom-score-adj=-998",
}...)

image := kubeProxyImage(b.NodeupModelContext)
image := c.Image
if b.Architecture != architectures.ArchitectureAmd64 {
image = strings.Replace(image, "-amd64", "-"+string(b.Architecture), 1)
}
if components.IsBaseURL(b.Cluster.Spec.KubernetesVersion) {
image = strings.Replace(image, "registry.k8s.io", "k8s.gcr.io", 1)
}

container := &v1.Container{
Name: "kube-proxy",
Image: image,
Expand Down Expand Up @@ -287,11 +295,3 @@ func tolerateMasterTaints() []v1.Toleration {

return tolerations
}

func kubeProxyImage(b *NodeupModelContext) string {
image := b.Cluster.Spec.KubeProxy.Image
if b.Architecture != architectures.ArchitectureAmd64 {
image = strings.Replace(image, "-amd64", "-"+string(b.Architecture), 1)
}
return image
}
4 changes: 4 additions & 0 deletions nodeup/pkg/model/kube_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/k8scodecs"
"k8s.io/kops/pkg/kubemanifest"
"k8s.io/kops/pkg/model/components"
"k8s.io/kops/pkg/rbac"
"k8s.io/kops/upup/pkg/fi"
"k8s.io/kops/upup/pkg/fi/nodeup/nodetasks"
Expand Down Expand Up @@ -214,6 +215,9 @@ func (b *KubeSchedulerBuilder) buildPod(kubeScheduler *kops.KubeSchedulerConfig)
}

image := kubeScheduler.Image
if components.IsBaseURL(b.Cluster.Spec.KubernetesVersion) {
image = strings.Replace(image, "registry.k8s.io", "k8s.gcr.io", 1)
}
if b.Architecture != architectures.ArchitectureAmd64 {
image = strings.Replace(image, "-amd64", "-"+string(b.Architecture), 1)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contents: |
- --log-file=/var/log/kube-apiserver.log
command:
- /usr/local/bin/kube-apiserver
image: registry.k8s.io/kube-apiserver-amd64:v1.22.0
image: k8s.gcr.io/kube-apiserver-amd64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contents: |
- --log-file=/var/log/kube-apiserver.log
command:
- /usr/local/bin/kube-apiserver
image: registry.k8s.io/kube-apiserver-arm64:v1.22.0
image: k8s.gcr.io/kube-apiserver-arm64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contents: |
- --log-file=/var/log/kube-controller-manager.log
command:
- /usr/local/bin/kube-controller-manager
image: registry.k8s.io/kube-controller-manager-amd64:v1.22.0
image: k8s.gcr.io/kube-controller-manager-amd64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ contents: |
- --log-file=/var/log/kube-controller-manager.log
command:
- /usr/local/bin/kube-controller-manager
image: registry.k8s.io/kube-controller-manager-arm64:v1.22.0
image: k8s.gcr.io/kube-controller-manager-arm64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contents: |
- --log-file=/var/log/kube-proxy.log
command:
- /usr/local/bin/kube-proxy
image: registry.k8s.io/kube-proxy-amd64:v1.22.0
image: k8s.gcr.io/kube-proxy-amd64:v1.22.0
name: kube-proxy
resources:
requests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contents: |
- --log-file=/var/log/kube-proxy.log
command:
- /usr/local/bin/kube-proxy
image: registry.k8s.io/kube-proxy-arm64:v1.22.0
image: k8s.gcr.io/kube-proxy-arm64:v1.22.0
name: kube-proxy
resources:
requests:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contents: |
- --log-file=/var/log/kube-scheduler.log
command:
- /usr/local/bin/kube-scheduler
image: registry.k8s.io/kube-scheduler-amd64:v1.22.0
image: k8s.gcr.io/kube-scheduler-amd64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ contents: |
- --log-file=/var/log/kube-scheduler.log
command:
- /usr/local/bin/kube-scheduler
image: registry.k8s.io/kube-scheduler-arm64:v1.22.0
image: k8s.gcr.io/kube-scheduler-arm64:v1.22.0
livenessProbe:
httpGet:
host: 127.0.0.1
Expand Down

0 comments on commit 759172c

Please sign in to comment.