-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
containerlimits support to skip cpu limit validation (#613)
* containerlimits support to skip cpu limit validation Signed-off-by: Xinhe Li <[email protected]> * f Signed-off-by: Xinhe Li <[email protected]> * f Signed-off-by: Xinhe Li <[email protected]> * f Signed-off-by: Xinhe Li <[email protected]> --------- Signed-off-by: Xinhe Li <[email protected]> Co-authored-by: Rita Zhang <[email protected]> Co-authored-by: Jaydip Gabani <[email protected]>
- Loading branch information
1 parent
357c95b
commit 2ac0a02
Showing
19 changed files
with
576 additions
and
6 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
artifacthub/library/general/containerlimits/1.1.0/artifacthub-pkg.yml
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 @@ | ||
version: 1.1.0 | ||
name: k8scontainerlimits | ||
displayName: Container Limits | ||
createdAt: "2024-12-05T08:42:14Z" | ||
description: |- | ||
Requires containers to have memory and CPU limits set and constrains limits to be within the specified maximum values. | ||
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | ||
digest: 80cdb57a413ec205ca940639fb78b7cb4b400fb820557654909578d0ddd0b5ef | ||
license: Apache-2.0 | ||
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/containerlimits | ||
keywords: | ||
- gatekeeper | ||
- open-policy-agent | ||
- policies | ||
readme: |- | ||
# Container Limits | ||
Requires containers to have memory and CPU limits set and constrains limits to be within the specified maximum values. | ||
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ | ||
install: |- | ||
### Usage | ||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/artifacthub/library/general/containerlimits/1.1.0/template.yaml | ||
``` | ||
provider: | ||
name: Gatekeeper Library |
2 changes: 2 additions & 0 deletions
2
artifacthub/library/general/containerlimits/1.1.0/kustomization.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,2 @@ | ||
resources: | ||
- template.yaml |
12 changes: 12 additions & 0 deletions
12
...library/general/containerlimits/1.1.0/samples/container-ignore-cpu-limits/constraint.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,12 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sContainerLimits | ||
metadata: | ||
name: container-must-have-limits | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["Pod"] | ||
parameters: | ||
cpu: "-1" | ||
memory: "1Gi" |
15 changes: 15 additions & 0 deletions
15
...ry/general/containerlimits/1.1.0/samples/container-ignore-cpu-limits/example_allowed.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,15 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: opa-allowed | ||
spec: | ||
containers: | ||
- name: opa | ||
image: openpolicyagent/opa:0.9.2 | ||
args: | ||
- "run" | ||
- "--server" | ||
- "--addr=localhost:8080" | ||
resources: | ||
limits: | ||
memory: "1Gi" |
15 changes: 15 additions & 0 deletions
15
...general/containerlimits/1.1.0/samples/container-ignore-cpu-limits/example_disallowed.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,15 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: opa-disallowed | ||
spec: | ||
containers: | ||
- name: opa | ||
image: openpolicyagent/opa:0.9.2 | ||
args: | ||
- "run" | ||
- "--server" | ||
- "--addr=localhost:8080" | ||
resources: | ||
limits: | ||
memory: "2Gi" |
12 changes: 12 additions & 0 deletions
12
.../library/general/containerlimits/1.1.0/samples/container-must-have-limits/constraint.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,12 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sContainerLimits | ||
metadata: | ||
name: container-must-have-limits | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["Pod"] | ||
parameters: | ||
cpu: "200m" | ||
memory: "1Gi" |
18 changes: 18 additions & 0 deletions
18
...ary/general/containerlimits/1.1.0/samples/container-must-have-limits/example_allowed.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: | ||
name: opa-allowed | ||
labels: | ||
owner: me.agilebank.demo | ||
spec: | ||
containers: | ||
- name: opa | ||
image: openpolicyagent/opa:0.9.2 | ||
args: | ||
- "run" | ||
- "--server" | ||
- "--addr=localhost:8080" | ||
resources: | ||
limits: | ||
cpu: "100m" | ||
memory: "1Gi" |
18 changes: 18 additions & 0 deletions
18
.../general/containerlimits/1.1.0/samples/container-must-have-limits/example_disallowed.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: | ||
name: opa-disallowed | ||
labels: | ||
owner: me.agilebank.demo | ||
spec: | ||
containers: | ||
- name: opa | ||
image: openpolicyagent/opa:0.9.2 | ||
args: | ||
- "run" | ||
- "--server" | ||
- "--addr=localhost:8080" | ||
resources: | ||
limits: | ||
cpu: "100m" | ||
memory: "2Gi" |
29 changes: 29 additions & 0 deletions
29
artifacthub/library/general/containerlimits/1.1.0/suite.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,29 @@ | ||
kind: Suite | ||
apiVersion: test.gatekeeper.sh/v1alpha1 | ||
metadata: | ||
name: containerlimits | ||
tests: | ||
- name: container-limits | ||
template: template.yaml | ||
constraint: samples/container-must-have-limits/constraint.yaml | ||
cases: | ||
- name: example-allowed | ||
object: samples/container-must-have-limits/example_allowed.yaml | ||
assertions: | ||
- violations: no | ||
- name: example-disallowed | ||
object: samples/container-must-have-limits/example_disallowed.yaml | ||
assertions: | ||
- violations: yes | ||
- name: container-limits-ignore-cpu | ||
template: template.yaml | ||
constraint: samples/container-ignore-cpu-limits/constraint.yaml | ||
cases: | ||
- name: example-allowed | ||
object: samples/container-ignore-cpu-limits/example_allowed.yaml | ||
assertions: | ||
- violations: no | ||
- name: example-disallowed | ||
object: samples/container-ignore-cpu-limits/example_disallowed.yaml | ||
assertions: | ||
- violations: yes |
Oops, something went wrong.