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

get ETCD version from kubernetes constants #11290

Open
medyagh opened this issue May 5, 2021 · 20 comments
Open

get ETCD version from kubernetes constants #11290

medyagh opened this issue May 5, 2021 · 20 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@medyagh
Copy link
Member

medyagh commented May 5, 2021

currently in https://github.com/medyagh/minikube/blob/a67a4ccbedd932f184b5713c70498dc434942621/pkg/minikube/bootstrapper/images/images.go#L86
we have

// etcd returns the image used for etcd
func etcd(v semver.Version, mirror string) string {
	// Should match `DefaultEtcdVersion` in:
	// https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go
	ev := "3.4.13-0"

	switch v.Minor {
	case 17, 18:
		ev = "3.4.3-0"
	case 16:
		ev = "3.3.15-0"
	case 14, 15:
		ev = "3.3.10"
	case 12, 13:
		ev = "3.2.24"
	case 11:
		ev = "3.2.18"
	}

	// An awkward special case for v1.19.0 - do not imitate unless necessary
	if v.Equals(semver.MustParse("1.19.0")) {
		ev = "3.4.9-1"
	}

	return path.Join(kubernetesRepo(mirror), "etcd:"+ev)
}

instead we should use this map in kuberentes so we dont have to update this manually

https://github.com/kubernetes/kubernetes/blob/b58a7e233e06f5e4b58a637af8e36cb4f59c001b/cmd/kubeadm/app/constants/constants.go#L452


	// SupportedEtcdVersion lists officially supported etcd versions with corresponding Kubernetes releases
	SupportedEtcdVersion = map[uint8]string{
		13: "3.2.24",
		14: "3.3.10",
		15: "3.3.10",
		16: "3.3.17-0",
		17: "3.4.3-0",
		18: "3.4.3-0",
		19: "3.4.13-0",
		20: "3.4.13-0",
		21: "3.4.13-0",
		22: "3.4.13-0",
		23: "3.4.13-0",
	}

@medyagh medyagh added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels May 5, 2021
@afbjorklund
Copy link
Collaborator

afbjorklund commented May 5, 2021

It's not really in kubernetes but in kubeadm, and we can access these through config images list

$ ~/.minikube/cache/linux/v1.20.2/kubeadm config images list
k8s.gcr.io/kube-apiserver:v1.20.7
k8s.gcr.io/kube-controller-manager:v1.20.7
k8s.gcr.io/kube-scheduler:v1.20.7
k8s.gcr.io/kube-proxy:v1.20.7
k8s.gcr.io/pause:3.2
k8s.gcr.io/etcd:3.4.13-0

By default it will try to get latest: remote version is much newer: v1.21.1; falling back to: stable-1.20

Forgot what the reason was (but there was one) for doing it in code, and for duplicating all the constants.

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 5, 2021

@medyagh : better fix all of them, if you fix one ?

// Pause returns the image name to pull for a given Kubernetes version
func Pause(v semver.Version, mirror string) string

// coreDNS returns the images used for CoreDNS
func coreDNS(v semver.Version, mirror string) string

// etcd returns the image used for etcd
func etcd(v semver.Version, mirror string) string

The original code is in cmd/kubeadm/app/images/images.go

https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/images/images.go
(https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go)

I think the problem was with accessing the earlier releases ?

	// DefaultEtcdVersion indicates the default etcd version that kubeadm uses
	DefaultEtcdVersion = "3.4.13-3"

	// CoreDNSVersion is the version of CoreDNS to be deployed if it is used
	CoreDNSVersion = "v1.8.0"

	// PauseVersion indicates the default pause image version for kubeadm
	PauseVersion = "3.4.1"

@medyagh
Copy link
Member Author

medyagh commented May 5, 2021

Agree. Anyone picking up this task fix all verisons. To get vers through kubeadm

@Srikrishnabh
Copy link
Contributor

@medyagh I would like to fix this.

@vibecoder
Copy link
Contributor

/assign

@Srikrishnabh
Copy link
Contributor

@vigothehacker If you dont mind can I work on this had already started, missed the assign command ?

@Srikrishnabh
Copy link
Contributor

@medyagh : better fix all of them, if you fix one ?

// Pause returns the image name to pull for a given Kubernetes version
func Pause(v semver.Version, mirror string) string

// coreDNS returns the images used for CoreDNS
func coreDNS(v semver.Version, mirror string) string

// etcd returns the image used for etcd
func etcd(v semver.Version, mirror string) string

The original code is in cmd/kubeadm/app/images/images.go

