@@ -39,7 +39,7 @@ import (
39
39
40
40
apps "k8s.io/api/apps/v1"
41
41
v1 "k8s.io/api/core/v1"
42
- extensions "k8s.io/api/extensions /v1beta1"
42
+ networkingv1beta1 "k8s.io/api/networking /v1beta1"
43
43
apierrs "k8s.io/apimachinery/pkg/api/errors"
44
44
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
45
45
"k8s.io/apimachinery/pkg/labels"
@@ -186,20 +186,20 @@ func CreateIngressComformanceTests(jig *TestJig, ns string, annotations map[stri
186
186
fmt .Sprintf ("should update url map for host %v to expose a single url: %v" , updateURLMapHost , updateURLMapPath ),
187
187
func () {
188
188
var pathToFail string
189
- jig .Update (func (ing * extensions .Ingress ) {
190
- newRules := []extensions .IngressRule {}
189
+ jig .Update (func (ing * networkingv1beta1 .Ingress ) {
190
+ newRules := []networkingv1beta1 .IngressRule {}
191
191
for _ , rule := range ing .Spec .Rules {
192
192
if rule .Host != updateURLMapHost {
193
193
newRules = append (newRules , rule )
194
194
continue
195
195
}
196
196
existingPath := rule .IngressRuleValue .HTTP .Paths [0 ]
197
197
pathToFail = existingPath .Path
198
- newRules = append (newRules , extensions .IngressRule {
198
+ newRules = append (newRules , networkingv1beta1 .IngressRule {
199
199
Host : updateURLMapHost ,
200
- IngressRuleValue : extensions .IngressRuleValue {
201
- HTTP : & extensions .HTTPIngressRuleValue {
202
- Paths : []extensions .HTTPIngressPath {
200
+ IngressRuleValue : networkingv1beta1 .IngressRuleValue {
201
+ HTTP : & networkingv1beta1 .HTTPIngressRuleValue {
202
+ Paths : []networkingv1beta1 .HTTPIngressPath {
203
203
{
204
204
Path : updateURLMapPath ,
205
205
Backend : existingPath .Backend ,
@@ -223,14 +223,14 @@ func CreateIngressComformanceTests(jig *TestJig, ns string, annotations map[stri
223
223
tests = append (tests , ConformanceTests {
224
224
fmt .Sprintf ("should update SSL certificate with modified hostname %v" , updatedTLSHost ),
225
225
func () {
226
- jig .Update (func (ing * extensions .Ingress ) {
227
- newRules := []extensions .IngressRule {}
226
+ jig .Update (func (ing * networkingv1beta1 .Ingress ) {
227
+ newRules := []networkingv1beta1 .IngressRule {}
228
228
for _ , rule := range ing .Spec .Rules {
229
229
if rule .Host != tlsHost {
230
230
newRules = append (newRules , rule )
231
231
continue
232
232
}
233
- newRules = append (newRules , extensions .IngressRule {
233
+ newRules = append (newRules , networkingv1beta1 .IngressRule {
234
234
Host : updatedTLSHost ,
235
235
IngressRuleValue : rule .IngressRuleValue ,
236
236
})
@@ -368,7 +368,7 @@ type TestJig struct {
368
368
369
369
RootCAs map [string ][]byte
370
370
Address string
371
- Ingress * extensions .Ingress
371
+ Ingress * networkingv1beta1 .Ingress
372
372
// class is the value of the annotation keyed under
373
373
// `kubernetes.io/ingress.class`. It's added to all ingresses created by
374
374
// this jig.
@@ -436,9 +436,9 @@ func (j *TestJig) CreateIngress(manifestPath, ns string, ingAnnotations map[stri
436
436
}
437
437
438
438
// runCreate runs the required command to create the given ingress.
439
- func (j * TestJig ) runCreate (ing * extensions .Ingress ) (* extensions .Ingress , error ) {
439
+ func (j * TestJig ) runCreate (ing * networkingv1beta1 .Ingress ) (* networkingv1beta1 .Ingress , error ) {
440
440
if j .Class != MulticlusterIngressClassValue {
441
- return j .Client .ExtensionsV1beta1 ().Ingresses (ing .Namespace ).Create (ing )
441
+ return j .Client .NetworkingV1beta1 ().Ingresses (ing .Namespace ).Create (ing )
442
442
}
443
443
// Use kubemci to create a multicluster ingress.
444
444
filePath := framework .TestContext .OutputDir + "/mci.yaml"
@@ -450,9 +450,9 @@ func (j *TestJig) runCreate(ing *extensions.Ingress) (*extensions.Ingress, error
450
450
}
451
451
452
452
// runUpdate runs the required command to update the given ingress.
453
- func (j * TestJig ) runUpdate (ing * extensions .Ingress ) (* extensions .Ingress , error ) {
453
+ func (j * TestJig ) runUpdate (ing * networkingv1beta1 .Ingress ) (* networkingv1beta1 .Ingress , error ) {
454
454
if j .Class != MulticlusterIngressClassValue {
455
- return j .Client .ExtensionsV1beta1 ().Ingresses (ing .Namespace ).Update (ing )
455
+ return j .Client .NetworkingV1beta1 ().Ingresses (ing .Namespace ).Update (ing )
456
456
}
457
457
// Use kubemci to update a multicluster ingress.
458
458
// kubemci does not have an update command. We use "create --force" to update an existing ingress.
@@ -465,11 +465,11 @@ func (j *TestJig) runUpdate(ing *extensions.Ingress) (*extensions.Ingress, error
465
465
}
466
466
467
467
// Update retrieves the ingress, performs the passed function, and then updates it.
468
- func (j * TestJig ) Update (update func (ing * extensions .Ingress )) {
468
+ func (j * TestJig ) Update (update func (ing * networkingv1beta1 .Ingress )) {
469
469
var err error
470
470
ns , name := j .Ingress .Namespace , j .Ingress .Name
471
471
for i := 0 ; i < 3 ; i ++ {
472
- j .Ingress , err = j .Client .ExtensionsV1beta1 ().Ingresses (ns ).Get (name , metav1.GetOptions {})
472
+ j .Ingress , err = j .Client .NetworkingV1beta1 ().Ingresses (ns ).Get (name , metav1.GetOptions {})
473
473
if err != nil {
474
474
framework .Failf ("failed to get ingress %s/%s: %v" , ns , name , err )
475
475
}
@@ -493,8 +493,8 @@ func (j *TestJig) AddHTTPS(secretName string, hosts ...string) {
493
493
_ , cert , _ , err := createTLSSecret (j .Client , j .Ingress .Namespace , secretName , hosts ... )
494
494
framework .ExpectNoError (err )
495
495
j .Logger .Infof ("Updating ingress %v to also use secret %v for TLS termination" , j .Ingress .Name , secretName )
496
- j .Update (func (ing * extensions .Ingress ) {
497
- ing .Spec .TLS = append (ing .Spec .TLS , extensions .IngressTLS {Hosts : hosts , SecretName : secretName })
496
+ j .Update (func (ing * networkingv1beta1 .Ingress ) {
497
+ ing .Spec .TLS = append (ing .Spec .TLS , networkingv1beta1 .IngressTLS {Hosts : hosts , SecretName : secretName })
498
498
})
499
499
j .RootCAs [secretName ] = cert
500
500
}
@@ -504,23 +504,23 @@ func (j *TestJig) SetHTTPS(secretName string, hosts ...string) {
504
504
_ , cert , _ , err := createTLSSecret (j .Client , j .Ingress .Namespace , secretName , hosts ... )
505
505
framework .ExpectNoError (err )
506
506
j .Logger .Infof ("Updating ingress %v to only use secret %v for TLS termination" , j .Ingress .Name , secretName )
507
- j .Update (func (ing * extensions .Ingress ) {
508
- ing .Spec .TLS = []extensions .IngressTLS {{Hosts : hosts , SecretName : secretName }}
507
+ j .Update (func (ing * networkingv1beta1 .Ingress ) {
508
+ ing .Spec .TLS = []networkingv1beta1 .IngressTLS {{Hosts : hosts , SecretName : secretName }}
509
509
})
510
510
j .RootCAs = map [string ][]byte {secretName : cert }
511
511
}
512
512
513
513
// RemoveHTTPS updates the ingress to not use this secret for TLS.
514
514
// Note: Does not delete the secret.
515
515
func (j * TestJig ) RemoveHTTPS (secretName string ) {
516
- newTLS := []extensions .IngressTLS {}
516
+ newTLS := []networkingv1beta1 .IngressTLS {}
517
517
for _ , ingressTLS := range j .Ingress .Spec .TLS {
518
518
if secretName != ingressTLS .SecretName {
519
519
newTLS = append (newTLS , ingressTLS )
520
520
}
521
521
}
522
522
j .Logger .Infof ("Updating ingress %v to not use secret %v for TLS termination" , j .Ingress .Name , secretName )
523
- j .Update (func (ing * extensions .Ingress ) {
523
+ j .Update (func (ing * networkingv1beta1 .Ingress ) {
524
524
ing .Spec .TLS = newTLS
525
525
})
526
526
delete (j .RootCAs , secretName )
@@ -551,16 +551,16 @@ func (j *TestJig) TryDeleteIngress() {
551
551
j .tryDeleteGivenIngress (j .Ingress )
552
552
}
553
553
554
- func (j * TestJig ) tryDeleteGivenIngress (ing * extensions .Ingress ) {
554
+ func (j * TestJig ) tryDeleteGivenIngress (ing * networkingv1beta1 .Ingress ) {
555
555
if err := j .runDelete (ing ); err != nil {
556
556
j .Logger .Infof ("Error while deleting the ingress %v/%v with class %s: %v" , ing .Namespace , ing .Name , j .Class , err )
557
557
}
558
558
}
559
559
560
560
// runDelete runs the required command to delete the given ingress.
561
- func (j * TestJig ) runDelete (ing * extensions .Ingress ) error {
561
+ func (j * TestJig ) runDelete (ing * networkingv1beta1 .Ingress ) error {
562
562
if j .Class != MulticlusterIngressClassValue {
563
- return j .Client .ExtensionsV1beta1 ().Ingresses (ing .Namespace ).Delete (ing .Name , nil )
563
+ return j .Client .NetworkingV1beta1 ().Ingresses (ing .Namespace ).Delete (ing .Name , nil )
564
564
}
565
565
// Use kubemci to delete a multicluster ingress.
566
566
filePath := framework .TestContext .OutputDir + "/mci.yaml"
@@ -600,7 +600,7 @@ func getIngressAddress(client clientset.Interface, ns, name, class string) ([]st
600
600
if class == MulticlusterIngressClassValue {
601
601
return getIngressAddressFromKubemci (name )
602
602
}
603
- ing , err := client .ExtensionsV1beta1 ().Ingresses (ns ).Get (name , metav1.GetOptions {})
603
+ ing , err := client .NetworkingV1beta1 ().Ingresses (ns ).Get (name , metav1.GetOptions {})
604
604
if err != nil {
605
605
return nil , err
606
606
}
@@ -635,7 +635,7 @@ func (j *TestJig) WaitForIngressAddress(c clientset.Interface, ns, ingName strin
635
635
return address , err
636
636
}
637
637
638
- func (j * TestJig ) pollIngressWithCert (ing * extensions .Ingress , address string , knownHosts []string , cert []byte , waitForNodePort bool , timeout time.Duration ) error {
638
+ func (j * TestJig ) pollIngressWithCert (ing * networkingv1beta1 .Ingress , address string , knownHosts []string , cert []byte , waitForNodePort bool , timeout time.Duration ) error {
639
639
// Check that all rules respond to a simple GET.
640
640
knownHostsSet := sets .NewString (knownHosts ... )
641
641
for _ , rules := range ing .Spec .Rules {
@@ -695,7 +695,7 @@ func (j *TestJig) WaitForIngressToStable() {
695
695
// http or https). If waitForNodePort is true, the NodePort of the Service
696
696
// is verified before verifying the Ingress. NodePort is currently a
697
697
// requirement for cloudprovider Ingress.
698
- func (j * TestJig ) WaitForGivenIngressWithTimeout (ing * extensions .Ingress , waitForNodePort bool , timeout time.Duration ) error {
698
+ func (j * TestJig ) WaitForGivenIngressWithTimeout (ing * networkingv1beta1 .Ingress , waitForNodePort bool , timeout time.Duration ) error {
699
699
// Wait for the loadbalancer IP.
700
700
address , err := j .WaitForIngressAddress (j .Client , ing .Namespace , ing .Name , timeout )
701
701
if err != nil {
@@ -864,15 +864,15 @@ func (cont *NginxIngressController) Init() {
864
864
framework .Logf ("ingress controller running in pod %v on ip %v" , cont .pod .Name , cont .externalIP )
865
865
}
866
866
867
- func generateBacksideHTTPSIngressSpec (ns string ) * extensions .Ingress {
868
- return & extensions .Ingress {
867
+ func generateBacksideHTTPSIngressSpec (ns string ) * networkingv1beta1 .Ingress {
868
+ return & networkingv1beta1 .Ingress {
869
869
ObjectMeta : metav1.ObjectMeta {
870
870
Name : "echoheaders-https" ,
871
871
Namespace : ns ,
872
872
},
873
- Spec : extensions .IngressSpec {
873
+ Spec : networkingv1beta1 .IngressSpec {
874
874
// Note kubemci requires a default backend.
875
- Backend : & extensions .IngressBackend {
875
+ Backend : & networkingv1beta1 .IngressBackend {
876
876
ServiceName : "echoheaders-https" ,
877
877
ServicePort : intstr.IntOrString {
878
878
Type : intstr .Int ,
@@ -939,7 +939,7 @@ func generateBacksideHTTPSDeploymentSpec() *apps.Deployment {
939
939
}
940
940
941
941
// SetUpBacksideHTTPSIngress sets up deployment, service and ingress with backside HTTPS configured.
942
- func (j * TestJig ) SetUpBacksideHTTPSIngress (cs clientset.Interface , namespace string , staticIPName string ) (* apps.Deployment , * v1.Service , * extensions .Ingress , error ) {
942
+ func (j * TestJig ) SetUpBacksideHTTPSIngress (cs clientset.Interface , namespace string , staticIPName string ) (* apps.Deployment , * v1.Service , * networkingv1beta1 .Ingress , error ) {
943
943
deployCreated , err := cs .AppsV1 ().Deployments (namespace ).Create (generateBacksideHTTPSDeploymentSpec ())
944
944
if err != nil {
945
945
return nil , nil , nil , err
@@ -963,7 +963,7 @@ func (j *TestJig) SetUpBacksideHTTPSIngress(cs clientset.Interface, namespace st
963
963
}
964
964
965
965
// DeleteTestResource deletes given deployment, service and ingress.
966
- func (j * TestJig ) DeleteTestResource (cs clientset.Interface , deploy * apps.Deployment , svc * v1.Service , ing * extensions .Ingress ) []error {
966
+ func (j * TestJig ) DeleteTestResource (cs clientset.Interface , deploy * apps.Deployment , svc * v1.Service , ing * networkingv1beta1 .Ingress ) []error {
967
967
var errs []error
968
968
if ing != nil {
969
969
if err := j .runDelete (ing ); err != nil {
0 commit comments