Skip to content

Commit

Permalink
added makefile target
Browse files Browse the repository at this point in the history
  • Loading branch information
Srikrishnabh committed Jul 31, 2021
1 parent 5f46b98 commit 8f04834
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 44 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,11 @@ else
go run update_kubernetes_version.go)
endif

.PHONY: update-kubeadm-constants
update-kubeadm-constants:
(cd hack/update/kubeadm_constants && \
go run update_kubeadm_constants.go -kubernetes-version=latest)

.PHONY: stress
stress: ## run the stress tests
go test -test.v -test.timeout=2h ./test/stress -loops=10 | tee "./out/testout_$(COMMIT_SHORT).txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ func main() {
},
}

if _, ok := constants.KubeadmImages[imageVersion]; !ok {
majorMinorVersion := semver.MajorMinor(imageVersion)

if _, ok := constants.KubeadmImages[majorMinorVersion]; !ok {
schema[minikubeConstantsFilePath].Replace[`KubeadmImages = .*`] =
`KubeadmImages = map[string]map[string]string{ {{.ImageMap}}`
} else {
versionIdentifier := fmt.Sprintf(`"%s": {[^}]+},`, imageVersion)
versionIdentifier := fmt.Sprintf(`"%s": {[^}]+},`, majorMinorVersion)
schema[minikubeConstantsFilePath].Replace[versionIdentifier] = "{{.ImageMap}}"
}

Expand All @@ -107,13 +109,15 @@ func getKubeadmImagesMapString(version string) (string, error) {
url := fmt.Sprintf(kubeadmReleaseURL, version)
fileName := fmt.Sprintf(kubeadmBinaryName, version)
if err := downloadFile(url, fileName); err != nil {
klog.Errorf("failed to download kubeadm binary %s", err.Error())
return "", err
}

kubeadmCommand := fmt.Sprintf("./%s", fileName)
args := []string{"config", "images", "list"}
imageListString, err := executeCommand(kubeadmCommand, args...)
if err != nil {
klog.Errorf("failed to execute kubeadm command %s", kubeadmCommand)
return "", err
}

Expand All @@ -126,18 +130,20 @@ func getKubeadmImagesMapString(version string) (string, error) {

func formatKubeadmImageList(version, data string) (string, error) {
templateData := make(map[string]map[string]string)
templateData[version] = make(map[string]string)
majorMinorVersion := semver.MajorMinor(version)
templateData[majorMinorVersion] = make(map[string]string)
lines := strings.Split(data, "\n")
for _, line := range lines {
imageTag := strings.Split(line, ":")
if len(imageTag) == 2 {
templateData[version][imageTag[0]] = imageTag[1]
templateData[majorMinorVersion][imageTag[0]] = imageTag[1]
}
}

imageTemplate := template.New("kubeadmImage")
t, err := imageTemplate.Parse(kubeadmImagesTemplate)
if err != nil {
klog.Errorf("failed to create kubeadm image map template %s", err.Error())
return "", err
}

Expand Down
2 changes: 1 addition & 1 deletion hack/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func init() {
klog.Warningf("Unable to set flag value for alsologtostderr: %v", err)
}

// used in update_kubeadm_image_versions.go
// used in update_kubeadm_constants.go
flag.String("kubernetes-version", "", "kubernetes-version")
flag.Parse()
defer klog.Flush()
Expand Down
19 changes: 10 additions & 9 deletions pkg/minikube/bootstrapper/images/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func Pause(v semver.Version, mirror string) string {
// Should match `PauseVersion` in:
// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants_unix.go
pv := "3.2"
k8sVersion := fmt.Sprintf("v1.%d.0", v.Minor)
majorMinorVersion := fmt.Sprintf("v%d.%d", v.Major, v.Minor)
imageName := path.Join(kubernetesRepo(mirror), "pause")

if _, ok := constants.KubeadmImages[k8sVersion]; ok {
pv = constants.KubeadmImages[k8sVersion][imageName]
if _, ok := constants.KubeadmImages[majorMinorVersion]; ok {
pv = constants.KubeadmImages[majorMinorVersion][imageName]
}

if semver.MustParseRange("<1.18.0-alpha.0")(v) {
Expand Down Expand Up @@ -95,15 +95,16 @@ func coreDNS(v semver.Version, mirror string) string {
*/

cv := "1.7.0"
k8sVersion := fmt.Sprintf("v1.%d.0", v.Minor)

majorMinorVersion := fmt.Sprintf("v%d.%d", v.Major, v.Minor)
imageName := path.Join(kubernetesRepo(mirror), "coredns")

if v.Minor >= 21 {
imageName = path.Join(imageName, "coredns")
}

if _, ok := constants.KubeadmImages[k8sVersion]; ok {
cv = constants.KubeadmImages[k8sVersion][imageName]
if _, ok := constants.KubeadmImages[majorMinorVersion]; ok {
cv = constants.KubeadmImages[majorMinorVersion][imageName]
}

// return path.Join(kubernetesRepo(mirror), "coredns:"+cv)
Expand All @@ -129,11 +130,11 @@ func etcd(v semver.Version, mirror string) string {
// ev = "3.2.18"
//}
*/
k8sVersion := fmt.Sprintf("v1.%d.0", v.Minor)
majorMinorVersion := fmt.Sprintf("v%d.%d", v.Major, v.Minor)
imageName := path.Join(kubernetesRepo(mirror), "etcd")

if _, ok := constants.KubeadmImages[k8sVersion]; ok {
ev = constants.KubeadmImages[k8sVersion][imageName]
if _, ok := constants.KubeadmImages[majorMinorVersion]; ok {
ev = constants.KubeadmImages[majorMinorVersion][imageName]
}

// An awkward special case for v1.19.0 - do not imitate unless necessary
Expand Down
44 changes: 14 additions & 30 deletions pkg/minikube/constants/constants_kubeadm_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package constants

var (
KubeadmImages = map[string]map[string]string{
"v1.22.0-rc.0": {
"v1.22": {
"k8s.gcr.io/coredns/coredns": "v1.8.4",
"k8s.gcr.io/etcd": "3.4.13-0",
"k8s.gcr.io/kube-apiserver": "v1.21.3",
Expand All @@ -27,16 +27,8 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.21.3",
"k8s.gcr.io/pause": "3.5",
},
"v1.21.3": {
"k8s.gcr.io/coredns/coredns": "v1.8.0",
"k8s.gcr.io/etcd": "3.4.13-0",
"k8s.gcr.io/kube-apiserver": "v1.21.3",
"k8s.gcr.io/kube-controller-manager": "v1.21.3",
"k8s.gcr.io/kube-proxy": "v1.21.3",
"k8s.gcr.io/kube-scheduler": "v1.21.3",
"k8s.gcr.io/pause": "3.4.1",
},
"v1.21.0": {

"v1.21": {
"k8s.gcr.io/coredns/coredns": "v1.8.0",
"k8s.gcr.io/etcd": "3.4.13-0",
"k8s.gcr.io/kube-apiserver": "v1.21.3",
Expand All @@ -45,7 +37,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.21.3",
"k8s.gcr.io/pause": "3.4.1",
},
"v1.20.0": {
"v1.20": {
"k8s.gcr.io/coredns": "1.7.0",
"k8s.gcr.io/etcd": "3.4.13-0",
"k8s.gcr.io/kube-apiserver": "v1.20.9",
Expand All @@ -54,7 +46,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.20.9",
"k8s.gcr.io/pause": "3.2",
},
"v1.19.0": {
"v1.19": {
"k8s.gcr.io/coredns": "1.7.0",
"k8s.gcr.io/etcd": "3.4.9-1",
"k8s.gcr.io/kube-apiserver": "v1.19.13",
Expand All @@ -63,7 +55,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.19.13",
"k8s.gcr.io/pause": "3.2",
},
"v1.18.0": {
"v1.18": {
"k8s.gcr.io/coredns": "1.6.7",
"k8s.gcr.io/etcd": "3.4.3-0",
"k8s.gcr.io/kube-apiserver": "v1.18.20",
Expand All @@ -72,7 +64,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.18.20",
"k8s.gcr.io/pause": "3.2",
},
"v1.17.0": {
"v1.17": {
"k8s.gcr.io/coredns": "1.6.5",
"k8s.gcr.io/etcd": "3.4.3-0",
"k8s.gcr.io/kube-apiserver": "v1.17.17",
Expand All @@ -81,16 +73,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.17.17",
"k8s.gcr.io/pause": "3.1",
},
"v1.16.1": {
"mirror.k8s.io/kube-proxy": "v1.16.1",
"mirror.k8s.io/kube-scheduler": "v1.16.1",
"mirror.k8s.io/kube-controller-manager": "v1.16.1",
"mirror.k8s.io/kube-apiserver": "v1.16.1",
"mirror.k8s.io/coredns": "1.6.2",
"mirror.k8s.io/etcd": "3.3.15-0",
"mirror.k8s.io/pause": "3.1",
},
"v1.16.0": {
"v1.16": {
"k8s.gcr.io/coredns": "1.6.2",
"k8s.gcr.io/etcd": "3.3.15-0",
"k8s.gcr.io/kube-apiserver": "v1.16.15",
Expand All @@ -99,7 +82,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.16.15",
"k8s.gcr.io/pause": "3.1",
},
"v1.15.0": {
"v1.15": {
"k8s.gcr.io/coredns": "1.3.1",
"k8s.gcr.io/etcd": "3.3.10",
"k8s.gcr.io/kube-apiserver": "v1.15.12",
Expand All @@ -108,7 +91,8 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.15.12",
"k8s.gcr.io/pause": "3.1",
},
"v1.14.0": {

"v1.14": {
"k8s.gcr.io/coredns": "1.3.1",
"k8s.gcr.io/etcd": "3.3.10",
"k8s.gcr.io/kube-apiserver": "v1.14.10",
Expand All @@ -117,7 +101,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.14.10",
"k8s.gcr.io/pause": "3.1",
},
"v1.13.0": {
"v1.13": {
"k8s.gcr.io/coredns": "1.2.6",
"k8s.gcr.io/etcd": "3.2.24",
"k8s.gcr.io/kube-apiserver": "v1.13.12",
Expand All @@ -126,7 +110,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.13.12",
"k8s.gcr.io/pause": "3.1",
},
"v1.12.0": {
"v1.12": {
"k8s.gcr.io/coredns": "1.2.2",
"k8s.gcr.io/etcd": "3.2.24",
"k8s.gcr.io/kube-apiserver": "v1.21.3",
Expand All @@ -135,7 +119,7 @@ var (
"k8s.gcr.io/kube-scheduler": "v1.21.3",
"k8s.gcr.io/pause": "3.1",
},
"v1.11.0": {
"v1.11": {
"k8s.gcr.io/coredns": "1.1.3",
"k8s.gcr.io/etcd-amd64": "3.2.18",
"k8s.gcr.io/kube-apiserver-amd64": "v1.11.10",
Expand Down

0 comments on commit 8f04834

Please sign in to comment.