diff --git a/build/kazel_generated.bzl b/build/kazel_generated.bzl index f1fc00ae6d..962ad67ff7 100644 --- a/build/kazel_generated.bzl +++ b/build/kazel_generated.bzl @@ -64,6 +64,7 @@ tags_values_pkgs = {"openapi-gen": { "staging/src/k8s.io/api/networking/v1", "staging/src/k8s.io/api/networking/v1beta1", "staging/src/k8s.io/api/node/v1alpha1", + "staging/src/k8s.io/api/node/v1beta1", "staging/src/k8s.io/api/policy/v1beta1", "staging/src/k8s.io/api/rbac/v1", "staging/src/k8s.io/api/rbac/v1alpha1", @@ -140,6 +141,7 @@ tags_pkgs_values = {"openapi-gen": { "staging/src/k8s.io/api/networking/v1": ["true"], "staging/src/k8s.io/api/networking/v1beta1": ["true"], "staging/src/k8s.io/api/node/v1alpha1": ["true"], + "staging/src/k8s.io/api/node/v1beta1": ["true"], "staging/src/k8s.io/api/policy/v1beta1": ["true"], "staging/src/k8s.io/api/rbac/v1": ["true"], "staging/src/k8s.io/api/rbac/v1alpha1": ["true"], diff --git a/cmd/kube-apiserver/app/aggregator.go b/cmd/kube-apiserver/app/aggregator.go index ad7a120b05..acf5b071ca 100644 --- a/cmd/kube-apiserver/app/aggregator.go +++ b/cmd/kube-apiserver/app/aggregator.go @@ -276,7 +276,8 @@ var apiVersionPriorities = map[schema.GroupVersion]priority{ {Group: "coordination.k8s.io", Version: "v1"}: {group: 16500, version: 15}, {Group: "coordination.k8s.io", Version: "v1beta1"}: {group: 16500, version: 9}, {Group: "auditregistration.k8s.io", Version: "v1alpha1"}: {group: 16400, version: 1}, - {Group: "node.k8s.io", Version: "v1alpha1"}: {group: 16300, version: 9}, + {Group: "node.k8s.io", Version: "v1alpha1"}: {group: 16300, version: 1}, + {Group: "node.k8s.io", Version: "v1beta1"}: {group: 16300, version: 9}, // Append a new group to the end of the list if unsure. // You can use min(existing group)-100 as the initial value for a group. // Version can be set to 9 (to have space around) for a new group. diff --git a/hack/.golint_failures b/hack/.golint_failures index 5959909a0b..0744b90232 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -50,6 +50,7 @@ pkg/apis/extensions/v1beta1 pkg/apis/imagepolicy pkg/apis/networking pkg/apis/networking/v1 +pkg/apis/node/v1alpha1 pkg/apis/policy pkg/apis/policy/v1beta1 pkg/apis/policy/validation diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 3f6fc04cdd..f169a609b5 100755 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -81,6 +81,7 @@ imagepolicy.k8s.io/v1alpha1 \ networking.k8s.io/v1 \ networking.k8s.io/v1beta1 \ node.k8s.io/v1alpha1 \ +node.k8s.io/v1beta1 \ policy/v1beta1 \ rbac.authorization.k8s.io/v1 \ rbac.authorization.k8s.io/v1beta1 \ diff --git a/pkg/apis/node/BUILD b/pkg/apis/node/BUILD index b4a74b0d97..0aca389379 100644 --- a/pkg/apis/node/BUILD +++ b/pkg/apis/node/BUILD @@ -29,6 +29,7 @@ filegroup( ":package-srcs", "//pkg/apis/node/install:all-srcs", "//pkg/apis/node/v1alpha1:all-srcs", + "//pkg/apis/node/v1beta1:all-srcs", "//pkg/apis/node/validation:all-srcs", ], tags = ["automanaged"], diff --git a/pkg/apis/node/install/BUILD b/pkg/apis/node/install/BUILD index 769c90e9f1..3d2048b5f9 100644 --- a/pkg/apis/node/install/BUILD +++ b/pkg/apis/node/install/BUILD @@ -9,6 +9,7 @@ go_library( "//pkg/api/legacyscheme:go_default_library", "//pkg/apis/node:go_default_library", "//pkg/apis/node/v1alpha1:go_default_library", + "//pkg/apis/node/v1beta1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", ], diff --git a/pkg/apis/node/install/install.go b/pkg/apis/node/install/install.go index 3537915400..c794c8ec79 100644 --- a/pkg/apis/node/install/install.go +++ b/pkg/apis/node/install/install.go @@ -24,6 +24,7 @@ import ( "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/node" "k8s.io/kubernetes/pkg/apis/node/v1alpha1" + "k8s.io/kubernetes/pkg/apis/node/v1beta1" ) func init() { @@ -34,5 +35,6 @@ func init() { func Install(scheme *runtime.Scheme) { utilruntime.Must(node.AddToScheme(scheme)) utilruntime.Must(v1alpha1.AddToScheme(scheme)) - utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)) + utilruntime.Must(v1beta1.AddToScheme(scheme)) + utilruntime.Must(scheme.SetVersionPriority(v1beta1.SchemeGroupVersion)) } diff --git a/pkg/apis/node/v1beta1/BUILD b/pkg/apis/node/v1beta1/BUILD new file mode 100644 index 0000000000..692be926ae --- /dev/null +++ b/pkg/apis/node/v1beta1/BUILD @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "register.go", + "zz_generated.conversion.go", + ], + importpath = "k8s.io/kubernetes/pkg/apis/node/v1beta1", + visibility = ["//visibility:public"], + deps = [ + "//pkg/apis/node:go_default_library", + "//staging/src/k8s.io/api/node/v1beta1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/conversion:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/apis/node/v1beta1/doc.go b/pkg/apis/node/v1beta1/doc.go new file mode 100644 index 0000000000..5883bc5050 --- /dev/null +++ b/pkg/apis/node/v1beta1/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/node +// +k8s:conversion-gen-external-types=k8s.io/api/node/v1beta1 + +// +groupName=node.k8s.io + +package v1beta1 // import "k8s.io/kubernetes/pkg/apis/node/v1beta1" diff --git a/pkg/apis/node/v1beta1/register.go b/pkg/apis/node/v1beta1/register.go new file mode 100644 index 0000000000..e018e3b70e --- /dev/null +++ b/pkg/apis/node/v1beta1/register.go @@ -0,0 +1,39 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + nodev1beta1 "k8s.io/api/node/v1beta1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName for node API +const GroupName = "node.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + localSchemeBuilder = &nodev1beta1.SchemeBuilder + // AddToScheme node API registration + AddToScheme = localSchemeBuilder.AddToScheme +) diff --git a/pkg/master/BUILD b/pkg/master/BUILD index 5388d161a4..28bf854721 100644 --- a/pkg/master/BUILD +++ b/pkg/master/BUILD @@ -92,6 +92,7 @@ go_library( "//staging/src/k8s.io/api/networking/v1:go_default_library", "//staging/src/k8s.io/api/networking/v1beta1:go_default_library", "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", + "//staging/src/k8s.io/api/node/v1beta1:go_default_library", "//staging/src/k8s.io/api/policy/v1beta1:go_default_library", "//staging/src/k8s.io/api/rbac/v1:go_default_library", "//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library", diff --git a/pkg/master/master.go b/pkg/master/master.go index effc19b6df..ac3b603c0c 100644 --- a/pkg/master/master.go +++ b/pkg/master/master.go @@ -48,6 +48,7 @@ import ( networkingapiv1 "k8s.io/api/networking/v1" networkingapiv1beta1 "k8s.io/api/networking/v1beta1" nodev1alpha1 "k8s.io/api/node/v1alpha1" + nodev1beta1 "k8s.io/api/node/v1beta1" policyapiv1beta1 "k8s.io/api/policy/v1beta1" rbacv1 "k8s.io/api/rbac/v1" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" @@ -497,6 +498,7 @@ func DefaultAPIResourceConfigSource() *serverstorage.ResourceConfig { extensionsapiv1beta1.SchemeGroupVersion, networkingapiv1.SchemeGroupVersion, networkingapiv1beta1.SchemeGroupVersion, + nodev1beta1.SchemeGroupVersion, policyapiv1beta1.SchemeGroupVersion, rbacv1.SchemeGroupVersion, rbacv1beta1.SchemeGroupVersion, diff --git a/pkg/printers/internalversion/BUILD b/pkg/printers/internalversion/BUILD index 34b742ab35..69b34f33e4 100644 --- a/pkg/printers/internalversion/BUILD +++ b/pkg/printers/internalversion/BUILD @@ -22,6 +22,7 @@ go_test( "//pkg/apis/coordination:go_default_library", "//pkg/apis/core:go_default_library", "//pkg/apis/networking:go_default_library", + "//pkg/apis/node:go_default_library", "//pkg/apis/policy:go_default_library", "//pkg/apis/scheduling:go_default_library", "//pkg/apis/storage:go_default_library", @@ -69,6 +70,7 @@ go_library( "//pkg/apis/events/install:go_default_library", "//pkg/apis/extensions/install:go_default_library", "//pkg/apis/networking:go_default_library", + "//pkg/apis/node:go_default_library", "//pkg/apis/policy:go_default_library", "//pkg/apis/policy/install:go_default_library", "//pkg/apis/rbac:go_default_library", diff --git a/pkg/printers/internalversion/printers.go b/pkg/printers/internalversion/printers.go index bb87e91221..b3980bcd52 100644 --- a/pkg/printers/internalversion/printers.go +++ b/pkg/printers/internalversion/printers.go @@ -53,6 +53,7 @@ import ( api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/core/helper" "k8s.io/kubernetes/pkg/apis/networking" + nodeapi "k8s.io/kubernetes/pkg/apis/node" "k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/rbac" "k8s.io/kubernetes/pkg/apis/scheduling" @@ -447,6 +448,14 @@ func AddHandlers(h printers.PrintHandler) { h.TableHandler(priorityClassColumnDefinitions, printPriorityClass) h.TableHandler(priorityClassColumnDefinitions, printPriorityClassList) + runtimeClassColumnDefinitions := []metav1beta1.TableColumnDefinition{ + {Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]}, + {Name: "Handler", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["handler"]}, + {Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]}, + } + h.TableHandler(runtimeClassColumnDefinitions, printRuntimeClass) + h.TableHandler(runtimeClassColumnDefinitions, printRuntimeClassList) + AddDefaultHandlers(h) } @@ -1971,6 +1980,30 @@ func printPriorityClassList(list *scheduling.PriorityClassList, options printers return rows, nil } +func printRuntimeClass(obj *nodeapi.RuntimeClass, options printers.PrintOptions) ([]metav1beta1.TableRow, error) { + row := metav1beta1.TableRow{ + Object: runtime.RawExtension{Object: obj}, + } + + name := obj.Name + handler := obj.Handler + row.Cells = append(row.Cells, name, handler, translateTimestampSince(obj.CreationTimestamp)) + + return []metav1beta1.TableRow{row}, nil +} + +func printRuntimeClassList(list *nodeapi.RuntimeClassList, options printers.PrintOptions) ([]metav1beta1.TableRow, error) { + rows := make([]metav1beta1.TableRow, 0, len(list.Items)) + for i := range list.Items { + r, err := printRuntimeClass(&list.Items[i], options) + if err != nil { + return nil, err + } + rows = append(rows, r...) + } + return rows, nil +} + func printBoolPtr(value *bool) string { if value != nil { return printBool(*value) diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index 2bf55354ca..eab8351daa 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -51,6 +51,7 @@ import ( "k8s.io/kubernetes/pkg/apis/coordination" api "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/apis/networking" + nodeapi "k8s.io/kubernetes/pkg/apis/node" "k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/scheduling" "k8s.io/kubernetes/pkg/apis/storage" @@ -3556,6 +3557,50 @@ func TestPrintPriorityClass(t *testing.T) { } } +func TestPrintRuntimeClass(t *testing.T) { + tests := []struct { + rc nodeapi.RuntimeClass + expect string + }{ + { + nodeapi.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{ + Name: "rc1", + CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)}, + }, + Handler: "h1", + }, + "rc1\th1\t0s\n", + }, + { + nodeapi.RuntimeClass{ + ObjectMeta: metav1.ObjectMeta{ + Name: "rc2", + CreationTimestamp: metav1.Time{Time: time.Now().Add(-3e11)}, + }, + Handler: "h2", + }, + "rc2\th2\t5m\n", + }, + } + + buf := bytes.NewBuffer([]byte{}) + for _, test := range tests { + table, err := printers.NewTablePrinter().With(AddHandlers).PrintTable(&test.rc, printers.PrintOptions{}) + if err != nil { + t.Fatal(err) + } + verifyTable(t, table) + if err := printers.PrintTable(table, buf, printers.PrintOptions{NoHeaders: true}); err != nil { + t.Fatal(err) + } + if buf.String() != test.expect { + t.Fatalf("Expected: %s, got: %s", test.expect, buf.String()) + } + buf.Reset() + } +} + func verifyTable(t *testing.T, table *metav1beta1.Table) { var panicErr interface{} func() { diff --git a/pkg/registry/node/rest/BUILD b/pkg/registry/node/rest/BUILD index ec87beeb65..79e86b4f8c 100644 --- a/pkg/registry/node/rest/BUILD +++ b/pkg/registry/node/rest/BUILD @@ -7,8 +7,10 @@ go_library( visibility = ["//visibility:public"], deps = [ "//pkg/api/legacyscheme:go_default_library", + "//pkg/apis/node:go_default_library", "//pkg/registry/node/runtimeclass/storage:go_default_library", "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", + "//staging/src/k8s.io/api/node/v1beta1:go_default_library", "//staging/src/k8s.io/apiserver/pkg/registry/generic:go_default_library", "//staging/src/k8s.io/apiserver/pkg/registry/rest:go_default_library", "//staging/src/k8s.io/apiserver/pkg/server:go_default_library", diff --git a/pkg/registry/node/rest/runtime_class.go b/pkg/registry/node/rest/runtime_class.go index 761fb5362d..5d24226253 100644 --- a/pkg/registry/node/rest/runtime_class.go +++ b/pkg/registry/node/rest/runtime_class.go @@ -18,11 +18,13 @@ package rest import ( nodev1alpha1 "k8s.io/api/node/v1alpha1" + nodev1beta1 "k8s.io/api/node/v1beta1" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/registry/rest" genericapiserver "k8s.io/apiserver/pkg/server" serverstorage "k8s.io/apiserver/pkg/server/storage" "k8s.io/kubernetes/pkg/api/legacyscheme" + nodeinternal "k8s.io/kubernetes/pkg/apis/node" runtimeclassstorage "k8s.io/kubernetes/pkg/registry/node/runtimeclass/storage" ) @@ -31,11 +33,16 @@ type RESTStorageProvider struct{} // NewRESTStorage returns a RESTStorageProvider func (p RESTStorageProvider) NewRESTStorage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) (genericapiserver.APIGroupInfo, bool) { - apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(nodev1alpha1.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs) + apiGroupInfo := genericapiserver.NewDefaultAPIGroupInfo(nodeinternal.GroupName, legacyscheme.Scheme, legacyscheme.ParameterCodec, legacyscheme.Codecs) if apiResourceConfigSource.VersionEnabled(nodev1alpha1.SchemeGroupVersion) { apiGroupInfo.VersionedResourcesStorageMap[nodev1alpha1.SchemeGroupVersion.Version] = p.v1alpha1Storage(apiResourceConfigSource, restOptionsGetter) } + + if apiResourceConfigSource.VersionEnabled(nodev1beta1.SchemeGroupVersion) { + apiGroupInfo.VersionedResourcesStorageMap[nodev1beta1.SchemeGroupVersion.Version] = p.v1beta1Storage(apiResourceConfigSource, restOptionsGetter) + } + return apiGroupInfo, true } @@ -47,7 +54,15 @@ func (p RESTStorageProvider) v1alpha1Storage(apiResourceConfigSource serverstora return storage } +func (p RESTStorageProvider) v1beta1Storage(apiResourceConfigSource serverstorage.APIResourceConfigSource, restOptionsGetter generic.RESTOptionsGetter) map[string]rest.Storage { + storage := map[string]rest.Storage{} + s := runtimeclassstorage.NewREST(restOptionsGetter) + storage["runtimeclasses"] = s + + return storage +} + // GroupName is the group name for the storage provider func (p RESTStorageProvider) GroupName() string { - return nodev1alpha1.GroupName + return nodeinternal.GroupName } diff --git a/staging/src/k8s.io/api/BUILD b/staging/src/k8s.io/api/BUILD index 275080d5fd..364f85d0a5 100644 --- a/staging/src/k8s.io/api/BUILD +++ b/staging/src/k8s.io/api/BUILD @@ -83,6 +83,7 @@ filegroup( "//staging/src/k8s.io/api/networking/v1:all-srcs", "//staging/src/k8s.io/api/networking/v1beta1:all-srcs", "//staging/src/k8s.io/api/node/v1alpha1:all-srcs", + "//staging/src/k8s.io/api/node/v1beta1:all-srcs", "//staging/src/k8s.io/api/policy/v1beta1:all-srcs", "//staging/src/k8s.io/api/rbac/v1:all-srcs", "//staging/src/k8s.io/api/rbac/v1alpha1:all-srcs", diff --git a/staging/src/k8s.io/api/node/v1beta1/BUILD b/staging/src/k8s.io/api/node/v1beta1/BUILD new file mode 100644 index 0000000000..5ae9e598da --- /dev/null +++ b/staging/src/k8s.io/api/node/v1beta1/BUILD @@ -0,0 +1,36 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = [ + "doc.go", + "generated.pb.go", + "register.go", + "types.go", + "types_swagger_doc_generated.go", + "zz_generated.deepcopy.go", + ], + importmap = "k8s.io/kubernetes/vendor/k8s.io/api/node/v1beta1", + importpath = "k8s.io/api/node/v1beta1", + visibility = ["//visibility:public"], + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", + "//vendor/github.com/gogo/protobuf/proto:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/api/node/v1beta1/doc.go b/staging/src/k8s.io/api/node/v1beta1/doc.go new file mode 100644 index 0000000000..0e8338cf7a --- /dev/null +++ b/staging/src/k8s.io/api/node/v1beta1/doc.go @@ -0,0 +1,22 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// +k8s:deepcopy-gen=package +// +k8s:openapi-gen=true + +// +groupName=node.k8s.io + +package v1beta1 // import "k8s.io/api/node/v1beta1" diff --git a/staging/src/k8s.io/api/node/v1beta1/register.go b/staging/src/k8s.io/api/node/v1beta1/register.go new file mode 100644 index 0000000000..3c3b61ba40 --- /dev/null +++ b/staging/src/k8s.io/api/node/v1beta1/register.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// GroupName is the group name use in this package +const GroupName = "node.k8s.io" + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1beta1"} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + // SchemeBuilder is the scheme builder with scheme init functions to run for this API package + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // AddToScheme is a common registration function for mapping packaged scoped group & version keys to a scheme + AddToScheme = SchemeBuilder.AddToScheme +) + +// addKnownTypes adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &RuntimeClass{}, + &RuntimeClassList{}, + ) + + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go new file mode 100644 index 0000000000..993c6e5066 --- /dev/null +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -0,0 +1,65 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RuntimeClass defines a class of container runtime supported in the cluster. +// The RuntimeClass is used to determine which container runtime is used to run +// all containers in a pod. RuntimeClasses are (currently) manually defined by a +// user or cluster provisioner, and referenced in the PodSpec. The Kubelet is +// responsible for resolving the RuntimeClassName reference before running the +// pod. For more details, see +// https://git.k8s.io/enhancements/keps/sig-node/runtime-class.md +type RuntimeClass struct { + metav1.TypeMeta `json:",inline"` + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Handler specifies the underlying runtime and configuration that the CRI + // implementation will use to handle pods of this class. The possible values + // are specific to the node & CRI configuration. It is assumed that all + // handlers are available on every node, and handlers of the same name are + // equivalent on every node. + // For example, a handler called "runc" might specify that the runc OCI + // runtime (using native Linux containers) will be used to run the containers + // in a pod. + // The Handler must conform to the DNS Label (RFC 1123) requirements, and is + // immutable. + Handler string `json:"handler" protobuf:"bytes,2,opt,name=handler"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// RuntimeClassList is a list of RuntimeClass objects. +type RuntimeClassList struct { + metav1.TypeMeta `json:",inline"` + // Standard list metadata. + // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata + // +optional + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Items is a list of schema objects. + Items []RuntimeClass `json:"items" protobuf:"bytes,2,rep,name=items"` +} diff --git a/test/integration/apiserver/BUILD b/test/integration/apiserver/BUILD index bc8412d5a2..55f5959909 100644 --- a/test/integration/apiserver/BUILD +++ b/test/integration/apiserver/BUILD @@ -34,6 +34,7 @@ go_test( "//staging/src/k8s.io/api/batch/v2alpha1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/extensions/v1beta1:go_default_library", + "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", "//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library", "//staging/src/k8s.io/api/scheduling/v1beta1:go_default_library", "//staging/src/k8s.io/api/settings/v1alpha1:go_default_library", diff --git a/test/integration/apiserver/print_test.go b/test/integration/apiserver/print_test.go index 40d1355f21..1d091c7799 100644 --- a/test/integration/apiserver/print_test.go +++ b/test/integration/apiserver/print_test.go @@ -31,6 +31,7 @@ import ( auditregv1alpha1 "k8s.io/api/auditregistration/v1alpha1" batchv2alpha1 "k8s.io/api/batch/v2alpha1" extensionsv1beta1 "k8s.io/api/extensions/v1beta1" + nodev1alpha1 "k8s.io/api/node/v1alpha1" rbacv1alpha1 "k8s.io/api/rbac/v1alpha1" schedulerapi "k8s.io/api/scheduling/v1beta1" settingsv1alpha1 "k8s.io/api/settings/v1alpha1" @@ -150,6 +151,7 @@ func TestServerSidePrint(t *testing.T) { appsv1beta1.SchemeGroupVersion, appsv1beta2.SchemeGroupVersion, extensionsv1beta1.SchemeGroupVersion, + nodev1alpha1.SchemeGroupVersion, }, []schema.GroupVersionResource{ extensionsv1beta1.SchemeGroupVersion.WithResource("daemonsets"), diff --git a/test/integration/etcd/data.go b/test/integration/etcd/data.go index f6d84a8d7c..ab2ecacb16 100644 --- a/test/integration/etcd/data.go +++ b/test/integration/etcd/data.go @@ -485,6 +485,21 @@ func GetEtcdStorageData() map[schema.GroupVersionResource]StorageData { ExpectedEtcdPath: "/registry/auditsinks/sink1", }, // -- + + // k8s.io/kubernetes/pkg/apis/node/v1alpha1 + gvr("node.k8s.io", "v1alpha1", "runtimeclasses"): { + Stub: `{"metadata": {"name": "rc1"}, "spec": {"runtimeHandler": "h1"}}`, + ExpectedEtcdPath: "/registry/runtimeclasses/rc1", + ExpectedGVK: gvkP("node.k8s.io", "v1beta1", "RuntimeClass"), + }, + // -- + + // k8s.io/kubernetes/pkg/apis/node/v1beta1 + gvr("node.k8s.io", "v1beta1", "runtimeclasses"): { + Stub: `{"metadata": {"name": "rc2"}, "handler": "h2"}`, + ExpectedEtcdPath: "/registry/runtimeclasses/rc2", + }, + // -- } // k8s.io/kubernetes/pkg/apis/storage/v1beta1 diff --git a/test/integration/framework/BUILD b/test/integration/framework/BUILD index d8f30fa7c5..e6b14df36e 100644 --- a/test/integration/framework/BUILD +++ b/test/integration/framework/BUILD @@ -37,6 +37,7 @@ go_library( "//staging/src/k8s.io/api/certificates/v1beta1:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/api/extensions/v1beta1:go_default_library", + "//staging/src/k8s.io/api/node/v1alpha1:go_default_library", "//staging/src/k8s.io/api/rbac/v1alpha1:go_default_library", "//staging/src/k8s.io/api/storage/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/api/resource:go_default_library", diff --git a/test/integration/framework/master_utils.go b/test/integration/framework/master_utils.go index 9b98835f2b..b0464cdf56 100644 --- a/test/integration/framework/master_utils.go +++ b/test/integration/framework/master_utils.go @@ -33,6 +33,7 @@ import ( certificates "k8s.io/api/certificates/v1beta1" "k8s.io/api/core/v1" extensions "k8s.io/api/extensions/v1beta1" + nodev1alpha1 "k8s.io/api/node/v1alpha1" rbac "k8s.io/api/rbac/v1alpha1" storage "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/runtime" @@ -311,6 +312,10 @@ func NewMasterConfig() *master.Config { schema.GroupResource{Group: auditreg.GroupName, Resource: serverstorage.AllResources}, "", ns) + storageFactory.SetSerializer( + schema.GroupResource{Group: nodev1alpha1.GroupName, Resource: serverstorage.AllResources}, + "", + ns) genericConfig := genericapiserver.NewConfig(legacyscheme.Codecs) kubeVersion := version.Get()