mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-05-28 04:35:50 -04:00
drop support for policyv1beta1.PodDisruptionBudget
Kubernetes-commit: f23f716af46c7f3bae2ac060167c20c956c25906
This commit is contained in:
parent
45c4af2dec
commit
f388d8cd50
2 changed files with 6 additions and 81 deletions
|
|
@ -51,7 +51,6 @@ import (
|
|||
networkingv1 "k8s.io/api/networking/v1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
policyv1 "k8s.io/api/policy/v1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
|
|
@ -233,7 +232,6 @@ func describerMap(clientConfig *rest.Config) (map[schema.GroupKind]ResourceDescr
|
|||
{Group: storagev1.GroupName, Kind: "StorageClass"}: &StorageClassDescriber{c},
|
||||
{Group: storagev1.GroupName, Kind: "CSINode"}: &CSINodeDescriber{c},
|
||||
{Group: storagev1.GroupName, Kind: "VolumeAttributesClass"}: &VolumeAttributesClassDescriber{c},
|
||||
{Group: policyv1beta1.GroupName, Kind: "PodDisruptionBudget"}: &PodDisruptionBudgetDescriber{c},
|
||||
{Group: policyv1.GroupName, Kind: "PodDisruptionBudget"}: &PodDisruptionBudgetDescriber{c},
|
||||
{Group: rbacv1.GroupName, Kind: "Role"}: &RoleDescriber{c},
|
||||
{Group: rbacv1.GroupName, Kind: "ClusterRole"}: &ClusterRoleDescriber{c},
|
||||
|
|
@ -406,7 +404,6 @@ func init() {
|
|||
describePersistentVolumeClaim,
|
||||
describePod,
|
||||
describePodDisruptionBudgetV1,
|
||||
describePodDisruptionBudgetV1beta1,
|
||||
describePriorityClass,
|
||||
describeQuota,
|
||||
describeReplicaSet,
|
||||
|
|
@ -4882,32 +4879,19 @@ type PodDisruptionBudgetDescriber struct {
|
|||
func (p *PodDisruptionBudgetDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (string, error) {
|
||||
var (
|
||||
pdbv1 *policyv1.PodDisruptionBudget
|
||||
pdbv1beta1 *policyv1beta1.PodDisruptionBudget
|
||||
err error
|
||||
)
|
||||
|
||||
pdbv1, err = p.PolicyV1().PodDisruptionBudgets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
var events *corev1.EventList
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = searchEvents(p.CoreV1(), pdbv1, describerSettings.ChunkSize)
|
||||
}
|
||||
return describePodDisruptionBudgetV1(pdbv1, events)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// try falling back to v1beta1 in NotFound error cases
|
||||
if apierrors.IsNotFound(err) {
|
||||
pdbv1beta1, err = p.PolicyV1beta1().PodDisruptionBudgets(namespace).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
var events *corev1.EventList
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = searchEvents(p.CoreV1(), pdbv1, describerSettings.ChunkSize)
|
||||
}
|
||||
if err == nil {
|
||||
var events *corev1.EventList
|
||||
if describerSettings.ShowEvents {
|
||||
events, _ = searchEvents(p.CoreV1(), pdbv1beta1, describerSettings.ChunkSize)
|
||||
}
|
||||
return describePodDisruptionBudgetV1beta1(pdbv1beta1, events)
|
||||
}
|
||||
|
||||
return "", err
|
||||
return describePodDisruptionBudgetV1(pdbv1, events)
|
||||
}
|
||||
|
||||
func describePodDisruptionBudgetV1(pdb *policyv1.PodDisruptionBudget, events *corev1.EventList) (string, error) {
|
||||
|
|
@ -4940,36 +4924,6 @@ func describePodDisruptionBudgetV1(pdb *policyv1.PodDisruptionBudget, events *co
|
|||
})
|
||||
}
|
||||
|
||||
func describePodDisruptionBudgetV1beta1(pdb *policyv1beta1.PodDisruptionBudget, events *corev1.EventList) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
w := NewPrefixWriter(out)
|
||||
w.Write(LEVEL_0, "Name:\t%s\n", pdb.Name)
|
||||
w.Write(LEVEL_0, "Namespace:\t%s\n", pdb.Namespace)
|
||||
|
||||
if pdb.Spec.MinAvailable != nil {
|
||||
w.Write(LEVEL_0, "Min available:\t%s\n", pdb.Spec.MinAvailable.String())
|
||||
} else if pdb.Spec.MaxUnavailable != nil {
|
||||
w.Write(LEVEL_0, "Max unavailable:\t%s\n", pdb.Spec.MaxUnavailable.String())
|
||||
}
|
||||
|
||||
if pdb.Spec.Selector != nil {
|
||||
w.Write(LEVEL_0, "Selector:\t%s\n", metav1.FormatLabelSelector(pdb.Spec.Selector))
|
||||
} else {
|
||||
w.Write(LEVEL_0, "Selector:\t<unset>\n")
|
||||
}
|
||||
w.Write(LEVEL_0, "Status:\n")
|
||||
w.Write(LEVEL_2, "Allowed disruptions:\t%d\n", pdb.Status.DisruptionsAllowed)
|
||||
w.Write(LEVEL_2, "Current:\t%d\n", pdb.Status.CurrentHealthy)
|
||||
w.Write(LEVEL_2, "Desired:\t%d\n", pdb.Status.DesiredHealthy)
|
||||
w.Write(LEVEL_2, "Total:\t%d\n", pdb.Status.ExpectedPods)
|
||||
if events != nil {
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// PriorityClassDescriber generates information about a PriorityClass.
|
||||
type PriorityClassDescriber struct {
|
||||
clientset.Interface
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ import (
|
|||
networkingv1 "k8s.io/api/networking/v1"
|
||||
networkingv1beta1 "k8s.io/api/networking/v1beta1"
|
||||
policyv1 "k8s.io/api/policy/v1"
|
||||
policyv1beta1 "k8s.io/api/policy/v1beta1"
|
||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
|
|
@ -4087,34 +4086,6 @@ func TestDescribeCSINode(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDescribePodDisruptionBudgetV1beta1(t *testing.T) {
|
||||
minAvailable := intstr.FromInt32(22)
|
||||
f := fake.NewSimpleClientset(&policyv1beta1.PodDisruptionBudget{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Namespace: "ns1",
|
||||
Name: "pdb1",
|
||||
CreationTimestamp: metav1.Time{Time: time.Now().Add(1.9e9)},
|
||||
},
|
||||
Spec: policyv1beta1.PodDisruptionBudgetSpec{
|
||||
MinAvailable: &minAvailable,
|
||||
},
|
||||
Status: policyv1beta1.PodDisruptionBudgetStatus{
|
||||
DisruptionsAllowed: 5,
|
||||
},
|
||||
})
|
||||
s := PodDisruptionBudgetDescriber{f}
|
||||
out, err := s.Describe("ns1", "pdb1", DescriberSettings{ShowEvents: true})
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "pdb1") ||
|
||||
!strings.Contains(out, "ns1") ||
|
||||
!strings.Contains(out, "22") ||
|
||||
!strings.Contains(out, "5") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescribePodDisruptionBudgetV1(t *testing.T) {
|
||||
minAvailable := intstr.FromInt32(22)
|
||||
f := fake.NewSimpleClientset(&policyv1.PodDisruptionBudget{
|
||||
|
|
|
|||
Loading…
Reference in a new issue