Merge pull request #130019 from yongruilin/version-intro
KEP-4330: extend version information with more detailed version fields Kubernetes-commit: 23d63770284cb30a2eb90b79ace0f1c7e32fb16f
This commit is contained in:
commit
70820c9c98
4
go.mod
4
go.mod
|
@ -49,9 +49,9 @@ require (
|
|||
gopkg.in/go-jose/go-jose.v2 v2.6.3
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
k8s.io/api v0.0.0-20250313213105-aae61a387040
|
||||
k8s.io/apimachinery v0.0.0-20250313012745-a04ff375cef8
|
||||
k8s.io/apimachinery v0.0.0-20250314012750-c8bf40462f05
|
||||
k8s.io/client-go v0.0.0-20250313213513-7faeb317c7cb
|
||||
k8s.io/component-base v0.0.0-20250313134451-21955e6fb6de
|
||||
k8s.io/component-base v0.0.0-20250314013811-792166919ea6
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
k8s.io/kms v0.0.0-20250308014716-89c23671c056
|
||||
k8s.io/kube-openapi v0.0.0-20250304201544-e5f78fe3ede9
|
||||
|
|
8
go.sum
8
go.sum
|
@ -369,12 +369,12 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
|
|||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
k8s.io/api v0.0.0-20250313213105-aae61a387040 h1:t4Fsq5t8BkN81dKsvJL0PobJ7UcEONapi8OEL7GKxdo=
|
||||
k8s.io/api v0.0.0-20250313213105-aae61a387040/go.mod h1:nyT7xKOld0k8IraPSyWNF96YIMppoRBYxtAUIehRQW0=
|
||||
k8s.io/apimachinery v0.0.0-20250313012745-a04ff375cef8 h1:aZ3lyC/cbDqhg3/RCSobSABNBeUzBWh6LrHeSnIVzVY=
|
||||
k8s.io/apimachinery v0.0.0-20250313012745-a04ff375cef8/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo=
|
||||
k8s.io/apimachinery v0.0.0-20250314012750-c8bf40462f05 h1:p6NTTHrtJ3xql/EbCo0+GTA03N+m4sT1Epi08HR/458=
|
||||
k8s.io/apimachinery v0.0.0-20250314012750-c8bf40462f05/go.mod h1:S2OIkExGqJOXYSYcAJwQ9zWcc6BkBUdTJUu4M7z0cvo=
|
||||
k8s.io/client-go v0.0.0-20250313213513-7faeb317c7cb h1:VQrMVHfIw2UYOoHRKv3IVq+0zOreSzDJNrqq1cucnUk=
|
||||
k8s.io/client-go v0.0.0-20250313213513-7faeb317c7cb/go.mod h1:V0EHGmkhojNdNhnYJsDvDW7DEgWmUnDPqtNVsH/UiJc=
|
||||
k8s.io/component-base v0.0.0-20250313134451-21955e6fb6de h1:We8ju29OKDTlkbMms7Undb7qDwsNCqONQ3n1267IHig=
|
||||
k8s.io/component-base v0.0.0-20250313134451-21955e6fb6de/go.mod h1:r6V6jJTcG+CkoeNrKCL9GVTxmFn8BpeX2aoiEGHxKNY=
|
||||
k8s.io/component-base v0.0.0-20250314013811-792166919ea6 h1:e3uteoFmipq017BqvEGsZMd2NJ70BNG8q9tJqmoAIjw=
|
||||
k8s.io/component-base v0.0.0-20250314013811-792166919ea6/go.mod h1:fofD+M/PFvgSSrpoHM4YNpml4jKf8cMXogjsQgRnryA=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
|
||||
k8s.io/kms v0.0.0-20250308014716-89c23671c056 h1:gbxlOdJXB8kVFrYsdlutvYMKCwkMvHuz7Z/k0dBvR1s=
|
||||
|
|
|
@ -1106,7 +1106,7 @@ func installAPI(name string, s *GenericAPIServer, c *Config) {
|
|||
}
|
||||
}
|
||||
|
||||
routes.Version{Version: c.EffectiveVersion.BinaryVersion().Info()}.Install(s.Handler.GoRestfulContainer)
|
||||
routes.Version{Version: c.EffectiveVersion.Info()}.Install(s.Handler.GoRestfulContainer)
|
||||
|
||||
if c.EnableDiscovery {
|
||||
wrapped := discoveryendpoint.WrapAggregatedDiscoveryToHandler(s.DiscoveryGroupManager, s.AggregatedDiscoveryGroupManager)
|
||||
|
|
|
@ -47,6 +47,7 @@ import (
|
|||
restclient "k8s.io/client-go/rest"
|
||||
cliflag "k8s.io/component-base/cli/flag"
|
||||
basecompatibility "k8s.io/component-base/compatibility"
|
||||
baseversion "k8s.io/component-base/version"
|
||||
"k8s.io/klog/v2/ktesting"
|
||||
netutils "k8s.io/utils/net"
|
||||
)
|
||||
|
@ -277,9 +278,8 @@ func TestServerRunWithSNI(t *testing.T) {
|
|||
|
||||
// launch server
|
||||
config := setUp(t)
|
||||
v := fakeVersion()
|
||||
config.EffectiveVersion = basecompatibility.NewEffectiveVersionFromString(v.String(), "", "")
|
||||
|
||||
info := fakeVersionInfo()
|
||||
config.EffectiveVersion = basecompatibility.NewEffectiveVersionFromString(fmt.Sprintf("%s.%s", info.Major, info.Minor), "", "")
|
||||
config.EnableIndex = true
|
||||
secureOptions := (&SecureServingOptions{
|
||||
BindAddress: netutils.ParseIPSloppy("127.0.0.1"),
|
||||
|
@ -371,8 +371,8 @@ func TestServerRunWithSNI(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("failed to connect with loopback client: %v", err)
|
||||
}
|
||||
if expected := &v; !reflect.DeepEqual(got, expected) {
|
||||
t.Errorf("loopback client didn't get correct version info: expected=%v got=%v", expected, got)
|
||||
if expected := &info; !reflect.DeepEqual(got, expected) {
|
||||
t.Errorf("loopback client didn't get correct version info: expected=%v got=%v", *expected, *got)
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -461,12 +461,15 @@ func certSignature(cert tls.Certificate) (string, error) {
|
|||
return x509CertSignature(x509Certs[0]), nil
|
||||
}
|
||||
|
||||
func fakeVersion() version.Info {
|
||||
return version.Info{
|
||||
Major: "42",
|
||||
Minor: "42",
|
||||
GitVersion: "42.42",
|
||||
}
|
||||
func fakeVersionInfo() version.Info {
|
||||
baseVer := baseversion.Get()
|
||||
baseVer.Major = "42"
|
||||
baseVer.Minor = "42"
|
||||
baseVer.EmulationMajor = "42"
|
||||
baseVer.EmulationMinor = "42"
|
||||
baseVer.MinCompatibilityMajor = "42"
|
||||
baseVer.MinCompatibilityMinor = "41"
|
||||
return baseVer
|
||||
}
|
||||
|
||||
// generateSelfSignedCertKey creates a self-signed certificate and key for the given host.
|
||||
|
|
|
@ -39,10 +39,10 @@ func (v Version) Install(c *restful.Container) {
|
|||
// Set up a service to return the git code version.
|
||||
versionWS := new(restful.WebService)
|
||||
versionWS.Path("/version")
|
||||
versionWS.Doc("git code version from which this is built")
|
||||
versionWS.Doc("get the version information for this server.")
|
||||
versionWS.Route(
|
||||
versionWS.GET("/").To(v.handleVersion).
|
||||
Doc("get the code version").
|
||||
Doc("get the version information for this server").
|
||||
Operation("getCodeVersion").
|
||||
Produces(restful.MIME_JSON).
|
||||
Consumes(restful.MIME_JSON).
|
||||
|
|
|
@ -55,11 +55,11 @@ func kubeEffectiveVersionFloors(binaryVersion *version.Version) *version.Version
|
|||
// We do not enforce the N-3..N emulation version range in tests so that the tests would not automatically fail when there is a version bump.
|
||||
// Only used in tests.
|
||||
func DefaultKubeEffectiveVersionForTest() basecompatibility.MutableEffectiveVersion {
|
||||
binaryVersion := version.MustParse(baseversion.DefaultKubeBinaryVersion).WithInfo(baseversion.Get())
|
||||
binaryVersion := version.MustParse(baseversion.DefaultKubeBinaryVersion)
|
||||
return basecompatibility.NewEffectiveVersion(binaryVersion, false, version.MustParse("0.0"), version.MustParse("0.0"))
|
||||
}
|
||||
|
||||
func defaultBuildBinaryVersion() *version.Version {
|
||||
verInfo := baseversion.Get()
|
||||
return version.MustParse(verInfo.String()).WithInfo(verInfo)
|
||||
return version.MustParse(verInfo.String())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue