@@ -34,7 +34,6 @@ import (
34
34
appsv1 "k8s.io/api/apps/v1"
35
35
corev1 "k8s.io/api/core/v1"
36
36
policyv1 "k8s.io/api/policy/v1"
37
- "k8s.io/api/policy/v1beta1"
38
37
apierrors "k8s.io/apimachinery/pkg/api/errors"
39
38
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
40
39
"k8s.io/apimachinery/pkg/labels"
@@ -528,73 +527,35 @@ func DeployUnevictablePod(ctx context.Context, input DeployUnevictablePodInput)
528
527
Deployment : workloadDeployment ,
529
528
})
530
529
531
- // TODO(oscr): Remove when Kubernetes 1.20 support is dropped.
532
- serverVersion , err := workloadClient .ServerVersion ()
533
- Expect (err ).ToNot (HaveOccurred (), "Failed to get Kubernetes version for workload" )
534
-
535
- // If Kubernetes < 1.21.0 we need to use PDB from v1beta1
536
- if utilversion .MustParseGeneric (serverVersion .String ()).LessThan (utilversion .MustParseGeneric ("v1.21.0" )) {
537
- budgetV1Beta1 := & v1beta1.PodDisruptionBudget {
538
- TypeMeta : metav1.TypeMeta {
539
- Kind : "PodDisruptionBudget" ,
540
- APIVersion : "policy/v1beta1" ,
541
- },
542
- ObjectMeta : metav1.ObjectMeta {
543
- Name : input .DeploymentName ,
544
- Namespace : input .Namespace ,
545
- },
546
- Spec : v1beta1.PodDisruptionBudgetSpec {
547
- Selector : & metav1.LabelSelector {
548
- MatchLabels : map [string ]string {
549
- "app" : "nonstop" ,
550
- },
551
- },
552
- MaxUnavailable : & intstr.IntOrString {
553
- Type : intstr .Int ,
554
- IntVal : 1 ,
555
- StrVal : "1" ,
556
- },
557
- },
558
- }
559
-
560
- AddPodDisruptionBudgetV1Beta1 (ctx , AddPodDisruptionBudgetInputV1Beta1 {
530
+ budget := & policyv1.PodDisruptionBudget {
531
+ TypeMeta : metav1.TypeMeta {
532
+ Kind : "PodDisruptionBudget" ,
533
+ APIVersion : "policy/v1" ,
534
+ },
535
+ ObjectMeta : metav1.ObjectMeta {
536
+ Name : input .DeploymentName ,
561
537
Namespace : input .Namespace ,
562
- ClientSet : workloadClient ,
563
- Budget : budgetV1Beta1 ,
564
- })
565
-
566
- // If Kubernetes >= 1.21.0 then we need to use PDB from v1
567
- } else {
568
- budget := & policyv1.PodDisruptionBudget {
569
- TypeMeta : metav1.TypeMeta {
570
- Kind : "PodDisruptionBudget" ,
571
- APIVersion : "policy/v1" ,
572
- },
573
- ObjectMeta : metav1.ObjectMeta {
574
- Name : input .DeploymentName ,
575
- Namespace : input .Namespace ,
576
- },
577
- Spec : policyv1.PodDisruptionBudgetSpec {
578
- Selector : & metav1.LabelSelector {
579
- MatchLabels : map [string ]string {
580
- "app" : "nonstop" ,
581
- },
582
- },
583
- MaxUnavailable : & intstr.IntOrString {
584
- Type : intstr .Int ,
585
- IntVal : 1 ,
586
- StrVal : "1" ,
538
+ },
539
+ Spec : policyv1.PodDisruptionBudgetSpec {
540
+ Selector : & metav1.LabelSelector {
541
+ MatchLabels : map [string ]string {
542
+ "app" : "nonstop" ,
587
543
},
588
544
},
589
- }
590
-
591
- AddPodDisruptionBudget (ctx , AddPodDisruptionBudgetInput {
592
- Namespace : input .Namespace ,
593
- ClientSet : workloadClient ,
594
- Budget : budget ,
595
- })
545
+ MaxUnavailable : & intstr.IntOrString {
546
+ Type : intstr .Int ,
547
+ IntVal : 1 ,
548
+ StrVal : "1" ,
549
+ },
550
+ },
596
551
}
597
552
553
+ AddPodDisruptionBudget (ctx , AddPodDisruptionBudgetInput {
554
+ Namespace : input .Namespace ,
555
+ ClientSet : workloadClient ,
556
+ Budget : budget ,
557
+ })
558
+
598
559
WaitForDeploymentsAvailable (ctx , WaitForDeploymentsAvailableInput {
599
560
Getter : input .WorkloadClusterProxy .GetClient (),
600
561
Deployment : workloadDeployment ,
@@ -632,21 +593,3 @@ func AddPodDisruptionBudget(ctx context.Context, input AddPodDisruptionBudgetInp
632
593
return fmt .Errorf ("podDisruptionBudget needs to be successfully deployed: %v" , err )
633
594
}, retryableOperationTimeout , retryableOperationInterval ).Should (Succeed (), "podDisruptionBudget needs to be successfully deployed" )
634
595
}
635
-
636
- // TODO(oscr): Delete below when Kubernetes 1.20 support is dropped.
637
-
638
- type AddPodDisruptionBudgetInputV1Beta1 struct {
639
- ClientSet * kubernetes.Clientset
640
- Budget * v1beta1.PodDisruptionBudget
641
- Namespace string
642
- }
643
-
644
- func AddPodDisruptionBudgetV1Beta1 (ctx context.Context , input AddPodDisruptionBudgetInputV1Beta1 ) {
645
- Eventually (func () error {
646
- budget , err := input .ClientSet .PolicyV1beta1 ().PodDisruptionBudgets (input .Namespace ).Create (ctx , input .Budget , metav1.CreateOptions {})
647
- if budget != nil && err == nil {
648
- return nil
649
- }
650
- return fmt .Errorf ("podDisruptionBudget needs to be successfully deployed: %v" , err )
651
- }, retryableOperationTimeout , retryableOperationInterval ).Should (Succeed (), "podDisruptionBudget needs to be successfully deployed" )
652
- }
0 commit comments