From e4f3232e54db6aae994e2a7a44e377d98556e954 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Thu, 25 Jan 2018 22:38:31 -0500 Subject: [PATCH] Prefer apps/v1 storage for daemonsets, deployments, replicasets --- api/swagger-spec/resourceListing.json | 8 +++---- cmd/kube-apiserver/app/server.go | 8 +++---- pkg/apis/apps/install/install.go | 2 +- .../etcd/etcd_storage_path_test.go | 22 +++++++++---------- 4 files changed, 19 insertions(+), 21 deletions(-) diff --git a/api/swagger-spec/resourceListing.json b/api/swagger-spec/resourceListing.json index 3eadc0bae42..1c9928dfa95 100644 --- a/api/swagger-spec/resourceListing.json +++ b/api/swagger-spec/resourceListing.json @@ -154,16 +154,16 @@ "description": "get information of a group" }, { - "path": "/apis/apps/v1beta1", - "description": "API at /apis/apps/v1beta1" + "path": "/apis/apps/v1", + "description": "API at /apis/apps/v1" }, { "path": "/apis/apps/v1beta2", "description": "API at /apis/apps/v1beta2" }, { - "path": "/apis/apps/v1", - "description": "API at /apis/apps/v1" + "path": "/apis/apps/v1beta1", + "description": "API at /apis/apps/v1beta1" }, { "path": "/apis/apps", diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index 87eba74b8be..57fe695ac2b 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -587,11 +587,9 @@ func BuildStorageFactory(s *options.ServerRunOptions, apiResourceConfig *servers } storageFactory.AddCohabitatingResources(networking.Resource("networkpolicies"), extensions.Resource("networkpolicies")) - - // keep Deployments, Daemonsets and ReplicaSets in extensions for backwards compatibility, we'll have to migrate at some point, eventually - storageFactory.AddCohabitatingResources(extensions.Resource("deployments"), apps.Resource("deployments")) - storageFactory.AddCohabitatingResources(extensions.Resource("daemonsets"), apps.Resource("daemonsets")) - storageFactory.AddCohabitatingResources(extensions.Resource("replicasets"), apps.Resource("replicasets")) + storageFactory.AddCohabitatingResources(apps.Resource("deployments"), extensions.Resource("deployments")) + storageFactory.AddCohabitatingResources(apps.Resource("daemonsets"), extensions.Resource("daemonsets")) + storageFactory.AddCohabitatingResources(apps.Resource("replicasets"), extensions.Resource("replicasets")) storageFactory.AddCohabitatingResources(api.Resource("events"), events.Resource("events")) for _, override := range s.Etcd.EtcdServersOverrides { tokens := strings.Split(override, "#") diff --git a/pkg/apis/apps/install/install.go b/pkg/apis/apps/install/install.go index 73117127693..4f9dcfe9a18 100644 --- a/pkg/apis/apps/install/install.go +++ b/pkg/apis/apps/install/install.go @@ -38,7 +38,7 @@ func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *r if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ GroupName: apps.GroupName, - VersionPreferenceOrder: []string{v1beta1.SchemeGroupVersion.Version, v1beta2.SchemeGroupVersion.Version, v1.SchemeGroupVersion.Version}, + VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version, v1beta2.SchemeGroupVersion.Version, v1beta1.SchemeGroupVersion.Version}, AddInternalObjectsToScheme: apps.AddToScheme, }, announced.VersionToSchemeFunc{ diff --git a/test/integration/etcd/etcd_storage_path_test.go b/test/integration/etcd/etcd_storage_path_test.go index bdaf07ca664..370c6bf784e 100644 --- a/test/integration/etcd/etcd_storage_path_test.go +++ b/test/integration/etcd/etcd_storage_path_test.go @@ -132,15 +132,17 @@ var etcdStorageData = map[schema.GroupVersionResource]struct { gvr("apps", "v1beta1", "statefulsets"): { stub: `{"metadata": {"name": "ss1"}, "spec": {"selector": {"matchLabels": {"a": "b"}}, "template": {"metadata": {"labels": {"a": "b"}}}}}`, expectedEtcdPath: "/registry/statefulsets/etcdstoragepathtestnamespace/ss1", + expectedGVK: gvkP("apps", "v1", "StatefulSet"), }, gvr("apps", "v1beta1", "deployments"): { stub: `{"metadata": {"name": "deployment2"}, "spec": {"selector": {"matchLabels": {"f": "z"}}, "template": {"metadata": {"labels": {"f": "z"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/deployments/etcdstoragepathtestnamespace/deployment2", - expectedGVK: gvkP("extensions", "v1beta1", "Deployment"), + expectedGVK: gvkP("apps", "v1", "Deployment"), }, gvr("apps", "v1beta1", "controllerrevisions"): { stub: `{"metadata":{"name":"crs1"},"data":{"name":"abc","namespace":"default","creationTimestamp":null,"Spec":{"Replicas":0,"Selector":{"matchLabels":{"foo":"bar"}},"Template":{"creationTimestamp":null,"labels":{"foo":"bar"},"Spec":{"Volumes":null,"InitContainers":null,"Containers":null,"RestartPolicy":"Always","TerminationGracePeriodSeconds":null,"ActiveDeadlineSeconds":null,"DNSPolicy":"ClusterFirst","NodeSelector":null,"ServiceAccountName":"","AutomountServiceAccountToken":null,"NodeName":"","SecurityContext":null,"ImagePullSecrets":null,"Hostname":"","Subdomain":"","Affinity":null,"SchedulerName":"","Tolerations":null,"HostAliases":null}},"VolumeClaimTemplates":null,"ServiceName":""},"Status":{"ObservedGeneration":null,"Replicas":0}},"revision":0}`, expectedEtcdPath: "/registry/controllerrevisions/etcdstoragepathtestnamespace/crs1", + expectedGVK: gvkP("apps", "v1", "ControllerRevision"), }, // -- @@ -148,27 +150,27 @@ var etcdStorageData = map[schema.GroupVersionResource]struct { gvr("apps", "v1beta2", "statefulsets"): { stub: `{"metadata": {"name": "ss2"}, "spec": {"selector": {"matchLabels": {"a": "b"}}, "template": {"metadata": {"labels": {"a": "b"}}}}}`, expectedEtcdPath: "/registry/statefulsets/etcdstoragepathtestnamespace/ss2", - expectedGVK: gvkP("apps", "v1beta1", "StatefulSet"), + expectedGVK: gvkP("apps", "v1", "StatefulSet"), }, gvr("apps", "v1beta2", "deployments"): { stub: `{"metadata": {"name": "deployment3"}, "spec": {"selector": {"matchLabels": {"f": "z"}}, "template": {"metadata": {"labels": {"f": "z"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/deployments/etcdstoragepathtestnamespace/deployment3", - expectedGVK: gvkP("extensions", "v1beta1", "Deployment"), + expectedGVK: gvkP("apps", "v1", "Deployment"), }, gvr("apps", "v1beta2", "daemonsets"): { stub: `{"metadata": {"name": "ds5"}, "spec": {"selector": {"matchLabels": {"a": "b"}}, "template": {"metadata": {"labels": {"a": "b"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/daemonsets/etcdstoragepathtestnamespace/ds5", - expectedGVK: gvkP("extensions", "v1beta1", "DaemonSet"), + expectedGVK: gvkP("apps", "v1", "DaemonSet"), }, gvr("apps", "v1beta2", "replicasets"): { stub: `{"metadata": {"name": "rs2"}, "spec": {"selector": {"matchLabels": {"g": "h"}}, "template": {"metadata": {"labels": {"g": "h"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container4"}]}}}}`, expectedEtcdPath: "/registry/replicasets/etcdstoragepathtestnamespace/rs2", - expectedGVK: gvkP("extensions", "v1beta1", "ReplicaSet"), + expectedGVK: gvkP("apps", "v1", "ReplicaSet"), }, gvr("apps", "v1beta2", "controllerrevisions"): { stub: `{"metadata":{"name":"crs2"},"data":{"name":"abc","namespace":"default","creationTimestamp":null,"Spec":{"Replicas":0,"Selector":{"matchLabels":{"foo":"bar"}},"Template":{"creationTimestamp":null,"labels":{"foo":"bar"},"Spec":{"Volumes":null,"InitContainers":null,"Containers":null,"RestartPolicy":"Always","TerminationGracePeriodSeconds":null,"ActiveDeadlineSeconds":null,"DNSPolicy":"ClusterFirst","NodeSelector":null,"ServiceAccountName":"","AutomountServiceAccountToken":null,"NodeName":"","SecurityContext":null,"ImagePullSecrets":null,"Hostname":"","Subdomain":"","Affinity":null,"SchedulerName":"","Tolerations":null,"HostAliases":null}},"VolumeClaimTemplates":null,"ServiceName":""},"Status":{"ObservedGeneration":null,"Replicas":0}},"revision":0}`, expectedEtcdPath: "/registry/controllerrevisions/etcdstoragepathtestnamespace/crs2", - expectedGVK: gvkP("apps", "v1beta1", "ControllerRevision"), + expectedGVK: gvkP("apps", "v1", "ControllerRevision"), }, // -- @@ -176,27 +178,22 @@ var etcdStorageData = map[schema.GroupVersionResource]struct { gvr("apps", "v1", "daemonsets"): { stub: `{"metadata": {"name": "ds6"}, "spec": {"selector": {"matchLabels": {"a": "b"}}, "template": {"metadata": {"labels": {"a": "b"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/daemonsets/etcdstoragepathtestnamespace/ds6", - expectedGVK: gvkP("extensions", "v1beta1", "DaemonSet"), }, gvr("apps", "v1", "deployments"): { stub: `{"metadata": {"name": "deployment4"}, "spec": {"selector": {"matchLabels": {"f": "z"}}, "template": {"metadata": {"labels": {"f": "z"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/deployments/etcdstoragepathtestnamespace/deployment4", - expectedGVK: gvkP("extensions", "v1beta1", "Deployment"), }, gvr("apps", "v1", "statefulsets"): { stub: `{"metadata": {"name": "ss3"}, "spec": {"selector": {"matchLabels": {"a": "b"}}, "template": {"metadata": {"labels": {"a": "b"}}}}}`, expectedEtcdPath: "/registry/statefulsets/etcdstoragepathtestnamespace/ss3", - expectedGVK: gvkP("apps", "v1beta1", "StatefulSet"), }, gvr("apps", "v1", "replicasets"): { stub: `{"metadata": {"name": "rs3"}, "spec": {"selector": {"matchLabels": {"g": "h"}}, "template": {"metadata": {"labels": {"g": "h"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container4"}]}}}}`, expectedEtcdPath: "/registry/replicasets/etcdstoragepathtestnamespace/rs3", - expectedGVK: gvkP("extensions", "v1beta1", "ReplicaSet"), }, gvr("apps", "v1", "controllerrevisions"): { stub: `{"metadata":{"name":"crs3"},"data":{"name":"abc","namespace":"default","creationTimestamp":null,"Spec":{"Replicas":0,"Selector":{"matchLabels":{"foo":"bar"}},"Template":{"creationTimestamp":null,"labels":{"foo":"bar"},"Spec":{"Volumes":null,"InitContainers":null,"Containers":null,"RestartPolicy":"Always","TerminationGracePeriodSeconds":null,"ActiveDeadlineSeconds":null,"DNSPolicy":"ClusterFirst","NodeSelector":null,"ServiceAccountName":"","AutomountServiceAccountToken":null,"NodeName":"","SecurityContext":null,"ImagePullSecrets":null,"Hostname":"","Subdomain":"","Affinity":null,"SchedulerName":"","Tolerations":null,"HostAliases":null}},"VolumeClaimTemplates":null,"ServiceName":""},"Status":{"ObservedGeneration":null,"Replicas":0}},"revision":0}`, expectedEtcdPath: "/registry/controllerrevisions/etcdstoragepathtestnamespace/crs3", - expectedGVK: gvkP("apps", "v1beta1", "ControllerRevision"), }, // -- @@ -256,6 +253,7 @@ var etcdStorageData = map[schema.GroupVersionResource]struct { gvr("extensions", "v1beta1", "daemonsets"): { stub: `{"metadata": {"name": "ds1"}, "spec": {"selector": {"matchLabels": {"u": "t"}}, "template": {"metadata": {"labels": {"u": "t"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container5"}]}}}}`, expectedEtcdPath: "/registry/daemonsets/etcdstoragepathtestnamespace/ds1", + expectedGVK: gvkP("apps", "v1", "DaemonSet"), }, gvr("extensions", "v1beta1", "podsecuritypolicies"): { stub: `{"metadata": {"name": "psp1"}, "spec": {"fsGroup": {"rule": "RunAsAny"}, "privileged": true, "runAsUser": {"rule": "RunAsAny"}, "seLinux": {"rule": "MustRunAs"}, "supplementalGroups": {"rule": "RunAsAny"}}}`, @@ -273,10 +271,12 @@ var etcdStorageData = map[schema.GroupVersionResource]struct { gvr("extensions", "v1beta1", "deployments"): { stub: `{"metadata": {"name": "deployment1"}, "spec": {"selector": {"matchLabels": {"f": "z"}}, "template": {"metadata": {"labels": {"f": "z"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`, expectedEtcdPath: "/registry/deployments/etcdstoragepathtestnamespace/deployment1", + expectedGVK: gvkP("apps", "v1", "Deployment"), }, gvr("extensions", "v1beta1", "replicasets"): { stub: `{"metadata": {"name": "rs1"}, "spec": {"selector": {"matchLabels": {"g": "h"}}, "template": {"metadata": {"labels": {"g": "h"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container4"}]}}}}`, expectedEtcdPath: "/registry/replicasets/etcdstoragepathtestnamespace/rs1", + expectedGVK: gvkP("apps", "v1", "ReplicaSet"), }, // --