mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
kubeadm: Use GetGenericImage for kube-dns
As kube-dns transitioned to fat manifests, it's no longer required to use arch suffixed images. This change makes use of fat manifests for kube-dns and removes the last few calls to the GetGenericArchImage function, thus removing GetGenericArchImage too. Signed-off-by: Rostislav M. Georgiev <rostislavg@vmware.com>
This commit is contained in:
parent
e3dbad3211
commit
68ed2bdd35
@ -18,7 +18,6 @@ package images
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
kubeadmapi "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
@ -31,11 +30,6 @@ func GetGenericImage(prefix, image, tag string) string {
|
|||||||
return fmt.Sprintf("%s/%s:%s", prefix, image, tag)
|
return fmt.Sprintf("%s/%s:%s", prefix, image, tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetGenericArchImage generates and returns an image based on the current runtime arch
|
|
||||||
func GetGenericArchImage(prefix, image, tag string) string {
|
|
||||||
return fmt.Sprintf("%s/%s-%s:%s", prefix, image, runtime.GOARCH, tag)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetKubeControlPlaneImage generates and returns the image for the core Kubernetes components or returns the unified control plane image if specified
|
// GetKubeControlPlaneImage generates and returns the image for the core Kubernetes components or returns the unified control plane image if specified
|
||||||
func GetKubeControlPlaneImage(image string, cfg *kubeadmapi.ClusterConfiguration) string {
|
func GetKubeControlPlaneImage(image string, cfg *kubeadmapi.ClusterConfiguration) string {
|
||||||
if cfg.UnifiedControlPlaneImage != "" {
|
if cfg.UnifiedControlPlaneImage != "" {
|
||||||
@ -79,9 +73,9 @@ func GetAllImages(cfg *kubeadmapi.ClusterConfiguration) []string {
|
|||||||
if features.Enabled(cfg.FeatureGates, features.CoreDNS) {
|
if features.Enabled(cfg.FeatureGates, features.CoreDNS) {
|
||||||
imgs = append(imgs, GetGenericImage(cfg.ImageRepository, constants.CoreDNS, constants.CoreDNSVersion))
|
imgs = append(imgs, GetGenericImage(cfg.ImageRepository, constants.CoreDNS, constants.CoreDNSVersion))
|
||||||
} else {
|
} else {
|
||||||
imgs = append(imgs, GetGenericArchImage(cfg.ImageRepository, "k8s-dns-kube-dns", constants.KubeDNSVersion))
|
imgs = append(imgs, GetGenericImage(cfg.ImageRepository, "k8s-dns-kube-dns", constants.KubeDNSVersion))
|
||||||
imgs = append(imgs, GetGenericArchImage(cfg.ImageRepository, "k8s-dns-sidecar", constants.KubeDNSVersion))
|
imgs = append(imgs, GetGenericImage(cfg.ImageRepository, "k8s-dns-sidecar", constants.KubeDNSVersion))
|
||||||
imgs = append(imgs, GetGenericArchImage(cfg.ImageRepository, "k8s-dns-dnsmasq-nanny", constants.KubeDNSVersion))
|
imgs = append(imgs, GetGenericImage(cfg.ImageRepository, "k8s-dns-dnsmasq-nanny", constants.KubeDNSVersion))
|
||||||
}
|
}
|
||||||
|
|
||||||
return imgs
|
return imgs
|
||||||
|
@ -18,7 +18,6 @@ package images
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -45,19 +44,6 @@ func TestGetGenericImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetGenericArchImage(t *testing.T) {
|
|
||||||
const (
|
|
||||||
prefix = "foo"
|
|
||||||
image = "bar"
|
|
||||||
tag = "baz"
|
|
||||||
)
|
|
||||||
expected := fmt.Sprintf("%s/%s-%s:%s", prefix, image, runtime.GOARCH, tag)
|
|
||||||
actual := GetGenericArchImage(prefix, image, tag)
|
|
||||||
if actual != expected {
|
|
||||||
t.Errorf("failed GetGenericArchImage:\n\texpected: %s\n\t actual: %s", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetKubeControlPlaneImage(t *testing.T) {
|
func TestGetKubeControlPlaneImage(t *testing.T) {
|
||||||
var tests = []struct {
|
var tests = []struct {
|
||||||
image string
|
image string
|
||||||
|
@ -19,7 +19,6 @@ package dns
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/mholt/caddy/caddyfile"
|
"github.com/mholt/caddy/caddyfile"
|
||||||
@ -97,9 +96,8 @@ func kubeDNSAddon(cfg *kubeadmapi.InitConfiguration, client clientset.Interface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dnsDeploymentBytes, err := kubeadmutil.ParseTemplate(KubeDNSDeployment,
|
dnsDeploymentBytes, err := kubeadmutil.ParseTemplate(KubeDNSDeployment,
|
||||||
struct{ ImageRepository, Arch, Version, DNSBindAddr, DNSProbeAddr, DNSDomain, MasterTaintKey string }{
|
struct{ ImageRepository, Version, DNSBindAddr, DNSProbeAddr, DNSDomain, MasterTaintKey string }{
|
||||||
ImageRepository: cfg.ImageRepository,
|
ImageRepository: cfg.ImageRepository,
|
||||||
Arch: runtime.GOARCH,
|
|
||||||
Version: kubeadmconstants.KubeDNSVersion,
|
Version: kubeadmconstants.KubeDNSVersion,
|
||||||
DNSBindAddr: dnsBindAddr,
|
DNSBindAddr: dnsBindAddr,
|
||||||
DNSProbeAddr: dnsProbeAddr,
|
DNSProbeAddr: dnsProbeAddr,
|
||||||
|
@ -95,9 +95,8 @@ func TestCompileManifests(t *testing.T) {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
manifest: KubeDNSDeployment,
|
manifest: KubeDNSDeployment,
|
||||||
data: struct{ ImageRepository, Arch, Version, DNSBindAddr, DNSProbeAddr, DNSDomain, MasterTaintKey string }{
|
data: struct{ ImageRepository, Version, DNSBindAddr, DNSProbeAddr, DNSDomain, MasterTaintKey string }{
|
||||||
ImageRepository: "foo",
|
ImageRepository: "foo",
|
||||||
Arch: "foo",
|
|
||||||
Version: "foo",
|
Version: "foo",
|
||||||
DNSBindAddr: "foo",
|
DNSBindAddr: "foo",
|
||||||
DNSProbeAddr: "foo",
|
DNSProbeAddr: "foo",
|
||||||
|
@ -50,7 +50,7 @@ spec:
|
|||||||
optional: true
|
optional: true
|
||||||
containers:
|
containers:
|
||||||
- name: kubedns
|
- name: kubedns
|
||||||
image: {{ .ImageRepository }}/k8s-dns-kube-dns-{{ .Arch }}:{{ .Version }}
|
image: {{ .ImageRepository }}/k8s-dns-kube-dns:{{ .Version }}
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
# TODO: Set memory limits when we've profiled the container for large
|
# TODO: Set memory limits when we've profiled the container for large
|
||||||
@ -102,7 +102,7 @@ spec:
|
|||||||
- name: kube-dns-config
|
- name: kube-dns-config
|
||||||
mountPath: /kube-dns-config
|
mountPath: /kube-dns-config
|
||||||
- name: dnsmasq
|
- name: dnsmasq
|
||||||
image: {{ .ImageRepository }}/k8s-dns-dnsmasq-nanny-{{ .Arch }}:{{ .Version }}
|
image: {{ .ImageRepository }}/k8s-dns-dnsmasq-nanny:{{ .Version }}
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
@ -143,7 +143,7 @@ spec:
|
|||||||
- name: kube-dns-config
|
- name: kube-dns-config
|
||||||
mountPath: /etc/k8s/dns/dnsmasq-nanny
|
mountPath: /etc/k8s/dns/dnsmasq-nanny
|
||||||
- name: sidecar
|
- name: sidecar
|
||||||
image: {{ .ImageRepository }}/k8s-dns-sidecar-{{ .Arch }}:{{ .Version }}
|
image: {{ .ImageRepository }}/k8s-dns-sidecar:{{ .Version }}
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
@ -174,8 +174,6 @@ spec:
|
|||||||
operator: Exists
|
operator: Exists
|
||||||
- key: {{ .MasterTaintKey }}
|
- key: {{ .MasterTaintKey }}
|
||||||
effect: NoSchedule
|
effect: NoSchedule
|
||||||
nodeSelector:
|
|
||||||
beta.kubernetes.io/arch: {{ .Arch }}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
// KubeDNSService is the kube-dns Service manifest
|
// KubeDNSService is the kube-dns Service manifest
|
||||||
|
Loading…
Reference in New Issue
Block a user