-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
362: Support policy/v1 PodDisruptionBudget r=zegl a=zegl Support and recommend policy/v1 if using Kubernetes v1.21 or later. This updates #360 ``` RELNOTE: Support policy/v1 of PodDisruptionBudget. If --kubernetes-version is set to v1.21 or later, policy/v1 will be recommended over policy/v1beta1 ``` Co-authored-by: Gustav Westling <[email protected]>
- Loading branch information
Showing
17 changed files
with
114 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,43 @@ | ||
package pod | ||
|
||
import ( | ||
policyv1 "k8s.io/api/policy/v1" | ||
policyv1beta1 "k8s.io/api/policy/v1beta1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
ks "github.com/zegl/kube-score/domain" | ||
) | ||
|
||
type PodDisruptionBudget struct { | ||
type PodDisruptionBudgetV1beta1 struct { | ||
Obj policyv1beta1.PodDisruptionBudget | ||
Location ks.FileLocation | ||
} | ||
|
||
func (p PodDisruptionBudget) PodDisruptionBudget() policyv1beta1.PodDisruptionBudget { | ||
return p.Obj | ||
func (p PodDisruptionBudgetV1beta1) PodDisruptionBudgetSelector() *metav1.LabelSelector { | ||
return p.Obj.Spec.Selector | ||
} | ||
|
||
func (p PodDisruptionBudget) FileLocation() ks.FileLocation { | ||
func (p PodDisruptionBudgetV1beta1) Namespace() string { | ||
return p.Obj.Namespace | ||
} | ||
|
||
func (p PodDisruptionBudgetV1beta1) FileLocation() ks.FileLocation { | ||
return p.Location | ||
} | ||
|
||
type PodDisruptionBudgetV1 struct { | ||
Obj policyv1.PodDisruptionBudget | ||
Location ks.FileLocation | ||
} | ||
|
||
func (p PodDisruptionBudgetV1) PodDisruptionBudgetSelector() *metav1.LabelSelector { | ||
return p.Obj.Spec.Selector | ||
} | ||
|
||
func (p PodDisruptionBudgetV1) FileLocation() ks.FileLocation { | ||
return p.Location | ||
} | ||
|
||
func (p PodDisruptionBudgetV1) Namespace() string { | ||
return p.Obj.Namespace | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
score/testdata/deployment-poddisruptionbudget-v1-matches.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: app-budget | ||
spec: | ||
minAvailable: 2 | ||
selector: | ||
matchLabels: | ||
app: foo | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: statefulset-test-1 | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: foo | ||
spec: | ||
containers: | ||
- name: foobar | ||
image: foo:bar |
23 changes: 23 additions & 0 deletions
23
score/testdata/deployment-poddisruptionbudget-v1-no-match.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: app-budget | ||
spec: | ||
minAvailable: 2 | ||
selector: | ||
matchLabels: | ||
app: not-foo | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: statefulset-test-1 | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: foo | ||
spec: | ||
containers: | ||
- name: foobar | ||
image: foo:bar |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.