https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/images/images.go
(https://github.com/kubernetes/kubernetes/blob/master/cmd/kubeadm/app/constants/constants.go)

I think the problem was with accessing the earlier releases ?

yes to get the older release versions.

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 9, 2021

I think the reason was that we wanted to know the versions before we downloaded kubeadm...

And that not all platforms were able to execute kubeadm, without wrapping it in docker or similar ?

One solution would be to make some kind of mapping table. That is, in markup instead of in code ?

---
v1.21.0:
    k8s.gcr.io/kube-apiserver: v1.21.0
    k8s.gcr.io/kube-controller-manager: v1.21.0
    k8s.gcr.io/kube-scheduler: v1.21.0
    k8s.gcr.io/kube-proxy: v1.21.0
    k8s.gcr.io/pause: 3.4.1
    k8s.gcr.io/etcd: 3.4.13-0
    k8s.gcr.io/coredns/coredns: v1.8.0
v1.20.0:
    k8s.gcr.io/kube-apiserver: v1.20.0
    k8s.gcr.io/kube-controller-manager: v1.20.0
    k8s.gcr.io/kube-scheduler: v1.20.0
    k8s.gcr.io/kube-proxy: v1.20.0
    k8s.gcr.io/pause: 3.2
    k8s.gcr.io/etcd: 3.4.13-0
    k8s.gcr.io/coredns: 1.7.0
v1.19.0:
    k8s.gcr.io/kube-apiserver: v1.19.0
    k8s.gcr.io/kube-controller-manager: v1.19.0
    k8s.gcr.io/kube-scheduler: v1.19.0
    k8s.gcr.io/kube-proxy: v1.19.0
    k8s.gcr.io/pause: 3.2
    k8s.gcr.io/etcd: 3.4.9-1
    k8s.gcr.io/coredns: 1.7.0

Note that you also have to supply --kubernetes-version, or it will auto-update (within each release).

@vibecoder
Copy link
Contributor

/unassign

@Srikrishnabh
Copy link
Contributor

/assign

@Srikrishnabh
Copy link
Contributor

I think the reason was that we wanted to know the versions before we downloaded kubeadm...

And that not all platforms were able to execute kubeadm, without wrapping it in docker or similar ?

One solution would be to make some kind of mapping table. That is, in markup instead of in code ?

---
v1.21.0:
    k8s.gcr.io/kube-apiserver: v1.21.0
    k8s.gcr.io/kube-controller-manager: v1.21.0
    k8s.gcr.io/kube-scheduler: v1.21.0
    k8s.gcr.io/kube-proxy: v1.21.0
    k8s.gcr.io/pause: 3.4.1
    k8s.gcr.io/etcd: 3.4.13-0
    k8s.gcr.io/coredns/coredns: v1.8.0
v1.20.0:
    k8s.gcr.io/kube-apiserver: v1.20.0
    k8s.gcr.io/kube-controller-manager: v1.20.0
    k8s.gcr.io/kube-scheduler: v1.20.0
    k8s.gcr.io/kube-proxy: v1.20.0
    k8s.gcr.io/pause: 3.2
    k8s.gcr.io/etcd: 3.4.13-0
    k8s.gcr.io/coredns: 1.7.0
v1.19.0:
    k8s.gcr.io/kube-apiserver: v1.19.0
    k8s.gcr.io/kube-controller-manager: v1.19.0
    k8s.gcr.io/kube-scheduler: v1.19.0
    k8s.gcr.io/kube-proxy: v1.19.0
    k8s.gcr.io/pause: 3.2
    k8s.gcr.io/etcd: 3.4.9-1
    k8s.gcr.io/coredns: 1.7.0

Note that you also have to supply --kubernetes-version, or it will auto-update (within each release).

@afbjorklund I'm able to collect the image versions thanks for the inputs.

where do we want to stores this image to k8s version map, did you mean this will be some yaml and we use in code to load?

@afbjorklund
Copy link
Collaborator

afbjorklund commented May 16, 2021

I'm not sure if the best is to embed some kind of resource, or convert the lookup back into code again.

The original input is like:

$ curl -o kubeadm-linux-amd64-v1.13.0 https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubeadm
$ chmod +x kubeadm-linux-amd64-v1.13.0
$ ./kubeadm-linux-amd64-v1.13.0 --kubernetes-version=v1.13.0 config images list
k8s.gcr.io/kube-apiserver:v1.13.0
k8s.gcr.io/kube-controller-manager:v1.13.0
k8s.gcr.io/kube-scheduler:v1.13.0
k8s.gcr.io/kube-proxy:v1.13.0
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.6

I converted it to some yaml markup like:

v1.13.0:
    k8s.gcr.io/kube-apiserver: v1.13.0
    k8s.gcr.io/kube-controller-manager: v1.13.0
    k8s.gcr.io/kube-scheduler: v1.13.0
    k8s.gcr.io/kube-proxy: v1.13.0
    k8s.gcr.io/pause: 3.1
    k8s.gcr.io/etcd: 3.2.24
    k8s.gcr.io/coredns: 1.2.6

It would also be possible to use go code:

	images := make(map[string]map[string]string)
	images["v1.13.0"] = map[string]string{
		"k8s.gcr.io/kube-apiserver":          "v1.13.0",
		"k8s.gcr.io/kube-controller-manager": "v1.13.0",
		"k8s.gcr.io/kube-scheduler":          "v1.13.0",
		"k8s.gcr.io/kube-proxy":              "v1.13.0",
		"k8s.gcr.io/pause":                   "3.1",
		"k8s.gcr.io/etcd":                    "3.2.24",
		"k8s.gcr.io/coredns":                 "1.2.6",
	}

Maybe @medyagh has some more thoughts, on what would be the best way to store these constants ?

@afbjorklund
Copy link
Collaborator

I made a PR to update the values for 1.21, while you think of the best solution for 1.22 and beyond...

@Srikrishnabh
Copy link
Contributor

I'm not sure if the best is to embed some kind of resource, or convert the lookup back into code again.

The original input is like:

$ curl -o kubeadm-linux-amd64-v1.13.0 https://storage.googleapis.com/kubernetes-release/release/v1.13.0/bin/linux/amd64/kubeadm
$ chmod +x kubeadm-linux-amd64-v1.13.0
$ ./kubeadm-linux-amd64-v1.13.0 --kubernetes-version=v1.13.0 config images list
k8s.gcr.io/kube-apiserver:v1.13.0
k8s.gcr.io/kube-controller-manager:v1.13.0
k8s.gcr.io/kube-scheduler:v1.13.0
k8s.gcr.io/kube-proxy:v1.13.0
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.2.24
k8s.gcr.io/coredns:1.2.6

I converted it to some yaml markup like:

v1.13.0:
    k8s.gcr.io/kube-apiserver: v1.13.0
    k8s.gcr.io/kube-controller-manager: v1.13.0
    k8s.gcr.io/kube-scheduler: v1.13.0
    k8s.gcr.io/kube-proxy: v1.13.0
    k8s.gcr.io/pause: 3.1
    k8s.gcr.io/etcd: 3.2.24
    k8s.gcr.io/coredns: 1.2.6

It would also be possible to use go code:

	images := make(map[string]map[string]string)
	images["v1.13.0"] = map[string]string{
		"k8s.gcr.io/kube-apiserver":          "v1.13.0",
		"k8s.gcr.io/kube-controller-manager": "v1.13.0",
		"k8s.gcr.io/kube-scheduler":          "v1.13.0",
		"k8s.gcr.io/kube-proxy":              "v1.13.0",
		"k8s.gcr.io/pause":                   "3.1",
		"k8s.gcr.io/etcd":                    "3.2.24",
		"k8s.gcr.io/coredns":                 "1.2.6",
	}

Maybe @medyagh has some more thoughts, on what would be the best way to store these constants ?

@medyagh any comments?

@medyagh
Copy link
Member Author

medyagh commented Jun 30, 2021

@Srikrishnabh I agree with what @afbjorklund suggested
this could be a map in our constants package
we should have an automated tool to update that constants package file
for example

make update-kubeadm-consts that will get the images list for that specific version of kubernetes and put it in our constants as a map

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 28, 2021
@Srikrishnabh
Copy link
Contributor

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 29, 2021
medyagh added a commit that referenced this issue Dec 7, 2021
fixes get ETCD version from kubernetes constants #11290
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 28, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 27, 2022
@sharifelgamal sharifelgamal added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Feb 9, 2022
@spowelljr spowelljr added priority/backlog Higher priority than priority/awaiting-more-evidence. and removed priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Aug 3, 2022
@spowelljr
Copy link
Member

This currently creates the following output but it should not:

I0517 11:25:37.298578   24430 kubeadm.go:322] W0517 18:25:29.455933    1314 images.go:80] could not find officially supported version of etcd for Kubernetes v1.27.1, falling back to the nearest etcd version (3.5.7-0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

8 participants