-
Notifications
You must be signed in to change notification settings - Fork 338
feat: add ability to restrict required-probes constraint to containers in pods selected by a service #273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
ctrought
wants to merge
13
commits into
open-policy-agent:master
from
ctrought:required-probes-only-services
Closed
feat: add ability to restrict required-probes constraint to containers in pods selected by a service #273
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
eac06ac
feat: add ability to restrict required-probes constraint to container…
ctrought 023ba37
Apply suggestions from review for tests
ctrought 700bfdd
fix merge conflict
ctrought f7ae6f9
chore: regenerate artifacts
ctrought c7efd92
Merge branch 'master' into required-probes-only-services
apeabody de4593f
Merge branch 'master' into required-probes-only-services
apeabody 008b848
chore: update to latest sync annotation format
ctrought f52a483
Merge branch 'master' into required-probes-only-services
apeabody aad2d55
Merge branch 'master' into required-probes-only-services
apeabody 98fc9dc
Merge branch 'master' into required-probes-only-services
apeabody 002f835
Merge branch 'master' into required-probes-only-services
apeabody e53d9b2
Merge branch 'master' into required-probes-only-services
apeabody ba6f0d0
Merge branch 'master' into required-probes-only-services
apeabody File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
artifacthub/library/general/requiredprobes/1.1.0/artifacthub-pkg.yml
This file contains hidden or 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,22 @@ | ||
| version: 1.1.0 | ||
| name: k8srequiredprobes | ||
| displayName: Required Probes | ||
| createdAt: "2023-06-30T04:22:54Z" | ||
| description: Requires Pods to have readiness and/or liveness probes. | ||
| digest: 6d2764a5d1d398ab02d5aaf92a49393c10c951d55ebdf7d172a1f2941b490005 | ||
| license: Apache-2.0 | ||
| homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/requiredprobes | ||
| keywords: | ||
| - gatekeeper | ||
| - open-policy-agent | ||
| - policies | ||
| readme: |- | ||
| # Required Probes | ||
| Requires Pods to have readiness and/or liveness probes. | ||
| install: |- | ||
| ### Usage | ||
| ```shell | ||
| kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/artifacthub/library/general/requiredprobes/1.1.0/template.yaml | ||
| ``` | ||
| provider: | ||
| name: Gatekeeper Library |
2 changes: 2 additions & 0 deletions
2
artifacthub/library/general/requiredprobes/1.1.0/kustomization.yaml
This file contains hidden or 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 |
14 changes: 14 additions & 0 deletions
14
.../library/general/requiredprobes/1.1.0/samples/must-have-probes-on-service/constraint.yaml
This file contains hidden or 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: constraints.gatekeeper.sh/v1beta1 | ||
| kind: K8sRequiredProbes | ||
| metadata: | ||
| name: must-have-probes-on-service | ||
| spec: | ||
| match: | ||
| kinds: | ||
| - apiGroups: [""] | ||
| kinds: ["Pod"] | ||
| parameters: | ||
| onlyServices: true | ||
| probes: ["readinessProbe", "livenessProbe"] | ||
| probeTypes: ["tcpSocket", "httpGet", "exec"] | ||
| customViolationMessage: "See https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes for more info." |
27 changes: 27 additions & 0 deletions
27
...equiredprobes/1.1.0/samples/must-have-probes-on-service/example_allowed_with_service.yaml
This file contains hidden or 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,27 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: allowed-pod-with-service | ||
| namespace: default | ||
| labels: | ||
| app.kubernetes.io/name: tomcat | ||
| spec: | ||
| containers: | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| name: tomcat-http | ||
| livenessProbe: | ||
| tcpSocket: | ||
| port: 80 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} |
17 changes: 17 additions & 0 deletions
17
...iredprobes/1.1.0/samples/must-have-probes-on-service/example_allowed_without_service.yaml
This file contains hidden or 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,17 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: allowed-pod-without-service | ||
| namespace: default | ||
| labels: | ||
| app.kubernetes.io/name: tomcat-no-svc | ||
| second-label: "example" | ||
| spec: | ||
| containers: | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} |
35 changes: 35 additions & 0 deletions
35
...iredprobes/1.1.0/samples/must-have-probes-on-service/example_disallowed_with_service.yaml
This file contains hidden or 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,35 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: disallowed-pod-with-service | ||
| namespace: default | ||
| labels: | ||
| app.kubernetes.io/name: tomcat | ||
| second-label: "example" | ||
| spec: | ||
| containers: | ||
| - name: nginx-1 | ||
| image: nginx:1.7.9 | ||
| ports: | ||
| - containerPort: 80 | ||
| livenessProbe: | ||
| # tcpSocket: | ||
| # port: 80 | ||
| # initialDelaySeconds: 5 | ||
| # periodSeconds: 10 | ||
| volumeMounts: | ||
| - mountPath: /tmp/cache | ||
| name: cache-volume | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| name: tomcat-http | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} | ||
13 changes: 13 additions & 0 deletions
13
...y/general/requiredprobes/1.1.0/samples/must-have-probes-on-service/example_inventory.yaml
This file contains hidden or 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,13 @@ | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| name: tomcat-service | ||
| namespace: default | ||
| spec: | ||
| selector: | ||
| app.kubernetes.io/name: tomcat | ||
| ports: | ||
| - name: name-of-service-port | ||
| protocol: TCP | ||
| port: 80 | ||
| targetPort: tomcat-http |
13 changes: 13 additions & 0 deletions
13
artifacthub/library/general/requiredprobes/1.1.0/samples/must-have-probes/constraint.yaml
This file contains hidden or 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,13 @@ | ||
| apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
| kind: K8sRequiredProbes | ||
| metadata: | ||
| name: must-have-probes | ||
| spec: | ||
| match: | ||
| kinds: | ||
| - apiGroups: [""] | ||
| kinds: ["Pod"] | ||
| parameters: | ||
| onlyServices: false | ||
| probes: ["readinessProbe", "livenessProbe"] | ||
| probeTypes: ["tcpSocket", "httpGet", "exec"] |
23 changes: 23 additions & 0 deletions
23
...acthub/library/general/requiredprobes/1.1.0/samples/must-have-probes/example_allowed.yaml
This file contains hidden or 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: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: test-pod1 | ||
| spec: | ||
| containers: | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| livenessProbe: | ||
| tcpSocket: | ||
| port: 80 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} |
30 changes: 30 additions & 0 deletions
30
...hub/library/general/requiredprobes/1.1.0/samples/must-have-probes/example_disallowed.yaml
This file contains hidden or 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,30 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: test-pod1 | ||
| spec: | ||
| containers: | ||
| - name: nginx-1 | ||
| image: nginx:1.7.9 | ||
| ports: | ||
| - containerPort: 80 | ||
| livenessProbe: | ||
| # tcpSocket: | ||
| # port: 80 | ||
| # initialDelaySeconds: 5 | ||
| # periodSeconds: 10 | ||
|
ctrought marked this conversation as resolved.
|
||
| volumeMounts: | ||
| - mountPath: /tmp/cache | ||
| name: cache-volume | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} | ||
41 changes: 41 additions & 0 deletions
41
...ub/library/general/requiredprobes/1.1.0/samples/must-have-probes/example_disallowed2.yaml
This file contains hidden or 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,41 @@ | ||
| apiVersion: v1 | ||
| kind: Pod | ||
| metadata: | ||
| name: test-pod2 | ||
| spec: | ||
| containers: | ||
| - name: nginx-1 | ||
| image: nginx:1.7.9 | ||
| ports: | ||
| - containerPort: 80 | ||
| readinessProbe: | ||
| # httpGet: | ||
| # path: / | ||
| # port: 80 | ||
| # initialDelaySeconds: 5 | ||
| # periodSeconds: 10 | ||
| livenessProbe: | ||
| tcpSocket: | ||
| port: 80 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| volumeMounts: | ||
| - mountPath: /tmp/cache | ||
| name: cache-volume | ||
| - name: tomcat | ||
| image: tomcat | ||
| ports: | ||
| - containerPort: 8080 | ||
| readinessProbe: | ||
| tcpSocket: | ||
| port: 8080 | ||
| initialDelaySeconds: 5 | ||
| periodSeconds: 10 | ||
| # livenessProbe: | ||
| # tcpSocket: | ||
| # port: 8080 | ||
| # initialDelaySeconds: 5 | ||
| # periodSeconds: 10 | ||
| volumes: | ||
| - name: cache-volume | ||
| emptyDir: {} |
43 changes: 43 additions & 0 deletions
43
artifacthub/library/general/requiredprobes/1.1.0/suite.yaml
This file contains hidden or 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,43 @@ | ||
| kind: Suite | ||
| apiVersion: test.gatekeeper.sh/v1alpha1 | ||
| metadata: | ||
| name: requiredprobes | ||
| tests: | ||
| - name: required-probes | ||
| template: template.yaml | ||
| constraint: samples/must-have-probes/constraint.yaml | ||
| cases: | ||
| - name: example-allowed | ||
| object: samples/must-have-probes/example_allowed.yaml | ||
| assertions: | ||
| - violations: no | ||
| - name: example-disallowed | ||
| object: samples/must-have-probes/example_disallowed.yaml | ||
| assertions: | ||
| - violations: yes | ||
| - name: example-disallowed2 | ||
| object: samples/must-have-probes/example_disallowed2.yaml | ||
| assertions: | ||
| - violations: yes | ||
| - name: required-probes-only-services | ||
| template: template.yaml | ||
| constraint: samples/must-have-probes-on-service/constraint.yaml | ||
| cases: | ||
| - name: example-allowed-without-service | ||
| object: samples/must-have-probes-on-service/example_allowed_without_service.yaml | ||
| inventory: | ||
| - samples/must-have-probes-on-service/example_inventory.yaml | ||
| assertions: | ||
| - violations: no | ||
| - name: example-allowed-with-service | ||
| object: samples/must-have-probes-on-service/example_allowed_with_service.yaml | ||
| inventory: | ||
| - samples/must-have-probes-on-service/example_inventory.yaml | ||
| assertions: | ||
| - violations: no | ||
| - name: example-disallowed-with-service | ||
| object: samples/must-have-probes-on-service/example_disallowed_with_service.yaml | ||
| inventory: | ||
| - samples/must-have-probes-on-service/example_inventory.yaml | ||
| assertions: | ||
| - violations: yes |
11 changes: 11 additions & 0 deletions
11
artifacthub/library/general/requiredprobes/1.1.0/sync.yaml
This file contains hidden or 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,11 @@ | ||
| apiVersion: config.gatekeeper.sh/v1alpha1 | ||
| kind: Config | ||
| metadata: | ||
| name: config | ||
| namespace: "gatekeeper-system" | ||
| spec: | ||
| sync: | ||
| syncOnly: | ||
| - group: "" | ||
| version: "v1" | ||
| kind: "Service" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.