mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-06-08 16:30:57 -04:00
fix TODO one of min-available/max-available must be specified when create pdb
This commit is contained in:
parent
d0c4c5647f
commit
f56ce29a0a
1 changed files with 3 additions and 10 deletions
|
|
@ -18,7 +18,6 @@ package kubectl
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
policy "k8s.io/api/policy/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -167,15 +166,6 @@ func (s *PodDisruptionBudgetV2Generator) StructuredGenerate() (runtime.Object, e
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if len(s.MaxUnavailable) == 0 && len(s.MinAvailable) == 0 {
|
||||
s.MinAvailable = "1"
|
||||
|
||||
// This behavior is intended for backward compatibility.
|
||||
// TODO: remove in Kubernetes 1.8
|
||||
fmt.Fprintln(os.Stderr, "Deprecated behavior in kubectl create pdb: Defaulting min-available to 1. "+
|
||||
"Kubernetes 1.8 will remove this default, and one of min-available/max-available must be specified. ")
|
||||
}
|
||||
|
||||
if len(s.MaxUnavailable) > 0 {
|
||||
maxUnavailable := intstr.Parse(s.MaxUnavailable)
|
||||
return &policy.PodDisruptionBudget{
|
||||
|
|
@ -213,6 +203,9 @@ func (s *PodDisruptionBudgetV2Generator) validate() error {
|
|||
if len(s.Selector) == 0 {
|
||||
return fmt.Errorf("a selector must be specified")
|
||||
}
|
||||
if len(s.MaxUnavailable) == 0 && len(s.MinAvailable) == 0 {
|
||||
return fmt.Errorf("one of min-available/max-available must be specified")
|
||||
}
|
||||
if len(s.MaxUnavailable) > 0 && len(s.MinAvailable) > 0 {
|
||||
return fmt.Errorf("min-available and max-unavailable cannot be both specified")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue