forked from kyverno/kyverno
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: handling unexpected global-anchor-variable for the apply command
Signed-off-by: ansalamdaniel <[email protected]>
- Loading branch information
1 parent
4d4ec16
commit b51fdac
Showing
7 changed files
with
192 additions
and
1 deletion.
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
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,28 @@ | ||
name: validate-service-loadbalancer | ||
policies: | ||
- policy.yaml | ||
resources: | ||
- resources.yaml | ||
results: | ||
- policy: add-safe-to-evict | ||
rule: annotate-empty-dir | ||
resource: pod-without-emptydir-hostpath | ||
kind: Pod | ||
result: skip | ||
- policy: add-safe-to-evict | ||
rule: annotate-empty-dir | ||
resource: pod-with-emptydir-hostpath | ||
patchedResource: patchedResource.yaml | ||
kind: Pod | ||
result: pass | ||
- policy: add-safe-to-evict | ||
rule: annotate-empty-dir | ||
resource: pod-with-emptydir-hostpath-1 | ||
patchedResource: patchedResourceWithVolume.yaml | ||
kind: Pod | ||
result: pass | ||
- policy: add-safe-to-evict | ||
rule: annotate-empty-dir | ||
resource: pod-without-emptydir-hostpath-1 | ||
kind: Pod | ||
result: skip |
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,14 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
cluster-autoscaler.kubernetes.io/safe-to-evict: "true" | ||
name: pod-with-emptydir-hostpath | ||
namespace: default | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: nginx | ||
volumes: | ||
- name: demo-volume | ||
emptyDir: {} |
18 changes: 18 additions & 0 deletions
18
test/cli/test-mutate/global-anchor/patchedResourceWithVolume.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,18 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
annotations: | ||
cluster-autoscaler.kubernetes.io/safe-to-evict: "true" | ||
name: pod-with-emptydir-hostpath-1 | ||
namespace: default | ||
spec: | ||
containers: | ||
- image: nginx | ||
name: nginx | ||
volumeMounts: | ||
- mountPath: /cache | ||
name: cache-volume | ||
volumes: | ||
- name: cache-volume | ||
emptyDir: | ||
sizeLimit: 500Mi |
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,25 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: add-safe-to-evict | ||
annotations: | ||
policies.kyverno.io/category: Workload Management | ||
policies.kyverno.io/description: The Kubernetes cluster autoscaler does not evict pods that | ||
use hostPath or emptyDir volumes. To allow eviction of these pods, the annotation | ||
cluster-autoscaler.kubernetes.io/safe-to-evict=true must be added to the pods. | ||
spec: | ||
rules: | ||
- name: annotate-empty-dir | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Pod | ||
mutate: | ||
patchStrategicMerge: | ||
metadata: | ||
annotations: | ||
+(cluster-autoscaler.kubernetes.io/safe-to-evict): "true" | ||
spec: | ||
volumes: | ||
- <(emptyDir): {} |
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,55 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-without-emptydir-hostpath | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-with-emptydir-hostpath | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
volumes: | ||
- name: demo-volume | ||
emptyDir: {} | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-with-emptydir-hostpath-1 | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
volumeMounts: | ||
- mountPath: /cache | ||
name: cache-volume | ||
volumes: | ||
- name: cache-volume | ||
emptyDir: | ||
sizeLimit: 500Mi | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-without-emptydir-hostpath-1 | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx | ||
volumeMounts: | ||
- name: config-vol | ||
mountPath: /etc/config | ||
volumes: | ||
- name: config-vol | ||
configMap: | ||
name: log-config | ||
items: | ||
- key: log_level | ||
path: log_level |