-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Darkhood148 <[email protected]>
- Loading branch information
1 parent
15ef878
commit d37184c
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
other/block-kubectl-cp-by-pod-label/.chainsaw-test/chainsaw-test.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,45 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
creationTimestamp: null | ||
name: block-kubectl-cp-by-pod-label | ||
spec: | ||
steps: | ||
- name: step-01 | ||
try: | ||
- apply: | ||
file: ../block-kubectl-cp-by-pod-label.yaml | ||
- assert: | ||
file: policy-ready.yaml | ||
- name: step-02 | ||
try: | ||
- apply: | ||
file: ns.yaml | ||
- apply: | ||
file: pods.yaml | ||
- name: step-03 | ||
try: | ||
- sleep: | ||
duration: 5s | ||
- name: step-04 | ||
try: | ||
- script: | ||
content: if kubectl cp -n bkc-podlabel-ns pod03:/test3.txt ./test3.txt; then exit 1;else | ||
exit 0; fi | ||
- script: | ||
content: kubectl cp -n bkc-podlabel-ns pod01:/test1.txt ./test1.txt; exit 0; | ||
- script: | ||
content: kubectl cp -n bkc-podlabel-ns pod02:/test2.txt ./test2.txt; exit 0; | ||
- script: | ||
content: kubectl cp -n bkc-podlabel-ns pod04:/test4.txt ./test4.txt; exit 0; | ||
- name: step-05 | ||
try: | ||
- script: | ||
content: rm -rf ./test1.txt | ||
- script: | ||
content: rm -rf ./test2.txt | ||
- script: | ||
content: rm -rf ./test3.txt | ||
- script: | ||
content: rm -rf ./test4.txt |
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,4 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: bkc-podlabel-ns |
63 changes: 63 additions & 0 deletions
63
other/block-kubectl-cp-by-pod-label/.chainsaw-test/pods.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,63 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: pod01 | ||
namespace: bkc-podlabel-ns | ||
spec: | ||
containers: | ||
- name: busybox | ||
image: busybox:1.35 | ||
command: ["/bin/sh", "-c"] | ||
args: | ||
- touch /test1.txt | ||
- sleep 300 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
foo: bar | ||
name: pod02 | ||
namespace: bkc-podlabel-ns | ||
spec: | ||
containers: | ||
- name: busybox | ||
image: busybox:1.35 | ||
command: [ "/bin/sh", "-c" ] | ||
args: | ||
- touch /test2.txt | ||
- sleep 300 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
foo: bar | ||
cp: "false" | ||
name: pod03 | ||
namespace: bkc-podlabel-ns | ||
spec: | ||
containers: | ||
- name: busybox | ||
image: busybox:1.35 | ||
command: [ "/bin/sh", "-c" ] | ||
args: | ||
- touch /test3.txt | ||
- sleep 300 | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
labels: | ||
cp: "true" | ||
foo: bar | ||
name: pod04 | ||
namespace: bkc-podlabel-ns | ||
spec: | ||
containers: | ||
- name: busybox | ||
image: busybox:1.35 | ||
command: [ "/bin/sh", "-c" ] | ||
args: | ||
- touch /test4.txt | ||
- sleep 300 |
9 changes: 9 additions & 0 deletions
9
other/block-kubectl-cp-by-pod-label/.chainsaw-test/policy-ready.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,9 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: block-kubectl-cp-by-pod-label | ||
status: | ||
conditions: | ||
- reason: Succeeded | ||
status: "True" | ||
type: Ready |