@@ -21,6 +21,7 @@ import (
21
21
"time"
22
22
23
23
appsv1 "k8s.io/api/apps/v1"
24
+ v1 "k8s.io/api/core/v1"
24
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
25
26
"k8s.io/apimachinery/pkg/types"
26
27
"k8s.io/kubernetes/test/e2e/framework"
@@ -56,7 +57,7 @@ func (r *ReplicaSetUpgradeTest) Setup(f *framework.Framework) {
56
57
nginxImage := imageutils .GetE2EImage (imageutils .Nginx )
57
58
58
59
ginkgo .By (fmt .Sprintf ("Creating replicaset %s in namespace %s" , rsName , ns ))
59
- replicaSet := replicaset . NewReplicaSet (rsName , ns , 1 , map [string ]string {"test" : "upgrade" }, "nginx" , nginxImage )
60
+ replicaSet := newReplicaSet (rsName , ns , 1 , map [string ]string {"test" : "upgrade" }, "nginx" , nginxImage )
60
61
rs , err := c .AppsV1 ().ReplicaSets (ns ).Create (replicaSet )
61
62
framework .ExpectNoError (err )
62
63
@@ -102,3 +103,37 @@ func (r *ReplicaSetUpgradeTest) Test(f *framework.Framework, done <-chan struct{
102
103
func (r * ReplicaSetUpgradeTest ) Teardown (f * framework.Framework ) {
103
104
// rely on the namespace deletion to clean up everything
104
105
}
106
+
107
+ // newReplicaSet returns a new ReplicaSet.
108
+ func newReplicaSet (name , namespace string , replicas int32 , podLabels map [string ]string , imageName , image string ) * appsv1.ReplicaSet {
109
+ return & appsv1.ReplicaSet {
110
+ TypeMeta : metav1.TypeMeta {
111
+ Kind : "ReplicaSet" ,
112
+ APIVersion : "apps/v1" ,
113
+ },
114
+ ObjectMeta : metav1.ObjectMeta {
115
+ Namespace : namespace ,
116
+ Name : name ,
117
+ },
118
+ Spec : appsv1.ReplicaSetSpec {
119
+ Selector : & metav1.LabelSelector {
120
+ MatchLabels : podLabels ,
121
+ },
122
+ Replicas : & replicas ,
123
+ Template : v1.PodTemplateSpec {
124
+ ObjectMeta : metav1.ObjectMeta {
125
+ Labels : podLabels ,
126
+ },
127
+ Spec : v1.PodSpec {
128
+ Containers : []v1.Container {
129
+ {
130
+ Name : imageName ,
131
+ Image : image ,
132
+ SecurityContext : & v1.SecurityContext {},
133
+ },
134
+ },
135
+ },
136
+ },
137
+ },
138
+ }
139
+ }
0 commit comments