From fd9e9b01b1c79c47c7edb4980468f2675daebf27 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Wed, 19 Dec 2018 11:18:53 -0500 Subject: [PATCH] Remove uses of extensions/v1beta1 clients --- pkg/apis/core/validation/events_test.go | 11 +- pkg/controller/controller_utils.go | 2 +- .../namespaced_resources_deleter_test.go | 6 +- .../podautoscaler/horizontal_test.go | 14 +- .../podautoscaler/legacy_horizontal_test.go | 6 +- .../metrics/rest_metrics_client_test.go | 4 +- .../podautoscaler/replica_calculator_test.go | 8 +- pkg/controller/replication/conversion.go | 11 ++ .../apply/strategy/merge_conflict_test.go | 30 ++-- .../apply/strategy/merge_map_list_test.go | 88 +++++------ pkg/kubectl/apply/strategy/merge_map_test.go | 24 +-- .../strategy/merge_primitive_list_test.go | 32 ++-- .../apply/strategy/merge_primitive_test.go | 112 ++++++------- .../apply/strategy/replace_map_list_test.go | 8 +- .../apply/strategy/replace_map_test.go | 8 +- .../strategy/replace_primitive_list_test.go | 96 ++++++------ .../apply/strategy/retain_keys_test.go | 32 ++-- pkg/kubectl/apply/strategy/test_swagger.json | 148 ++++++++++++++---- pkg/kubectl/cmd/apply/apply_test.go | 6 +- pkg/kubectl/cmd/drain/drain.go | 2 +- pkg/kubectl/cmd/drain/drain_test.go | 24 +-- pkg/kubectl/cmd/testing/fake.go | 1 + .../openapi/validation/validation_test.go | 6 +- .../mapbasedselectorforobject_test.go | 86 ++++++++++ plugin/pkg/admission/gc/gc_admission_test.go | 8 +- .../pkg/apis/meta/v1/group_version_test.go | 4 +- .../pkg/server/resourceconfig/helpers_test.go | 2 +- test/cmd/apps.sh | 8 +- test/cmd/generic-resources.sh | 4 +- test/cmd/rbac.sh | 16 +- test/cmd/run.sh | 2 +- test/e2e/apimachinery/garbage_collector.go | 4 +- .../custom_metrics_stackdriver_autoscaling.go | 18 +-- test/e2e/framework/psp_util.go | 4 +- test/e2e/framework/rs_util.go | 2 +- test/e2e/framework/util.go | 18 +++ .../monitoring/custom_metrics_deployments.go | 19 +-- test/e2e/network/ingress.go | 12 +- test/e2e/scheduling/resource_quota.go | 21 +-- test/e2e/storage/persistent_volumes-local.go | 2 +- .../integration/deployment/deployment_test.go | 6 +- test/integration/deployment/util.go | 2 +- .../master/synthetic_master_test.go | 50 ++++-- .../integration/replicaset/replicaset_test.go | 1 + 44 files changed, 601 insertions(+), 367 deletions(-) diff --git a/pkg/apis/core/validation/events_test.go b/pkg/apis/core/validation/events_test.go index 1db7463f97..835862ba98 100644 --- a/pkg/apis/core/validation/events_test.go +++ b/pkg/apis/core/validation/events_test.go @@ -84,7 +84,7 @@ func TestValidateEvent(t *testing.T) { Namespace: metav1.NamespaceDefault, }, InvolvedObject: core.ObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "NoKind", Namespace: metav1.NamespaceDefault, }, @@ -97,7 +97,7 @@ func TestValidateEvent(t *testing.T) { Namespace: metav1.NamespaceDefault, }, InvolvedObject: core.ObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "batch/v1", Kind: "Job", Namespace: "foo", }, @@ -110,7 +110,7 @@ func TestValidateEvent(t *testing.T) { Namespace: metav1.NamespaceDefault, }, InvolvedObject: core.ObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "batch/v1", Kind: "Job", Namespace: metav1.NamespaceDefault, }, @@ -149,7 +149,7 @@ func TestValidateEvent(t *testing.T) { Namespace: metav1.NamespaceDefault, }, InvolvedObject: core.ObjectReference{ - APIVersion: "extensions", + APIVersion: "batch", Kind: "Job", Namespace: "foo", }, @@ -162,8 +162,7 @@ func TestValidateEvent(t *testing.T) { Namespace: "foo", }, InvolvedObject: core.ObjectReference{ - // must register in v1beta1 to be true - APIVersion: "extensions/v1beta1", + APIVersion: "batch/v1", Kind: "Job", Namespace: "foo", }, diff --git a/pkg/controller/controller_utils.go b/pkg/controller/controller_utils.go index 25d02a2938..dbcafd4fc0 100644 --- a/pkg/controller/controller_utils.go +++ b/pkg/controller/controller_utils.go @@ -412,7 +412,7 @@ type RealRSControl struct { var _ RSControlInterface = &RealRSControl{} func (r RealRSControl) PatchReplicaSet(namespace, name string, data []byte) error { - _, err := r.KubeClient.ExtensionsV1beta1().ReplicaSets(namespace).Patch(name, types.StrategicMergePatchType, data) + _, err := r.KubeClient.AppsV1().ReplicaSets(namespace).Patch(name, types.StrategicMergePatchType, data) return err } diff --git a/pkg/controller/namespace/deletion/namespaced_resources_deleter_test.go b/pkg/controller/namespace/deletion/namespaced_resources_deleter_test.go index 5a35633753..ae9770cad0 100644 --- a/pkg/controller/namespace/deletion/namespaced_resources_deleter_test.go +++ b/pkg/controller/namespace/deletion/namespaced_resources_deleter_test.go @@ -234,8 +234,8 @@ func TestSyncNamespaceThatIsTerminatingNonExperimental(t *testing.T) { testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{}) } -func TestSyncNamespaceThatIsTerminatingV1Beta1(t *testing.T) { - testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"extensions/v1beta1"}}) +func TestSyncNamespaceThatIsTerminatingV1(t *testing.T) { + testSyncNamespaceThatIsTerminating(t, &metav1.APIVersions{Versions: []string{"apps/v1"}}) } func TestSyncNamespaceThatIsActive(t *testing.T) { @@ -331,7 +331,7 @@ func testResources() []*metav1.APIResourceList { }, }, { - GroupVersion: "extensions/v1beta1", + GroupVersion: "apps/v1", APIResources: []metav1.APIResource{ { Name: "deployments", diff --git a/pkg/controller/podautoscaler/horizontal_test.go b/pkg/controller/podautoscaler/horizontal_test.go index 0cc8922835..06d20d012d 100644 --- a/pkg/controller/podautoscaler/horizontal_test.go +++ b/pkg/controller/podautoscaler/horizontal_test.go @@ -51,8 +51,8 @@ import ( "github.com/stretchr/testify/assert" + _ "k8s.io/kubernetes/pkg/apis/apps/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" - _ "k8s.io/kubernetes/pkg/apis/extensions/install" ) var statusOk = []autoscalingv2.HorizontalPodAutoscalerCondition{ @@ -862,7 +862,7 @@ func TestScaleUpDeployment(t *testing.T) { useMetricsAPI: true, resource: &fakeResource{ name: "test-dep", - apiVersion: "extensions/v1beta1", + apiVersion: "apps/v1", kind: "Deployment", }, } @@ -882,7 +882,7 @@ func TestScaleUpReplicaSet(t *testing.T) { useMetricsAPI: true, resource: &fakeResource{ name: "test-replicaset", - apiVersion: "extensions/v1beta1", + apiVersion: "apps/v1", kind: "ReplicaSet", }, } @@ -1033,7 +1033,7 @@ func TestScaleUpCMObject(t *testing.T) { Type: autoscalingv2.ObjectMetricSourceType, Object: &autoscalingv2.ObjectMetricSource{ DescribedObject: autoscalingv2.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: "some-deployment", }, @@ -1183,7 +1183,7 @@ func TestScaleDownCMObject(t *testing.T) { Type: autoscalingv2.ObjectMetricSourceType, Object: &autoscalingv2.ObjectMetricSource{ DescribedObject: autoscalingv2.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: "some-deployment", }, @@ -1392,7 +1392,7 @@ func TestToleranceCMObject(t *testing.T) { Type: autoscalingv2.ObjectMetricSourceType, Object: &autoscalingv2.ObjectMetricSource{ DescribedObject: autoscalingv2.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: "some-deployment", }, @@ -1860,7 +1860,7 @@ func TestConditionFailedGetMetrics(t *testing.T) { Type: autoscalingv2.ObjectMetricSourceType, Object: &autoscalingv2.ObjectMetricSource{ DescribedObject: autoscalingv2.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: "some-deployment", }, diff --git a/pkg/controller/podautoscaler/legacy_horizontal_test.go b/pkg/controller/podautoscaler/legacy_horizontal_test.go index 6d0bf6cdc4..deeb649b1d 100644 --- a/pkg/controller/podautoscaler/legacy_horizontal_test.go +++ b/pkg/controller/podautoscaler/legacy_horizontal_test.go @@ -50,9 +50,9 @@ import ( "github.com/stretchr/testify/assert" + _ "k8s.io/kubernetes/pkg/apis/apps/install" _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" _ "k8s.io/kubernetes/pkg/apis/core/install" - _ "k8s.io/kubernetes/pkg/apis/extensions/install" ) func (w fakeResponseWrapper) DoRaw() ([]byte, error) { @@ -588,7 +588,7 @@ func TestLegacyScaleUpDeployment(t *testing.T) { useMetricsAPI: true, resource: &fakeResource{ name: "test-dep", - apiVersion: "extensions/v1beta1", + apiVersion: "apps/v1", kind: "Deployment", }, } @@ -608,7 +608,7 @@ func TestLegacyScaleUpReplicaSet(t *testing.T) { useMetricsAPI: true, resource: &fakeResource{ name: "test-replicaset", - apiVersion: "extensions/v1beta1", + apiVersion: "apps/v1", kind: "ReplicaSet", }, } diff --git a/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go b/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go index d8de168fc4..d7475e6528 100644 --- a/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go +++ b/pkg/controller/podautoscaler/metrics/rest_metrics_client_test.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" core "k8s.io/client-go/testing" "k8s.io/kubernetes/pkg/api/legacyscheme" - _ "k8s.io/kubernetes/pkg/apis/extensions/install" + _ "k8s.io/kubernetes/pkg/apis/apps/install" cmapi "k8s.io/metrics/pkg/apis/custom_metrics/v1beta2" emapi "k8s.io/metrics/pkg/apis/external_metrics/v1beta1" metricsapi "k8s.io/metrics/pkg/apis/metrics/v1beta1" @@ -305,7 +305,7 @@ func TestRESTClientSingleObject(t *testing.T) { targetTimestamp: 1, reportedMetricPoints: []metricPoint{{10, 1}}, singleObject: &autoscalingapi.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: "some-dep", }, diff --git a/pkg/controller/podautoscaler/replica_calculator_test.go b/pkg/controller/podautoscaler/replica_calculator_test.go index ff71498278..c3342d6260 100644 --- a/pkg/controller/podautoscaler/replica_calculator_test.go +++ b/pkg/controller/podautoscaler/replica_calculator_test.go @@ -623,7 +623,7 @@ func TestReplicaCalcScaleUpCMObject(t *testing.T) { expectedUtilization: 20000, singleObject: &autoscalingv2.CrossVersionObjectReference{ Kind: "Deployment", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Name: "some-deployment", }, }, @@ -643,7 +643,7 @@ func TestReplicaCalcScaleUpCMObjectIgnoresUnreadyPods(t *testing.T) { expectedUtilization: 50000, singleObject: &autoscalingv2.CrossVersionObjectReference{ Kind: "Deployment", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Name: "some-deployment", }, }, @@ -758,7 +758,7 @@ func TestReplicaCalcScaleDownCMObject(t *testing.T) { expectedUtilization: 12000, singleObject: &autoscalingv2.CrossVersionObjectReference{ Kind: "Deployment", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Name: "some-deployment", }, }, @@ -916,7 +916,7 @@ func TestReplicaCalcToleranceCMObject(t *testing.T) { expectedUtilization: 20666, singleObject: &autoscalingv2.CrossVersionObjectReference{ Kind: "Deployment", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Name: "some-deployment", }, }, diff --git a/pkg/controller/replication/conversion.go b/pkg/controller/replication/conversion.go index 1c9ddb0ba1..3bb1df30a9 100644 --- a/pkg/controller/replication/conversion.go +++ b/pkg/controller/replication/conversion.go @@ -27,6 +27,7 @@ import ( "time" apps "k8s.io/api/apps/v1" + autoscalingv1 "k8s.io/api/autoscaling/v1" "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -239,6 +240,16 @@ func (c conversionClient) Patch(name string, pt types.PatchType, data []byte, su return nil, errors.New("Patch() is not implemented for conversionClient") } +func (c conversionClient) GetScale(name string, options metav1.GetOptions) (result *autoscalingv1.Scale, err error) { + // This is not used by RSC. + return nil, errors.New("GetScale() is not implemented for conversionClient") +} + +func (c conversionClient) UpdateScale(name string, scale *autoscalingv1.Scale) (result *autoscalingv1.Scale, err error) { + // This is not used by RSC. + return nil, errors.New("UpdateScale() is not implemented for conversionClient") +} + func convertSlice(rcList []*v1.ReplicationController) ([]*apps.ReplicaSet, error) { rsList := make([]*apps.ReplicaSet, 0, len(rcList)) for _, rc := range rcList { diff --git a/pkg/kubectl/apply/strategy/merge_conflict_test.go b/pkg/kubectl/apply/strategy/merge_conflict_test.go index 73ca6ca720..395f430303 100644 --- a/pkg/kubectl/apply/strategy/merge_conflict_test.go +++ b/pkg/kubectl/apply/strategy/merge_conflict_test.go @@ -26,19 +26,19 @@ var _ = Describe("Comparing fields of remote and recorded ", func() { Context("Test conflict in map fields of remote and recorded", func() { It("If conflicts found, expected return error", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: "key1" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo2: "baz2-1" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: "baz1-0" @@ -53,7 +53,7 @@ spec: Context("Test conflict in list fields of remote and recorded ", func() { It("If conflicts found, expected return false", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -62,7 +62,7 @@ metadata: - "d" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -70,7 +70,7 @@ metadata: - "b" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -87,7 +87,7 @@ metadata: Context("Test conflict in Map-List fields of remote and recorded ", func() { It("should leave the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -97,7 +97,7 @@ spec: image: image1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -107,7 +107,7 @@ spec: image: image2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -125,21 +125,21 @@ spec: Context("Test conflicts in nested map field", func() { It("If conflicts found, expected return error", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: name: "key1" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: name: "baz1-0" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: @@ -154,7 +154,7 @@ spec: Context("Test conflicts in complicated map, list", func() { It("Should catch conflict in key-value in map element", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -170,7 +170,7 @@ spec: hostPort: 2022 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -183,7 +183,7 @@ spec: hostPort: 2020 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: diff --git a/pkg/kubectl/apply/strategy/merge_map_list_test.go b/pkg/kubectl/apply/strategy/merge_map_list_test.go index f18eb875fc..8ff0825eb7 100644 --- a/pkg/kubectl/apply/strategy/merge_map_list_test.go +++ b/pkg/kubectl/apply/strategy/merge_map_list_test.go @@ -28,7 +28,7 @@ var _ = Describe("Merging fields of type list-of-map with openapi", func() { Context("where one of the items has been deleted resulting in the containers being empty", func() { It("should set the containers field to null", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -38,7 +38,7 @@ spec: image: image `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -46,7 +46,7 @@ spec: containers: `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -58,7 +58,7 @@ spec: image: image2 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -71,7 +71,7 @@ spec: Context("where one of the items has been deleted", func() { It("should be deleted from the result", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -83,7 +83,7 @@ spec: image: image-delete `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -93,7 +93,7 @@ spec: image: image-keep `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -105,7 +105,7 @@ spec: image: image-delete `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -121,7 +121,7 @@ spec: Context("where one of the items is only in the remote", func() { It("should leave the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -131,7 +131,7 @@ spec: image: image2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -141,7 +141,7 @@ spec: image: image2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -151,7 +151,7 @@ spec: image: image `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -169,7 +169,7 @@ spec: Context("where one of the items differs from the remote value and is missing from the recorded", func() { It("should update the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -177,7 +177,7 @@ spec: containers: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -187,7 +187,7 @@ spec: image: image:2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -197,7 +197,7 @@ spec: image: image:1 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -213,7 +213,7 @@ spec: Context("where one of the items differs from the remote value but matches the recorded", func() { It("should update the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -223,7 +223,7 @@ spec: image: image:2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -233,7 +233,7 @@ spec: image: image:2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -243,7 +243,7 @@ spec: image: image:1 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -259,7 +259,7 @@ spec: Context("where one of the items is missing from the remote but matches the recorded", func() { It("should add the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -269,7 +269,7 @@ spec: image: image:2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -279,7 +279,7 @@ spec: image: image:2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -287,7 +287,7 @@ spec: containers: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -303,7 +303,7 @@ spec: Context("where one of the items is missing from the remote and missing from the recorded ", func() { It("should add the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -312,7 +312,7 @@ spec: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -322,7 +322,7 @@ spec: image: image:2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -330,7 +330,7 @@ spec: containers: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -346,7 +346,7 @@ spec: Context("where the order of the resolved, local and remote lists differs", func() { It("should keep the order specified in local and append items appears only in remote", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -363,7 +363,7 @@ spec: timeoutSeconds: 4 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -383,7 +383,7 @@ spec: initialDelaySeconds: 18 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -403,7 +403,7 @@ spec: imagePullPolicy: Always `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -441,7 +441,7 @@ var _ = Describe("Merging fields of type list-of-map with openapi containing a m Context("where one of the items has been deleted", func() { It("should delete the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -457,7 +457,7 @@ spec: hostPort: 2022 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -470,7 +470,7 @@ spec: hostPort: 2020 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -487,7 +487,7 @@ spec: hostIP: "127.0.0.1" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -506,7 +506,7 @@ spec: Context("where one of the items has been updated", func() { It("should merge updates to the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -522,7 +522,7 @@ spec: hostPort: 2021 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -538,7 +538,7 @@ spec: hostPort: 2022 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -555,7 +555,7 @@ spec: hostIP: "127.0.0.1" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -578,7 +578,7 @@ spec: Context("where one of the items has been added", func() { It("should add the item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -591,7 +591,7 @@ spec: hostPort: 2020 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -607,7 +607,7 @@ spec: hostPort: 2022 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -621,7 +621,7 @@ spec: hostIP: "127.0.0.1" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: diff --git a/pkg/kubectl/apply/strategy/merge_map_test.go b/pkg/kubectl/apply/strategy/merge_map_test.go index f62497c511..95f37e6294 100644 --- a/pkg/kubectl/apply/strategy/merge_map_test.go +++ b/pkg/kubectl/apply/strategy/merge_map_test.go @@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type map with openapi for some fields", func Context("where a field has been deleted", func() { It("should delete the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -35,14 +35,14 @@ spec: image: "1" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 foo2: null `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -57,7 +57,7 @@ spec: image: "3" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -72,7 +72,7 @@ spec: Context("where a field is has been added", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: @@ -80,7 +80,7 @@ spec: image: "1" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -92,12 +92,12 @@ spec: image: "2" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -115,7 +115,7 @@ spec: Context("where a field is has been updated", func() { It("should update the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo1: @@ -123,7 +123,7 @@ spec: image: "1-1" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -135,7 +135,7 @@ spec: image: "2-1" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 2 @@ -147,7 +147,7 @@ spec: image: "2-0" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 diff --git a/pkg/kubectl/apply/strategy/merge_primitive_list_test.go b/pkg/kubectl/apply/strategy/merge_primitive_list_test.go index 34757b6984..11c643efea 100644 --- a/pkg/kubectl/apply/strategy/merge_primitive_list_test.go +++ b/pkg/kubectl/apply/strategy/merge_primitive_list_test.go @@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type list-of-primitive with openapi", func() Context("where one of the items has been deleted", func() { It("should delete the deleted item", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -35,7 +35,7 @@ metadata: - "c" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -43,7 +43,7 @@ metadata: - "c" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -52,7 +52,7 @@ metadata: - "c" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -66,7 +66,7 @@ metadata: Context("where one of the items is only on the remote", func() { It("should move the remote-only item to the end but keep it", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -74,7 +74,7 @@ metadata: - "b" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -82,7 +82,7 @@ metadata: - "b" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -91,7 +91,7 @@ metadata: - "a" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -106,7 +106,7 @@ metadata: Context("where one of the items is repeated", func() { It("should de-duplicate the repeated items", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -114,7 +114,7 @@ metadata: - "b" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -123,7 +123,7 @@ metadata: - "a" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -131,7 +131,7 @@ metadata: - "b" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -145,7 +145,7 @@ metadata: Context("where some items are deleted and others are on remote only", func() { It("should retain the correct items in the correct order", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -154,7 +154,7 @@ metadata: - "c" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -163,7 +163,7 @@ metadata: - "a" `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: @@ -174,7 +174,7 @@ metadata: - "e" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: finalizers: diff --git a/pkg/kubectl/apply/strategy/merge_primitive_test.go b/pkg/kubectl/apply/strategy/merge_primitive_test.go index d222901285..fc245c0d6f 100644 --- a/pkg/kubectl/apply/strategy/merge_primitive_test.go +++ b/pkg/kubectl/apply/strategy/merge_primitive_test.go @@ -26,7 +26,7 @@ var _ = Describe("Merging fields of type map with openapi", func() { Context("where a field has been deleted", func() { It("should delete the field when it is the only field in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - recorded/remote match @@ -35,14 +35,14 @@ spec: progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - not present in recorded replicas: null `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -51,7 +51,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) @@ -60,7 +60,7 @@ spec: It("should delete the field when there are other fields in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - recorded/remote match @@ -69,7 +69,7 @@ spec: progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - not present in recorded @@ -78,7 +78,7 @@ spec: revisionHistoryLimit: 1 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -88,7 +88,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: revisionHistoryLimit: 1 @@ -100,14 +100,14 @@ spec: Context("where a field is has been added", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: paused: true progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # Add this - it is missing from recorded and remote @@ -118,12 +118,12 @@ spec: progressDeadlineSeconds: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -137,14 +137,14 @@ spec: Context("where a field is has been updated", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: paused: true progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # Missing from recorded @@ -155,7 +155,7 @@ spec: progressDeadlineSeconds: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 2 @@ -163,7 +163,7 @@ spec: progressDeadlineSeconds: 3 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -175,26 +175,26 @@ spec: It("should update the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 2 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: replicas: 3 @@ -208,7 +208,7 @@ var _ = Describe("Merging fields of type map without openapi", func() { Context("where a field has been deleted", func() { It("should delete the field when it is the only field in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # delete - recorded/remote match @@ -217,14 +217,14 @@ spec: progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # delete - not present in recorded replicas: null `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 @@ -233,7 +233,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: `) @@ -242,7 +242,7 @@ spec: It("should delete the field when there are other fields in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # delete - recorded/remote match @@ -251,7 +251,7 @@ spec: progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # delete - not present in recorded @@ -260,7 +260,7 @@ spec: revisionHistoryLimit: 1 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 @@ -270,7 +270,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: revisionHistoryLimit: 1 @@ -282,14 +282,14 @@ spec: Context("where a field is has been added", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: paused: true progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # Add this - it is missing from recorded and remote @@ -300,12 +300,12 @@ spec: progressDeadlineSeconds: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 @@ -319,14 +319,14 @@ spec: Context("where a field is has been updated", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: paused: true progressDeadlineSeconds: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: # Matches recorded @@ -337,7 +337,7 @@ spec: progressDeadlineSeconds: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 2 @@ -345,7 +345,7 @@ spec: progressDeadlineSeconds: 3 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 @@ -357,26 +357,26 @@ spec: It("should update the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 2 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: replicas: 3 @@ -390,7 +390,7 @@ var _ = Describe("Merging fields of type map with openapi", func() { Context("where a field has been deleted", func() { It("should delete the field when it is the only field in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - recorded/remote match @@ -399,14 +399,14 @@ spec: bar: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - not present in recorded baz: null `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: baz: 3 @@ -415,7 +415,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) @@ -424,7 +424,7 @@ spec: It("should delete the field when there are other fields in the map", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - recorded/remote match @@ -433,7 +433,7 @@ spec: bar: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # delete - not present in recorded @@ -442,7 +442,7 @@ spec: biz: 1 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: bar: 3 @@ -452,7 +452,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: biz: 1 @@ -464,14 +464,14 @@ spec: Context("where a field is has been added", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo: true biz: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # Add this - it is missing from recorded and remote @@ -482,12 +482,12 @@ spec: biz: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: baz: 3 @@ -501,14 +501,14 @@ spec: Context("where a field is has been updated", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: foo: true baz: 1 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: # Missing from recorded @@ -519,7 +519,7 @@ spec: baz: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: bar: 2 @@ -527,7 +527,7 @@ spec: baz: 3 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: bar: 3 diff --git a/pkg/kubectl/apply/strategy/replace_map_list_test.go b/pkg/kubectl/apply/strategy/replace_map_list_test.go index 75819c92c5..025f0ca810 100644 --- a/pkg/kubectl/apply/strategy/replace_map_list_test.go +++ b/pkg/kubectl/apply/strategy/replace_map_list_test.go @@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() { Context("where a field is has been updated", func() { It("should replace the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: bar: @@ -36,7 +36,7 @@ spec: value: 2 `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: bar: @@ -46,7 +46,7 @@ spec: value: 2 `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: bar: @@ -58,7 +58,7 @@ spec: value: 4 `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: bar: diff --git a/pkg/kubectl/apply/strategy/replace_map_test.go b/pkg/kubectl/apply/strategy/replace_map_test.go index e6873c17af..1feb64d2ec 100644 --- a/pkg/kubectl/apply/strategy/replace_map_test.go +++ b/pkg/kubectl/apply/strategy/replace_map_test.go @@ -33,7 +33,7 @@ var _ = Describe("Replacing fields of type map with openapi for some fields", fu Context("where a field is has been updated", func() { It("should update the field", func() { recorded := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: ReplicaSet spec: template: @@ -42,7 +42,7 @@ spec: image: image1 `) local := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: ReplicaSet spec: template: @@ -51,7 +51,7 @@ spec: image: image1 `) remote := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: ReplicaSet spec: template: @@ -64,7 +64,7 @@ spec: image: image3 `) expected := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: ReplicaSet spec: template: diff --git a/pkg/kubectl/apply/strategy/replace_primitive_list_test.go b/pkg/kubectl/apply/strategy/replace_primitive_list_test.go index b83e7fdfda..0bc95b5a2d 100644 --- a/pkg/kubectl/apply/strategy/replace_primitive_list_test.go +++ b/pkg/kubectl/apply/strategy/replace_primitive_list_test.go @@ -26,7 +26,7 @@ var _ = Describe("Replacing fields of type list with openapi", func() { Context("where the field has been deleted", func() { It("should delete the field if present in recorded and missing from local.", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -38,7 +38,7 @@ spec: - b `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -47,7 +47,7 @@ spec: - name: container `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -62,7 +62,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -75,7 +75,7 @@ spec: It("should delete the field if missing in recorded and set to null in local.", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -84,7 +84,7 @@ spec: - name: container `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -95,7 +95,7 @@ spec: `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -109,7 +109,7 @@ spec: - "y" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -124,14 +124,14 @@ spec: Context("where the field is has been added", func() { It("should add the field when missing from recorded", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: spec: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -144,14 +144,14 @@ spec: - c `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -168,7 +168,7 @@ spec: It("should add the field when even when present in recorded", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -181,7 +181,7 @@ spec: - c `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -194,14 +194,14 @@ spec: - c `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -218,12 +218,12 @@ spec: It("should add the field when the parent field is missing as well", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -236,12 +236,12 @@ spec: - c `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -260,7 +260,7 @@ spec: Context("where a field is has been updated", func() { It("should replace the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -273,7 +273,7 @@ spec: - c `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -286,7 +286,7 @@ spec: - f `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: spec: @@ -302,7 +302,7 @@ spec: - "y" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -319,7 +319,7 @@ spec: It("should replace the field even if recorded matches", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -332,7 +332,7 @@ spec: - f `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -345,7 +345,7 @@ spec: - f `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: spec: @@ -361,7 +361,7 @@ spec: - "y" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -378,7 +378,7 @@ spec: It("should replace the field even if the only change is ordering", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -391,7 +391,7 @@ spec: - f `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -404,7 +404,7 @@ spec: - f `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: spec: @@ -418,7 +418,7 @@ spec: - c `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -439,7 +439,7 @@ var _ = Describe("Replacing fields of type list with openapi for the type, but n Context("where a field is has been updated", func() { It("should replace the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -452,7 +452,7 @@ spec: - c `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -471,7 +471,7 @@ spec: - g `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: spec: @@ -503,7 +503,7 @@ spec: - m `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -530,7 +530,7 @@ var _ = Describe("Replacing fields of type list without openapi", func() { Context("where the field has been deleted", func() { It("should delete the field.", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -539,14 +539,14 @@ spec: - b `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: arguments: `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -570,7 +570,7 @@ spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -587,7 +587,7 @@ spec: Context("where the field is has been added", func() { It("should add the field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -598,7 +598,7 @@ spec: - "y" `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -616,12 +616,12 @@ spec: - w `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -643,7 +643,7 @@ spec: Context("where a field is has been updated", func() { It("should replace field", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -657,7 +657,7 @@ spec: - u `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: @@ -677,7 +677,7 @@ spec: - u `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: spec: @@ -698,7 +698,7 @@ spec: - "t" `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Foo spec: template: diff --git a/pkg/kubectl/apply/strategy/retain_keys_test.go b/pkg/kubectl/apply/strategy/retain_keys_test.go index 481da91a09..edc6a4a78d 100644 --- a/pkg/kubectl/apply/strategy/retain_keys_test.go +++ b/pkg/kubectl/apply/strategy/retain_keys_test.go @@ -26,20 +26,20 @@ var _ = Describe("Merging fields with the retainkeys strategy", func() { Context("where some fields are only defined remotely", func() { It("should drop those fields ", func() { recorded := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: `) local := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: type: Recreate `) remote := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: @@ -49,7 +49,7 @@ spec: maxSurge: 1 `) expected := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: @@ -62,13 +62,13 @@ spec: Context("where some fields are defined both locally and remotely", func() { It("should merge those fields", func() { recorded := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: `) local := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: @@ -77,7 +77,7 @@ spec: maxUnavailable: 2 `) remote := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: @@ -86,7 +86,7 @@ spec: maxSurge: 1 `) expected := create(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: strategy: @@ -102,14 +102,14 @@ spec: Context("where the elements are in a list and some fields are only defined remotely", func() { It("should drop those fields ", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: spec: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -119,7 +119,7 @@ spec: emptyDir: `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -130,7 +130,7 @@ spec: path: /tmp/cache-volume `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -146,14 +146,14 @@ spec: Context("where the elements are in a list", func() { It("the fields defined both locally and remotely should be merged", func() { recorded := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: spec: `) local := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -165,7 +165,7 @@ spec: emptyDir: `) remote := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: @@ -177,7 +177,7 @@ spec: type: Directory `) expected := create(` -apiVersion: apps/v1beta1 +apiVersion: apps/v1 kind: Deployment spec: template: diff --git a/pkg/kubectl/apply/strategy/test_swagger.json b/pkg/kubectl/apply/strategy/test_swagger.json index 57f69314d6..57c014f6ab 100644 --- a/pkg/kubectl/apply/strategy/test_swagger.json +++ b/pkg/kubectl/apply/strategy/test_swagger.json @@ -1,11 +1,10 @@ { "swagger": "2.0", "info": { - "title": "Kubernetes", - "version": "v1.9.0" - }, - "paths": { + "title": "Kubernetes", + "version": "v1.9.0" }, + "paths": {}, "definitions": { "io.k8s.api.core.v1.Container": { "description": "A single application container that you want to run within a pod.", @@ -63,8 +62,8 @@ } } }, - "io.k8s.api.apps.v1beta1.Deployment": { - "description": "DEPRECATED - This group version of Deployment is deprecated by apps/v1beta2/Deployment. See the release notes for more information. Deployment enables declarative updates for Pods and ReplicaSets.", + "io.k8s.api.apps.v1.Deployment": { + "description": "Deployment enables declarative updates for Pods and ReplicaSets.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", @@ -80,20 +79,21 @@ }, "spec": { "description": "Specification of the desired behavior of the Deployment.", - "$ref": "#/definitions/io.k8s.api.apps.v1beta1.DeploymentSpec" + "$ref": "#/definitions/io.k8s.api.apps.v1.DeploymentSpec" } }, "x-kubernetes-group-version-kind": [ { "group": "apps", "kind": "Deployment", - "version": "v1beta1" + "version": "v1" } ] }, - "io.k8s.api.apps.v1beta1.DeploymentSpec": { + "io.k8s.api.apps.v1.DeploymentSpec": { "description": "DeploymentSpec is the specification of the desired behavior of the Deployment.", "required": [ + "selector", "template" ], "properties": { @@ -107,7 +107,7 @@ "type": "boolean" }, "progressDeadlineSeconds": { - "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Once autoRollback is implemented, the deployment controller will automatically rollback failed deployments. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", + "description": "The maximum time in seconds for a deployment to make progress before it is considered to be failed. The deployment controller will continue to process failed deployments and a condition with a ProgressDeadlineExceeded reason will be surfaced in the deployment status. Note that progress will not be estimated during the time a deployment is paused. Defaults to 600s.", "type": "integer", "format": "int32" }, @@ -117,16 +117,56 @@ "format": "int32" }, "revisionHistoryLimit": { - "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 2.", + "description": "The number of old ReplicaSets to retain to allow rollback. This is a pointer to distinguish between explicit zero and not specified. Defaults to 10.", "type": "integer", "format": "int32" }, + "selector": { + "description": "Label selector for pods. Existing ReplicaSets whose pods are selected by this will be the ones affected by this deployment. It must match the pod template's labels.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, + "strategy": { + "description": "The deployment strategy to use to replace existing pods with new ones.", + "x-kubernetes-patch-strategy": "retainKeys", + "$ref": "#/definitions/io.k8s.api.apps.v1.DeploymentStrategy" + }, "template": { "description": "Template describes the pods that will be created.", "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" } } }, + "io.k8s.api.apps.v1.DeploymentStrategy": { + "description": "DeploymentStrategy describes how to replace existing pods with new ones.", + "properties": { + "rollingUpdate": { + "description": "Rolling update config params. Present only if DeploymentStrategyType = RollingUpdate.", + "$ref": "#/definitions/io.k8s.api.apps.v1.RollingUpdateDeployment" + }, + "type": { + "description": "Type of deployment. Can be \"Recreate\" or \"RollingUpdate\". Default is RollingUpdate.", + "type": "string" + } + } + }, + "io.k8s.api.apps.v1.RollingUpdateDeployment": { + "description": "Spec to control the desired behavior of rolling update.", + "properties": { + "maxSurge": { + "description": "The maximum number of pods that can be scheduled above the desired number of pods. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number is calculated from percentage by rounding up. Defaults to 25%. Example: when this is set to 30%, the new ReplicaSet can be scaled up immediately when the rolling update starts, such that the total number of old and new pods do not exceed 130% of desired pods. Once old pods have been killed, new ReplicaSet can be scaled up further, ensuring that total number of pods running at any time during the update is at most 130% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + }, + "maxUnavailable": { + "description": "The maximum number of pods that can be unavailable during the update. Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%). Absolute number is calculated from percentage by rounding down. This can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set to 30%, the old ReplicaSet can be scaled down to 70% of desired pods immediately when the rolling update starts. Once new pods are ready, old ReplicaSet can be scaled down further, followed by scaling up the new ReplicaSet, ensuring that the total number of pods available at all times during the update is at least 70% of desired pods.", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.util.intstr.IntOrString" + } + } + }, + "io.k8s.apimachinery.pkg.util.intstr.IntOrString": { + "description": "IntOrString is a type that can hold an int32 or a string. When used in JSON or YAML marshalling and unmarshalling, it produces or consumes the inner type. This allows you to have, for example, a JSON field that can accept a name or number.", + "type": "string", + "format": "int-or-string" + }, "io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta": { "description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create.", "properties": { @@ -184,8 +224,8 @@ } } }, - "io.k8s.api.extensions.v1beta1.ReplicaSet": { - "description": "DEPRECATED - This group version of ReplicaSet is deprecated by apps/v1beta2/ReplicaSet. See the release notes for more information. ReplicaSet represents the configuration of a ReplicaSet.", + "io.k8s.api.apps.v1.ReplicaSet": { + "description": "ReplicaSet ensures that a specified number of pod replicas are running at any given time.", "properties": { "apiVersion": { "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", @@ -201,21 +241,22 @@ }, "spec": { "description": "Spec defines the specification of the desired behavior of the ReplicaSet. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status", - "$ref": "#/definitions/io.k8s.api.extensions.v1beta1.ReplicaSetSpec", - "x-kubernetes-patch-strategy": "replace" - + "$ref": "#/definitions/io.k8s.api.apps.v1.ReplicaSetSpec" } }, "x-kubernetes-group-version-kind": [ { - "group": "extensions", + "group": "apps", "kind": "ReplicaSet", - "version": "v1beta1" + "version": "v1" } ] }, - "io.k8s.api.extensions.v1beta1.ReplicaSetSpec": { + "io.k8s.api.apps.v1.ReplicaSetSpec": { "description": "ReplicaSetSpec is the specification of a ReplicaSet.", + "required": [ + "selector" + ], "properties": { "minReadySeconds": { "description": "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)", @@ -227,24 +268,73 @@ "type": "integer", "format": "int32" }, + "selector": { + "description": "Selector is a label query over pods that should match the replica count. Label keys and values that must match in order to be controlled by this replica set. It must match the pod template's labels. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#label-selectors", + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" + }, "template": { "description": "Template is the object that describes the pod that will be created if insufficient replicas are detected. More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#pod-template", "$ref": "#/definitions/io.k8s.api.core.v1.PodTemplateSpec" } } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector": { + "description": "A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.", + "properties": { + "matchExpressions": { + "description": "matchExpressions is a list of label selector requirements. The requirements are ANDed.", + "type": "array", + "items": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement" + } + }, + "matchLabels": { + "description": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is \"key\", the operator is \"In\", and the values array contains only \"value\". The requirements are ANDed.", + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, + "io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement": { + "description": "A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.", + "required": [ + "key", + "operator" + ], + "properties": { + "key": { + "description": "key is the label key that the selector applies to.", + "type": "string", + "x-kubernetes-patch-merge-key": "key", + "x-kubernetes-patch-strategy": "merge" + }, + "operator": { + "description": "operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.", + "type": "string" + }, + "values": { + "description": "values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.", + "type": "array", + "items": { + "type": "string" + } + } + } } }, "securityDefinitions": { - "BearerToken": { - "description": "Bearer Token authentication", - "type": "apiKey", - "name": "authorization", - "in": "header" - } + "BearerToken": { + "description": "Bearer Token authentication", + "type": "apiKey", + "name": "authorization", + "in": "header" + } }, "security": [ - { - "BearerToken": [] - } + { + "BearerToken": [] + } ] - } +} \ No newline at end of file diff --git a/pkg/kubectl/cmd/apply/apply_test.go b/pkg/kubectl/cmd/apply/apply_test.go index 6c21e92d65..36fcad29f5 100644 --- a/pkg/kubectl/cmd/apply/apply_test.go +++ b/pkg/kubectl/cmd/apply/apply_test.go @@ -32,8 +32,8 @@ import ( "github.com/googleapis/gnostic/OpenAPIv2" "github.com/spf13/cobra" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" kubeerr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -876,7 +876,7 @@ const ( func readDeploymentFromFile(t *testing.T, file string) []byte { raw := readBytesFromFile(t, file) - obj := &extensionsv1beta1.Deployment{} + obj := &appsv1.Deployment{} if err := runtime.DecodeInto(codec, raw, obj); err != nil { t.Fatal(err) } @@ -948,7 +948,7 @@ func TestApplyNULLPreservation(t *testing.T) { cmd.Run(cmd, []string{}) - expected := "deployment.extensions/" + deploymentName + "\n" + expected := "deployment.apps/" + deploymentName + "\n" if buf.String() != expected { t.Fatalf("unexpected output: %s\nexpected: %s", buf.String(), expected) } diff --git a/pkg/kubectl/cmd/drain/drain.go b/pkg/kubectl/cmd/drain/drain.go index 4f4d2d88b0..a7e50e9d7e 100644 --- a/pkg/kubectl/cmd/drain/drain.go +++ b/pkg/kubectl/cmd/drain/drain.go @@ -401,7 +401,7 @@ func (o *DrainOptions) daemonsetFilter(pod corev1.Pod) (bool, *warning, *fatal) return true, nil, nil } - if _, err := o.client.ExtensionsV1beta1().DaemonSets(pod.Namespace).Get(controllerRef.Name, metav1.GetOptions{}); err != nil { + if _, err := o.client.AppsV1().DaemonSets(pod.Namespace).Get(controllerRef.Name, metav1.GetOptions{}); err != nil { // remove orphaned pods with a warning if --force is used if apierrors.IsNotFound(err) && o.Force { return true, &warning{err.Error()}, nil diff --git a/pkg/kubectl/cmd/drain/drain_test.go b/pkg/kubectl/cmd/drain/drain_test.go index d0a3a4e17e..d0c3eb6623 100644 --- a/pkg/kubectl/cmd/drain/drain_test.go +++ b/pkg/kubectl/cmd/drain/drain_test.go @@ -33,9 +33,9 @@ import ( "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" + appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - extensionsv1beta1 "k8s.io/api/extensions/v1beta1" policyv1beta1 "k8s.io/api/policy/v1beta1" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -294,13 +294,13 @@ func TestDrain(t *testing.T) { }, } - ds := extensionsv1beta1.DaemonSet{ + ds := appsv1.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ Name: "ds", Namespace: "default", CreationTimestamp: metav1.Time{Time: time.Now()}, }, - Spec: extensionsv1beta1.DaemonSetSpec{ + Spec: appsv1.DaemonSetSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, }, } @@ -313,7 +313,7 @@ func TestDrain(t *testing.T) { Labels: labels, OwnerReferences: []metav1.OwnerReference{ { - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "DaemonSet", Name: "ds", BlockOwnerDeletion: boolptr(true), @@ -334,7 +334,7 @@ func TestDrain(t *testing.T) { Labels: labels, OwnerReferences: []metav1.OwnerReference{ { - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "DaemonSet", Name: "ds", BlockOwnerDeletion: boolptr(true), @@ -358,7 +358,7 @@ func TestDrain(t *testing.T) { Labels: labels, OwnerReferences: []metav1.OwnerReference{ { - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "DaemonSet", Name: "ds", BlockOwnerDeletion: boolptr(true), @@ -457,14 +457,14 @@ func TestDrain(t *testing.T) { }, } - rs := extensionsv1beta1.ReplicaSet{ + rs := appsv1.ReplicaSet{ ObjectMeta: metav1.ObjectMeta{ Name: "rs", Namespace: "default", CreationTimestamp: metav1.Time{Time: time.Now()}, Labels: labels, }, - Spec: extensionsv1beta1.ReplicaSetSpec{ + Spec: appsv1.ReplicaSetSpec{ Selector: &metav1.LabelSelector{MatchLabels: labels}, }, } @@ -546,7 +546,7 @@ func TestDrain(t *testing.T) { expected *corev1.Node pods []corev1.Pod rcs []corev1.ReplicationController - replicaSets []extensionsv1beta1.ReplicaSet + replicaSets []appsv1.ReplicaSet args []string expectWarning string expectFatal bool @@ -648,7 +648,7 @@ func TestDrain(t *testing.T) { node: node, expected: cordonedNode, pods: []corev1.Pod{rsPod}, - replicaSets: []extensionsv1beta1.ReplicaSet{rs}, + replicaSets: []appsv1.ReplicaSet{rs}, args: []string{"node"}, expectFatal: false, expectDelete: true, @@ -776,7 +776,7 @@ func TestDrain(t *testing.T) { case m.isFor("GET", "/namespaces/default/daemonsets/ds"): return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &ds)}, nil case m.isFor("GET", "/namespaces/default/daemonsets/missing-ds"): - return &http.Response{StatusCode: 404, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &extensionsv1beta1.DaemonSet{})}, nil + return &http.Response{StatusCode: 404, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &appsv1.DaemonSet{})}, nil case m.isFor("GET", "/namespaces/default/jobs/job"): return &http.Response{StatusCode: 200, Header: cmdtesting.DefaultHeader(), Body: cmdtesting.ObjBody(codec, &job)}, nil case m.isFor("GET", "/namespaces/default/replicasets/rs"): @@ -1027,6 +1027,6 @@ func (m *MyReq) isFor(method string, path string) bool { return method == req.Method && (req.URL.Path == path || req.URL.Path == strings.Join([]string{"/api/v1", path}, "") || - req.URL.Path == strings.Join([]string{"/apis/extensions/v1beta1", path}, "") || + req.URL.Path == strings.Join([]string{"/apis/apps/v1", path}, "") || req.URL.Path == strings.Join([]string{"/apis/batch/v1", path}, "")) } diff --git a/pkg/kubectl/cmd/testing/fake.go b/pkg/kubectl/cmd/testing/fake.go index 30f1d7a54e..ac116373db 100644 --- a/pkg/kubectl/cmd/testing/fake.go +++ b/pkg/kubectl/cmd/testing/fake.go @@ -421,6 +421,7 @@ func (f *TestFactory) KubernetesClientSet() (*kubernetes.Clientset, error) { clientset.StorageV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.AppsV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.AppsV1beta2().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client + clientset.AppsV1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.PolicyV1beta1().RESTClient().(*restclient.RESTClient).Client = fakeClient.Client clientset.DiscoveryClient.RESTClient().(*restclient.RESTClient).Client = fakeClient.Client diff --git a/pkg/kubectl/cmd/util/openapi/validation/validation_test.go b/pkg/kubectl/cmd/util/openapi/validation/validation_test.go index ea2ddc93a4..89807c971a 100644 --- a/pkg/kubectl/cmd/util/openapi/validation/validation_test.go +++ b/pkg/kubectl/cmd/util/openapi/validation/validation_test.go @@ -24,6 +24,7 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/kube-openapi/pkg/util/proto/validation" + // This dependency is needed to register API types. "k8s.io/kube-openapi/pkg/util/proto/testing" "k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi" @@ -44,7 +45,7 @@ var _ = Describe("resource validation using OpenAPI Schema", func() { It("finds Deployment in Schema and validates it", func() { err := validator.ValidateBytes([]byte(` -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: labels: @@ -52,6 +53,9 @@ metadata: name: name spec: replicas: 1 + selector: + matchLabels: + app: redis template: metadata: labels: diff --git a/pkg/kubectl/polymorphichelpers/mapbasedselectorforobject_test.go b/pkg/kubectl/polymorphichelpers/mapbasedselectorforobject_test.go index 1ca8d1c7a9..96044d6435 100644 --- a/pkg/kubectl/polymorphichelpers/mapbasedselectorforobject_test.go +++ b/pkg/kubectl/polymorphichelpers/mapbasedselectorforobject_test.go @@ -382,6 +382,92 @@ func TestMapBasedSelectorForObject(t *testing.T) { expectErr: true, }, // Node can not be exposed -- error + { + object: &appsv1.Deployment{ + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + }, + }, + }, + expectSelector: "foo=bar", + }, + { + object: &appsv1.Deployment{ + Spec: appsv1.DeploymentSpec{ + Selector: &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + { + Key: "foo", + }, + }, + }, + }, + }, + expectErr: true, + }, + { + object: &appsv1.ReplicaSet{ + Spec: appsv1.ReplicaSetSpec{ + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "foo": "bar", + }, + }, + }, + }, + expectSelector: "foo=bar", + }, + { + object: &appsv1.ReplicaSet{ + Spec: appsv1.ReplicaSetSpec{ + Selector: &metav1.LabelSelector{ + MatchExpressions: []metav1.LabelSelectorRequirement{ + { + Key: "foo", + }, + }, + }, + }, + }, + expectErr: true, + }, + + { + object: &appsv1.Deployment{ + Spec: appsv1.DeploymentSpec{ + Selector: nil, + }, + }, + expectErr: true, + }, + { + object: &appsv1.Deployment{ + Spec: appsv1.DeploymentSpec{ + Selector: nil, + }, + }, + expectErr: true, + }, + { + object: &appsv1.ReplicaSet{ + Spec: appsv1.ReplicaSetSpec{ + Selector: nil, + }, + }, + expectErr: true, + }, + { + object: &appsv1.ReplicaSet{ + Spec: appsv1.ReplicaSetSpec{ + Selector: nil, + }, + }, + expectErr: true, + }, + { object: &corev1.Node{}, expectErr: true, diff --git a/plugin/pkg/admission/gc/gc_admission_test.go b/plugin/pkg/admission/gc/gc_admission_test.go index 034e5179e4..a7d51cd0ef 100644 --- a/plugin/pkg/admission/gc/gc_admission_test.go +++ b/plugin/pkg/admission/gc/gc_admission_test.go @@ -21,8 +21,8 @@ import ( "strings" "testing" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - extensionv1beta1 "k8s.io/api/extensions/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -112,7 +112,7 @@ func newGCPermissionsEnforcement() (*gcPermissionsEnforcement, error) { }, }, { - GroupVersion: extensionv1beta1.SchemeGroupVersion.String(), + GroupVersion: appsv1.SchemeGroupVersion.String(), APIResources: []metav1.APIResource{ {Name: "daemonsets", Namespaced: true, Kind: "DaemonSet"}, }, @@ -372,13 +372,13 @@ func TestBlockOwnerDeletionAdmission(t *testing.T) { Name: "rc2", } blockDS1 := metav1.OwnerReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "DaemonSet", Name: "ds1", BlockOwnerDeletion: getTrueVar(), } notBlockDS1 := metav1.OwnerReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "DaemonSet", Name: "ds1", BlockOwnerDeletion: getFalseVar(), diff --git a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go index 5250e33cba..d0b1bc2ac4 100644 --- a/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go +++ b/staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/group_version_test.go @@ -34,7 +34,7 @@ func TestGroupVersionUnmarshalJSON(t *testing.T) { expect GroupVersion }{ {[]byte(`{"val": "v1"}`), GroupVersion{"", "v1"}}, - {[]byte(`{"val": "extensions/v1beta1"}`), GroupVersion{"extensions", "v1beta1"}}, + {[]byte(`{"val": "apps/v1"}`), GroupVersion{"apps", "v1"}}, } for _, c := range cases { @@ -63,7 +63,7 @@ func TestGroupVersionMarshalJSON(t *testing.T) { expect []byte }{ {GroupVersion{"", "v1"}, []byte(`{"val":"v1"}`)}, - {GroupVersion{"extensions", "v1beta1"}, []byte(`{"val":"extensions/v1beta1"}`)}, + {GroupVersion{"apps", "v1"}, []byte(`{"val":"apps/v1"}`)}, } for _, c := range cases { diff --git a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go index 6ae41f7143..13bf72b25f 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go +++ b/staging/src/k8s.io/apiserver/pkg/server/resourceconfig/helpers_test.go @@ -66,7 +66,7 @@ func TestParseRuntimeConfig(t *testing.T) { { // version enabled by runtimeConfig override. runtimeConfig: map[string]string{ - "extensions/v1beta1": "", + "apps/v1": "", }, defaultResourceConfig: func() *serverstore.ResourceConfig { config := newFakeAPIResourceConfigSource() diff --git a/test/cmd/apps.sh b/test/cmd/apps.sh index 8811ef0a0d..4c50a20bc8 100755 --- a/test/cmd/apps.sh +++ b/test/cmd/apps.sh @@ -183,7 +183,7 @@ run_deployment_tests() { # Post-Condition: Deployment "nginx" is created. kube::test::get_object_assert 'deploy test-nginx-extensions' "{{$container_name_field}}" 'nginx' # and old generator was used, iow. old defaults are applied - output_message=$(kubectl get deployment.extensions/test-nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}') + output_message=$(kubectl get deployment.apps/test-nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}') kube::test::if_has_not_string "${output_message}" '2' # Ensure we can interact with deployments through extensions and apps endpoints output_message=$(kubectl get deployment.extensions -o=jsonpath='{.items[0].apiVersion}' 2>&1 "${kube_flags[@]}") @@ -275,7 +275,7 @@ run_deployment_tests() { # Clean up # Note that we should delete hpa first, otherwise it may fight with the deployment reaper. kubectl delete hpa nginx-deployment "${kube_flags[@]}" - kubectl delete deployment.extensions nginx-deployment "${kube_flags[@]}" + kubectl delete deployment.apps nginx-deployment "${kube_flags[@]}" ### Rollback a deployment # Pre-condition: no deployment exists @@ -290,10 +290,10 @@ run_deployment_tests() { kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:" # Update the deployment (revision 2) kubectl apply -f hack/testdata/deployment-revision2.yaml "${kube_flags[@]}" - kube::test::get_object_assert deployment.extensions "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:" + kube::test::get_object_assert deployment.apps "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:" # Rollback to revision 1 with dry-run - should be no-op kubectl rollout undo deployment nginx --dry-run=true "${kube_flags[@]}" | grep "test-cmd" - kube::test::get_object_assert deployment.extensions "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:" + kube::test::get_object_assert deployment.apps "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R2}:" # Rollback to revision 1 kubectl rollout undo deployment nginx --to-revision=1 "${kube_flags[@]}" sleep 1 diff --git a/test/cmd/generic-resources.sh b/test/cmd/generic-resources.sh index 66eb82f5c0..a24410d6e2 100755 --- a/test/cmd/generic-resources.sh +++ b/test/cmd/generic-resources.sh @@ -268,10 +268,10 @@ run_recursive_resources_tests() { kube::test::get_object_assert deployment "{{range.items}}{{$id_field}}:{{end}}" 'nginx:' kube::test::get_object_assert deployment "{{range.items}}{{$image_field0}}:{{end}}" "${IMAGE_DEPLOYMENT_R1}:" # Command - output_message=$(kubectl convert --local -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1beta1 -o yaml "${kube_flags[@]}") + output_message=$(kubectl convert --local -f hack/testdata/deployment-revision1.yaml --output-version=apps/v1 -o yaml "${kube_flags[@]}") # Post-condition: apiVersion is still extensions/v1beta1 in the live deployment, but command output is the new value kube::test::get_object_assert 'deployment nginx' "{{ .apiVersion }}" 'extensions/v1beta1' - kube::test::if_has_string "${output_message}" "apps/v1beta1" + kube::test::if_has_string "${output_message}" "apps/v1" # Clean up kubectl delete deployment nginx "${kube_flags[@]}" diff --git a/test/cmd/rbac.sh b/test/cmd/rbac.sh index 65136050dd..e874c7e8be 100755 --- a/test/cmd/rbac.sh +++ b/test/cmd/rbac.sh @@ -34,10 +34,10 @@ run_clusterroles_tests() { kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" '\*:' kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:' kube::test::get_object_assert clusterrole/pod-admin "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':' - kubectl create "${kube_flags[@]}" clusterrole resource-reader --verb=get,list --resource=pods,deployments.extensions + kubectl create "${kube_flags[@]}" clusterrole resource-reader --verb=get,list --resource=pods,deployments.apps kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:get:list:' kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:deployments:' - kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':extensions:' + kube::test::get_object_assert clusterrole/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':apps:' kubectl create "${kube_flags[@]}" clusterrole resourcename-reader --verb=get,list --resource=pods --resource-name=foo kube::test::get_object_assert clusterrole/resourcename-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:' kube::test::get_object_assert clusterrole/resourcename-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods:' @@ -124,10 +124,10 @@ run_role_tests() { output_message=$(! kubectl create "${kube_flags[@]}" role invalid-pod-admin --verb=* --resource=invalid-resource 2>&1) kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"invalid-resource\"" # Create Role from command (resource + group) - kubectl create "${kube_flags[@]}" role group-reader --verb=get,list --resource=deployments.extensions + kubectl create "${kube_flags[@]}" role group-reader --verb=get,list --resource=deployments.apps kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:' kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'deployments:' - kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'extensions:' + kube::test::get_object_assert role/group-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'apps:' output_message=$(! kubectl create "${kube_flags[@]}" role invalid-group --verb=get,list --resource=deployments.invalid-group 2>&1) kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"deployments\" in group \"invalid-group\"" # Create Role from command (resource / subresource) @@ -136,10 +136,10 @@ run_role_tests() { kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods/status:' kube::test::get_object_assert role/subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':' # Create Role from command (resource + group / subresource) - kubectl create "${kube_flags[@]}" role group-subresource-reader --verb=get,list --resource=replicasets.extensions/scale + kubectl create "${kube_flags[@]}" role group-subresource-reader --verb=get,list --resource=replicasets.apps/scale kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:' kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'replicasets/scale:' - kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'extensions:' + kube::test::get_object_assert role/group-subresource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" 'apps:' output_message=$(! kubectl create "${kube_flags[@]}" role invalid-group --verb=get,list --resource=rs.invalid-group/scale 2>&1) kube::test::if_has_string "${output_message}" "the server doesn't have a resource type \"rs\" in group \"invalid-group\"" # Create Role from command (resource + resourcename) @@ -149,10 +149,10 @@ run_role_tests() { kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':' kube::test::get_object_assert role/resourcename-reader "{{range.rules}}{{range.resourceNames}}{{.}}:{{end}}{{end}}" 'foo:' # Create Role from command (multi-resources) - kubectl create "${kube_flags[@]}" role resource-reader --verb=get,list --resource=pods/status,deployments.extensions + kubectl create "${kube_flags[@]}" role resource-reader --verb=get,list --resource=pods/status,deployments.apps kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.verbs}}{{.}}:{{end}}{{end}}" 'get:list:get:list:' kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.resources}}{{.}}:{{end}}{{end}}" 'pods/status:deployments:' - kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':extensions:' + kube::test::get_object_assert role/resource-reader "{{range.rules}}{{range.apiGroups}}{{.}}:{{end}}{{end}}" ':apps:' set +o nounset set +o errexit diff --git a/test/cmd/run.sh b/test/cmd/run.sh index 45e7eb5694..38d03854b6 100755 --- a/test/cmd/run.sh +++ b/test/cmd/run.sh @@ -43,7 +43,7 @@ run_kubectl_run_tests() { # Command kubectl run nginx-extensions "--image=$IMAGE_NGINX" "${kube_flags[@]}" # Post-Condition: Deployment "nginx" is created - kube::test::get_object_assert deployment.extensions "{{range.items}}{{$id_field}}:{{end}}" 'nginx-extensions:' + kube::test::get_object_assert deployment.apps "{{range.items}}{{$id_field}}:{{end}}" 'nginx-extensions:' # new generator was used output_message=$(kubectl get deployment.apps/nginx-extensions -o jsonpath='{.spec.revisionHistoryLimit}') kube::test::if_has_string "${output_message}" '10' diff --git a/test/e2e/apimachinery/garbage_collector.go b/test/e2e/apimachinery/garbage_collector.go index f313c60205..7ff0653900 100644 --- a/test/e2e/apimachinery/garbage_collector.go +++ b/test/e2e/apimachinery/garbage_collector.go @@ -185,7 +185,7 @@ func verifyRemainingObjects(f *framework.Framework, objects map[string]int) (boo By(fmt.Sprintf("expected %d pods, got %d pods", num, len(pods.Items))) } case "Deployments": - deployments, err := f.ClientSet.ExtensionsV1beta1().Deployments(f.Namespace.Name).List(metav1.ListOptions{}) + deployments, err := f.ClientSet.AppsV1().Deployments(f.Namespace.Name).List(metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list deployments: %v", err) } @@ -194,7 +194,7 @@ func verifyRemainingObjects(f *framework.Framework, objects map[string]int) (boo By(fmt.Sprintf("expected %d Deployments, got %d Deployments", num, len(deployments.Items))) } case "ReplicaSets": - rs, err := f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).List(metav1.ListOptions{}) + rs, err := f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).List(metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list rs: %v", err) } diff --git a/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go b/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go index 2f89165997..9fab9a4963 100644 --- a/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go +++ b/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go @@ -22,9 +22,9 @@ import ( "time" gcm "google.golang.org/api/monitoring/v3" + appsv1 "k8s.io/api/apps/v1" as "k8s.io/api/autoscaling/v2beta1" corev1 "k8s.io/api/core/v1" - extensions "k8s.io/api/extensions/v1beta1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -219,7 +219,7 @@ type CustomMetricTestCase struct { framework *framework.Framework hpa *as.HorizontalPodAutoscaler kubeClient clientset.Interface - deployment *extensions.Deployment + deployment *appsv1.Deployment pod *corev1.Pod initialReplicas int scaledReplicas int @@ -282,9 +282,9 @@ func (tc *CustomMetricTestCase) Run() { waitForReplicas(tc.deployment.ObjectMeta.Name, tc.framework.Namespace.ObjectMeta.Name, tc.kubeClient, 15*time.Minute, tc.scaledReplicas) } -func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, deployment *extensions.Deployment, pod *corev1.Pod) error { +func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, deployment *appsv1.Deployment, pod *corev1.Pod) error { if deployment != nil { - _, err := cs.Extensions().Deployments(f.Namespace.ObjectMeta.Name).Create(deployment) + _, err := cs.AppsV1().Deployments(f.Namespace.ObjectMeta.Name).Create(deployment) if err != nil { return err } @@ -298,9 +298,9 @@ func createDeploymentToScale(f *framework.Framework, cs clientset.Interface, dep return nil } -func cleanupDeploymentsToScale(f *framework.Framework, cs clientset.Interface, deployment *extensions.Deployment, pod *corev1.Pod) { +func cleanupDeploymentsToScale(f *framework.Framework, cs clientset.Interface, deployment *appsv1.Deployment, pod *corev1.Pod) { if deployment != nil { - _ = cs.Extensions().Deployments(f.Namespace.ObjectMeta.Name).Delete(deployment.ObjectMeta.Name, &metav1.DeleteOptions{}) + _ = cs.AppsV1().Deployments(f.Namespace.ObjectMeta.Name).Delete(deployment.ObjectMeta.Name, &metav1.DeleteOptions{}) } if pod != nil { _ = cs.CoreV1().Pods(f.Namespace.ObjectMeta.Name).Delete(pod.ObjectMeta.Name, &metav1.DeleteOptions{}) @@ -333,7 +333,7 @@ func podsHPA(namespace string, deploymentName string, metricTargets map[string]i MaxReplicas: 3, MinReplicas: &minReplicas, ScaleTargetRef: as.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: deploymentName, }, @@ -365,7 +365,7 @@ func objectHPA(namespace string, metricTarget int64) *as.HorizontalPodAutoscaler MaxReplicas: 3, MinReplicas: &minReplicas, ScaleTargetRef: as.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: dummyDeploymentName, }, @@ -424,7 +424,7 @@ func externalHPA(namespace string, metricTargets map[string]externalMetricTarget MaxReplicas: 3, MinReplicas: &minReplicas, ScaleTargetRef: as.CrossVersionObjectReference{ - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", Kind: "Deployment", Name: dummyDeploymentName, }, diff --git a/test/e2e/framework/psp_util.go b/test/e2e/framework/psp_util.go index 82363ed04f..e211d4ef66 100644 --- a/test/e2e/framework/psp_util.go +++ b/test/e2e/framework/psp_util.go @@ -78,7 +78,7 @@ func PrivilegedPSP(name string) *policy.PodSecurityPolicy { func IsPodSecurityPolicyEnabled(f *Framework) bool { isPSPEnabledOnce.Do(func() { - psps, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().List(metav1.ListOptions{}) + psps, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().List(metav1.ListOptions{}) if err != nil { Logf("Error listing PodSecurityPolicies; assuming PodSecurityPolicy is disabled: %v", err) isPSPEnabled = false @@ -103,7 +103,7 @@ func CreatePrivilegedPSPBinding(f *Framework, namespace string) { } // Create the privileged PSP & role privilegedPSPOnce.Do(func() { - _, err := f.ClientSet.ExtensionsV1beta1().PodSecurityPolicies().Get( + _, err := f.ClientSet.PolicyV1beta1().PodSecurityPolicies().Get( podSecurityPolicyPrivileged, metav1.GetOptions{}) if !apierrs.IsNotFound(err) { // Privileged PSP was already created. diff --git a/test/e2e/framework/rs_util.go b/test/e2e/framework/rs_util.go index f206dc89fc..cfdf0975ad 100644 --- a/test/e2e/framework/rs_util.go +++ b/test/e2e/framework/rs_util.go @@ -130,7 +130,7 @@ func NewReplicaSet(name, namespace string, replicas int32, podLabels map[string] return &apps.ReplicaSet{ TypeMeta: metav1.TypeMeta{ Kind: "ReplicaSet", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", }, ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index f6463dd0c0..21725ae5cc 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -3110,10 +3110,16 @@ func getSelectorFromRuntimeObject(obj runtime.Object) (labels.Selector, error) { return labels.SelectorFromSet(typed.Spec.Selector), nil case *extensions.ReplicaSet: return metav1.LabelSelectorAsSelector(typed.Spec.Selector) + case *apps.ReplicaSet: + return metav1.LabelSelectorAsSelector(typed.Spec.Selector) case *extensions.Deployment: return metav1.LabelSelectorAsSelector(typed.Spec.Selector) + case *apps.Deployment: + return metav1.LabelSelectorAsSelector(typed.Spec.Selector) case *extensions.DaemonSet: return metav1.LabelSelectorAsSelector(typed.Spec.Selector) + case *apps.DaemonSet: + return metav1.LabelSelectorAsSelector(typed.Spec.Selector) case *batch.Job: return metav1.LabelSelectorAsSelector(typed.Spec.Selector) default: @@ -3133,13 +3139,25 @@ func getReplicasFromRuntimeObject(obj runtime.Object) (int32, error) { return *typed.Spec.Replicas, nil } return 0, nil + case *apps.ReplicaSet: + if typed.Spec.Replicas != nil { + return *typed.Spec.Replicas, nil + } + return 0, nil case *extensions.Deployment: if typed.Spec.Replicas != nil { return *typed.Spec.Replicas, nil } return 0, nil + case *apps.Deployment: + if typed.Spec.Replicas != nil { + return *typed.Spec.Replicas, nil + } + return 0, nil case *extensions.DaemonSet: return 0, nil + case *apps.DaemonSet: + return 0, nil case *batch.Job: // TODO: currently we use pause pods so that's OK. When we'll want to switch to Pods // that actually finish we need a better way to do this. diff --git a/test/e2e/instrumentation/monitoring/custom_metrics_deployments.go b/test/e2e/instrumentation/monitoring/custom_metrics_deployments.go index 3c59f6e488..636b6e8651 100644 --- a/test/e2e/instrumentation/monitoring/custom_metrics_deployments.go +++ b/test/e2e/instrumentation/monitoring/custom_metrics_deployments.go @@ -20,13 +20,14 @@ import ( "fmt" "strings" + "os/exec" + gcm "google.golang.org/api/monitoring/v3" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" - extensions "k8s.io/api/extensions/v1beta1" rbac "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/test/e2e/framework" - "os/exec" ) var ( @@ -71,7 +72,7 @@ type CustomMetricContainerSpec struct { // SimpleStackdriverExporterDeployment is a Deployment of simple application that exports a metric of // fixed value to Stackdriver in a loop. -func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32, metricValue int64) *extensions.Deployment { +func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment { return StackdriverExporterDeployment(name, namespace, replicas, []CustomMetricContainerSpec{ { @@ -86,18 +87,18 @@ func SimpleStackdriverExporterDeployment(name, namespace string, replicas int32, // an arbitrary amount of metrics of fixed value to Stackdriver in a loop. Each metric // is exposed by a different container in one pod. // The metric names and values are configured via the containers parameter. -func StackdriverExporterDeployment(name, namespace string, replicas int32, containers []CustomMetricContainerSpec) *extensions.Deployment { +func StackdriverExporterDeployment(name, namespace string, replicas int32, containers []CustomMetricContainerSpec) *appsv1.Deployment { podSpec := corev1.PodSpec{Containers: []corev1.Container{}} for _, containerSpec := range containers { podSpec.Containers = append(podSpec.Containers, stackdriverExporterContainerSpec(containerSpec.Name, namespace, containerSpec.MetricName, containerSpec.MetricValue)) } - return &extensions.Deployment{ + return &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: extensions.DeploymentSpec{ + Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"name": name}, }, @@ -175,13 +176,13 @@ func stackdriverExporterContainerSpec(name string, namespace string, metricName // PrometheusExporterDeployment is a Deployment of simple application with two containers // one exposing a metric in prometheus format and second a prometheus-to-sd container // that scrapes the metric and pushes it to stackdriver. -func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *extensions.Deployment { - return &extensions.Deployment{ +func PrometheusExporterDeployment(name, namespace string, replicas int32, metricValue int64) *appsv1.Deployment { + return &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Spec: extensions.DeploymentSpec{ + Spec: appsv1.DeploymentSpec{ Selector: &metav1.LabelSelector{ MatchLabels: map[string]string{"name": name}, }, diff --git a/test/e2e/network/ingress.go b/test/e2e/network/ingress.go index 44f95086f9..96815c9dd9 100644 --- a/test/e2e/network/ingress.go +++ b/test/e2e/network/ingress.go @@ -562,11 +562,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() { It("should sync endpoints to NEG", func() { name := "hostname" scaleAndValidateNEG := func(num int) { - scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{}) + scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) if scale.Spec.Replicas != int32(num) { scale.Spec.Replicas = int32(num) - _, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale) + _, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale) Expect(err).NotTo(HaveOccurred()) } wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) { @@ -611,10 +611,10 @@ var _ = SIGDescribe("Loadbalancing: L7", func() { Expect(usingNEG).To(BeTrue()) By(fmt.Sprintf("Scale backend replicas to %d", replicas)) - scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{}) + scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) scale.Spec.Replicas = int32(replicas) - _, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale) + _, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale) Expect(err).NotTo(HaveOccurred()) wait.Poll(10*time.Second, framework.LoadBalancerPollTimeout, func() (bool, error) { res, err := jig.GetDistinctResponseFromIngress() @@ -657,11 +657,11 @@ var _ = SIGDescribe("Loadbalancing: L7", func() { expectedKeys := []int32{80, 443} scaleAndValidateExposedNEG := func(num int) { - scale, err := f.ClientSet.ExtensionsV1beta1().Deployments(ns).GetScale(name, metav1.GetOptions{}) + scale, err := f.ClientSet.AppsV1().Deployments(ns).GetScale(name, metav1.GetOptions{}) Expect(err).NotTo(HaveOccurred()) if scale.Spec.Replicas != int32(num) { scale.Spec.Replicas = int32(num) - _, err = f.ClientSet.ExtensionsV1beta1().Deployments(ns).UpdateScale(name, scale) + _, err = f.ClientSet.AppsV1().Deployments(ns).UpdateScale(name, scale) Expect(err).NotTo(HaveOccurred()) } wait.Poll(10*time.Second, ingress.NEGUpdateTimeout, func() (bool, error) { diff --git a/test/e2e/scheduling/resource_quota.go b/test/e2e/scheduling/resource_quota.go index 3c33caa390..81d42625da 100644 --- a/test/e2e/scheduling/resource_quota.go +++ b/test/e2e/scheduling/resource_quota.go @@ -20,8 +20,8 @@ import ( "fmt" "time" + appsv1 "k8s.io/api/apps/v1" "k8s.io/api/core/v1" - extensions "k8s.io/api/extensions/v1beta1" "k8s.io/api/scheduling/v1beta1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" @@ -464,27 +464,27 @@ var _ = SIGDescribe("ResourceQuota", func() { By("Ensuring resource quota status is calculated") usedResources := v1.ResourceList{} usedResources[v1.ResourceQuotas] = resource.MustParse("1") - usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("0") + usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("0") err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) Expect(err).NotTo(HaveOccurred()) By("Creating a ReplicaSet") replicaSet := newTestReplicaSetForQuota("test-rs", "nginx", 0) - replicaSet, err = f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Create(replicaSet) + replicaSet, err = f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Create(replicaSet) Expect(err).NotTo(HaveOccurred()) By("Ensuring resource quota status captures replicaset creation") usedResources = v1.ResourceList{} - usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("1") + usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("1") err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) Expect(err).NotTo(HaveOccurred()) By("Deleting a ReplicaSet") - err = f.ClientSet.ExtensionsV1beta1().ReplicaSets(f.Namespace.Name).Delete(replicaSet.Name, nil) + err = f.ClientSet.AppsV1().ReplicaSets(f.Namespace.Name).Delete(replicaSet.Name, nil) Expect(err).NotTo(HaveOccurred()) By("Ensuring resource quota status released usage") - usedResources[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("0") + usedResources[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("0") err = waitForResourceQuota(f.ClientSet, f.Namespace.Name, quotaName, usedResources) Expect(err).NotTo(HaveOccurred()) }) @@ -1351,7 +1351,7 @@ func newTestResourceQuota(name string) *v1.ResourceQuota { hard[core.V1ResourceByStorageClass(classGold, v1.ResourcePersistentVolumeClaims)] = resource.MustParse("10") hard[core.V1ResourceByStorageClass(classGold, v1.ResourceRequestsStorage)] = resource.MustParse("10Gi") // test quota on discovered resource type - hard[v1.ResourceName("count/replicasets.extensions")] = resource.MustParse("5") + hard[v1.ResourceName("count/replicasets.apps")] = resource.MustParse("5") // test quota on extended resource hard[v1.ResourceName(v1.DefaultResourceRequestsPrefix+extendedResourceName)] = resource.MustParse("3") return &v1.ResourceQuota{ @@ -1453,14 +1453,15 @@ func newTestReplicationControllerForQuota(name, image string, replicas int32) *v } // newTestReplicaSetForQuota returns a simple replica set -func newTestReplicaSetForQuota(name, image string, replicas int32) *extensions.ReplicaSet { +func newTestReplicaSetForQuota(name, image string, replicas int32) *appsv1.ReplicaSet { zero := int64(0) - return &extensions.ReplicaSet{ + return &appsv1.ReplicaSet{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Spec: extensions.ReplicaSetSpec{ + Spec: appsv1.ReplicaSetSpec{ Replicas: &replicas, + Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"name": name}}, Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"name": name}, diff --git a/test/e2e/storage/persistent_volumes-local.go b/test/e2e/storage/persistent_volumes-local.go index e64f1fcd50..fadb462c3f 100644 --- a/test/e2e/storage/persistent_volumes-local.go +++ b/test/e2e/storage/persistent_volumes-local.go @@ -1629,7 +1629,7 @@ func createProvisionerDaemonset(config *localTestConfig) { provisioner := &appsv1.DaemonSet{ TypeMeta: metav1.TypeMeta{ Kind: "DaemonSet", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", }, ObjectMeta: metav1.ObjectMeta{ Name: daemonSetName, diff --git a/test/integration/deployment/deployment_test.go b/test/integration/deployment/deployment_test.go index e927153545..86d5aeeaa6 100644 --- a/test/integration/deployment/deployment_test.go +++ b/test/integration/deployment/deployment_test.go @@ -109,7 +109,9 @@ func TestNewDeployment(t *testing.T) { } } -// Deployments should support roll out, roll back, and roll over +// Deployments should support roll out, roll back, and roll over. +// TODO: drop the rollback portions of this test when extensions/v1beta1 is no longer served +// and rollback endpoint is no longer supported. func TestDeploymentRollingUpdate(t *testing.T) { s, closeFn, rm, dc, informers, c := dcSetup(t) defer closeFn() @@ -239,6 +241,7 @@ func TestDeploymentSelectorImmutability(t *testing.T) { } // test to ensure extensions/v1beta1 selector is mutable + // TODO: drop the extensions/v1beta1 portion of this test when extensions/v1beta1 is no longer served newSelectorLabels := map[string]string{"name_extensions_v1beta1": "test_extensions_v1beta1"} deploymentExtensionsV1beta1, err := c.ExtensionsV1beta1().Deployments(ns.Name).Get(name, metav1.GetOptions{}) if err != nil { @@ -553,6 +556,7 @@ func TestDeploymentHashCollision(t *testing.T) { } // Deployment supports rollback even when there's old replica set without revision. +// TODO: drop this test when extensions/v1beta1 is no longer served func TestRollbackDeploymentRSNoRevision(t *testing.T) { s, closeFn, rm, dc, informers, c := dcSetup(t) defer closeFn() diff --git a/test/integration/deployment/util.go b/test/integration/deployment/util.go index 3dd73425ff..dc2b3a13f1 100644 --- a/test/integration/deployment/util.go +++ b/test/integration/deployment/util.go @@ -105,7 +105,7 @@ func newReplicaSet(name, ns string, replicas int32) *apps.ReplicaSet { return &apps.ReplicaSet{ TypeMeta: metav1.TypeMeta{ Kind: "ReplicaSet", - APIVersion: "extensions/v1beta1", + APIVersion: "apps/v1", }, ObjectMeta: metav1.ObjectMeta{ Namespace: ns, diff --git a/test/integration/master/synthetic_master_test.go b/test/integration/master/synthetic_master_test.go index de3f9f2933..d40b98e3ca 100644 --- a/test/integration/master/synthetic_master_test.go +++ b/test/integration/master/synthetic_master_test.go @@ -24,6 +24,7 @@ import ( "net" "net/http" "os" + "path" "strconv" "strings" "sync" @@ -47,7 +48,6 @@ import ( clientsetv1 "k8s.io/client-go/kubernetes" clienttypedv1 "k8s.io/client-go/kubernetes/typed/core/v1" restclient "k8s.io/client-go/rest" - "k8s.io/kubernetes/pkg/api/testapi" api "k8s.io/kubernetes/pkg/apis/core" clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/master" @@ -298,7 +298,7 @@ func TestObjectSizeResponses(t *testing.T) { _, s, closeFn := framework.RunAMaster(nil) defer closeFn() - client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}}) + client := clientsetv1.NewForConfigOrDie(&restclient.Config{Host: s.URL}) const DeploymentMegabyteSize = 100000 const DeploymentTwoMegabyteSize = 1000000 @@ -403,7 +403,7 @@ var deploymentExtensions string = ` var deploymentApps string = ` { - "apiVersion": "apps/v1beta1", + "apiVersion": "apps/v1", "kind": "Deployment", "metadata": { "name": "test-deployment2", @@ -411,6 +411,11 @@ var deploymentApps string = ` }, "spec": { "replicas": 1, + "selector": { + "matchLabels": { + "app": "nginx0" + } + }, "template": { "metadata": { "labels": { @@ -429,19 +434,31 @@ var deploymentApps string = ` ` func autoscalingPath(resource, namespace, name string) string { - return testapi.Autoscaling.ResourcePath(resource, namespace, name) + if namespace != "" { + namespace = path.Join("namespaces", namespace) + } + return path.Join("/apis/autoscaling/v1", namespace, resource, name) } func batchPath(resource, namespace, name string) string { - return testapi.Batch.ResourcePath(resource, namespace, name) + if namespace != "" { + namespace = path.Join("namespaces", namespace) + } + return path.Join("/apis/batch/v1", namespace, resource, name) } func extensionsPath(resource, namespace, name string) string { - return testapi.Extensions.ResourcePath(resource, namespace, name) + if namespace != "" { + namespace = path.Join("namespaces", namespace) + } + return path.Join("/apis/extensions/v1beta1", namespace, resource, name) } func appsPath(resource, namespace, name string) string { - return testapi.Apps.ResourcePath(resource, namespace, name) + if namespace != "" { + namespace = path.Join("namespaces", namespace) + } + return path.Join("/apis/apps/v1", namespace, resource, name) } func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { @@ -457,7 +474,7 @@ func TestAutoscalingGroupBackwardCompatibility(t *testing.T) { expectedVersion string }{ {"POST", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), hpaV1, integration.Code201, ""}, - {"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, testapi.Autoscaling.GroupVersion().String()}, + {"GET", autoscalingPath("horizontalpodautoscalers", metav1.NamespaceDefault, ""), "", integration.Code200, "autoscaling/v1"}, } for _, r := range requests { @@ -503,14 +520,15 @@ func TestAppsGroupBackwardCompatibility(t *testing.T) { }{ // Post to extensions endpoint and get back from both: extensions and apps {"POST", extensionsPath("deployments", metav1.NamespaceDefault, ""), deploymentExtensions, integration.Code201, ""}, - {"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()}, - {"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Apps.GroupVersion().String()}, - {"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, testapi.Extensions.GroupVersion().String()}, + {"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"}, + {"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "apps/v1"}, + {"DELETE", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment1"), "", integration.Code200, "extensions/v1beta1"}, // Post to apps endpoint and get back from both: apps and extensions {"POST", appsPath("deployments", metav1.NamespaceDefault, ""), deploymentApps, integration.Code201, ""}, - {"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()}, - {"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Extensions.GroupVersion().String()}, - {"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, testapi.Apps.GroupVersion().String()}, + {"GET", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "apps/v1"}, + {"GET", extensionsPath("deployments", metav1.NamespaceDefault, "test-deployment2"), "", integration.Code200, "extensions/v1beta1"}, + // set propagationPolicy=Orphan to force the object to be returned so we can check the apiVersion (otherwise, we just get a status object back) + {"DELETE", appsPath("deployments", metav1.NamespaceDefault, "test-deployment2") + "?propagationPolicy=Orphan", "", integration.Code200, "apps/v1"}, } for _, r := range requests { @@ -624,7 +642,7 @@ func TestMasterService(t *testing.T) { _, s, closeFn := framework.RunAMaster(framework.NewIntegrationTestMasterConfig()) defer closeFn() - client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}}) + client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL}) err := wait.Poll(time.Second, time.Minute, func() (bool, error) { svcList, err := client.Core().Services(metav1.NamespaceDefault).List(metav1.ListOptions{}) @@ -666,7 +684,7 @@ func TestServiceAlloc(t *testing.T) { _, s, closeFn := framework.RunAMaster(cfg) defer closeFn() - client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL, ContentConfig: restclient.ContentConfig{GroupVersion: testapi.Groups[api.GroupName].GroupVersion()}}) + client := clientset.NewForConfigOrDie(&restclient.Config{Host: s.URL}) svc := func(i int) *api.Service { return &api.Service{ diff --git a/test/integration/replicaset/replicaset_test.go b/test/integration/replicaset/replicaset_test.go index 595d2576a0..0a5ae21642 100644 --- a/test/integration/replicaset/replicaset_test.go +++ b/test/integration/replicaset/replicaset_test.go @@ -471,6 +471,7 @@ func TestRSSelectorImmutability(t *testing.T) { createRSsPods(t, clientSet, []*apps.ReplicaSet{rs}, []*v1.Pod{}) // test to ensure extensions/v1beta1 selector is mutable + // TODO: remove the extensions/v1beta1 portion of the test once we stop serving extensions/v1beta1 newSelectorLabels := map[string]string{"changed_name_extensions_v1beta1": "changed_test_extensions_v1beta1"} rsExt, err := clientSet.ExtensionsV1beta1().ReplicaSets(ns.Name).Get(rs.Name, metav1.GetOptions{}) if err != nil {