-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clarify template behavior in description
Signed-off-by: Andrew Peabody <andrewpeabody@google.com>
- Loading branch information
Showing
22 changed files
with
456 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# StorageClass | ||
|
||
The `StorageClass` constraint blocks the creation of PVCs or StatefulSets | ||
where the specified storage class doesn't exist on the cluster, or that no | ||
storage class at all is specified. | ||
|
||
This policy helps prevent workloads from getting stuck indefinitely waiting | ||
for a storage class to provision the persistent storage that will never | ||
happen. This often causes users to get confused as to why their pods are stuck | ||
pending, and requires deleting the StatefulSet and any PVCs it has created along | ||
with redeploying the workload in order to fix. Blocking it up front makes it | ||
much easier to fix before there is a mess to clean up. | ||
|
||
Optionally accepts an `allowedStorageClasses` parameter to restrict PVCs and | ||
StatefulSets to a subset list of allowed storage classes. | ||
|
||
> Please note that this policy requires Gatekeeper v3.9.0 or later. |
22 changes: 22 additions & 0 deletions
22
artifacthub/library/general/storageclass/1.1.2/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,22 @@ | ||
version: 1.1.2 | ||
name: k8sstorageclass | ||
displayName: Storage Class | ||
createdAt: "2023-11-06T20:56:52Z" | ||
description: Requires storage classes to be specified when used. Only Gatekeeper 3.9+ is supported. | ||
digest: 549bc0b8e3aea2c4410798d4f5357a3dbd2bd4225b580104b44fd4659b840b4d | ||
license: Apache-2.0 | ||
homeURL: https://open-policy-agent.github.io/gatekeeper-library/website/storageclass | ||
keywords: | ||
- gatekeeper | ||
- open-policy-agent | ||
- policies | ||
readme: |- | ||
# Storage Class | ||
Requires storage classes to be specified when used. Only Gatekeeper 3.9+ is supported. | ||
install: |- | ||
### Usage | ||
```shell | ||
kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper-library/master/artifacthub/library/general/storageclass/1.1.2/template.yaml | ||
``` | ||
provider: | ||
name: Gatekeeper Library |
2 changes: 2 additions & 0 deletions
2
artifacthub/library/general/storageclass/1.1.2/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 |
15 changes: 15 additions & 0 deletions
15
...facthub/library/general/storageclass/1.1.2/samples/storageclass-allowlist/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,15 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sStorageClass | ||
metadata: | ||
name: allowed-storageclass | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["PersistentVolumeClaim"] | ||
- apiGroups: ["apps"] | ||
kinds: ["StatefulSet"] | ||
parameters: | ||
includeStorageClassesInMessage: true | ||
allowedStorageClasses: | ||
- allowed-storage-class |
12 changes: 12 additions & 0 deletions
12
...ub/library/general/storageclass/1.1.2/samples/storageclass-allowlist/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,12 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: allowed-storage-class-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 8Gi | ||
storageClassName: allowed-storage-class |
12 changes: 12 additions & 0 deletions
12
...library/general/storageclass/1.1.2/samples/storageclass-allowlist/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,12 @@ | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: disallowed-storage-class-pvc | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 8Gi | ||
storageClassName: disallowed-storage-class |
7 changes: 7 additions & 0 deletions
7
...ageclass/1.1.2/samples/storageclass-allowlist/example_inventory_allowed_storageclass.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,7 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: allowed-storage-class | ||
provisioner: foo | ||
parameters: | ||
allowVolumeExpansion: true |
13 changes: 13 additions & 0 deletions
13
artifacthub/library/general/storageclass/1.1.2/samples/storageclass/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,13 @@ | ||
apiVersion: constraints.gatekeeper.sh/v1beta1 | ||
kind: K8sStorageClass | ||
metadata: | ||
name: storageclass | ||
spec: | ||
match: | ||
kinds: | ||
- apiGroups: [""] | ||
kinds: ["PersistentVolumeClaim"] | ||
- apiGroups: ["apps"] | ||
kinds: ["StatefulSet"] | ||
parameters: | ||
includeStorageClassesInMessage: true |
12 changes: 12 additions & 0 deletions
12
artifacthub/library/general/storageclass/1.1.2/samples/storageclass/example_allowed_pvc.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: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: ok | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 8Gi | ||
storageClassName: somestorageclass |
30 changes: 30 additions & 0 deletions
30
artifacthub/library/general/storageclass/1.1.2/samples/storageclass/example_allowed_ss.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,30 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: volumeclaimstorageclass | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: volumeclaimstorageclass | ||
serviceName: volumeclaimstorageclass | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: volumeclaimstorageclass | ||
spec: | ||
containers: | ||
- name: main | ||
image: registry.k8s.io/nginx-slim:0.8 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /usr/share/nginx/html | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
storageClassName: "somestorageclass" | ||
resources: | ||
requests: | ||
storage: 1Gi |
12 changes: 12 additions & 0 deletions
12
...brary/general/storageclass/1.1.2/samples/storageclass/example_disallowed_pvc_badname.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: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: badstorageclass | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 8Gi | ||
storageClassName: badstorageclass |
12 changes: 12 additions & 0 deletions
12
...ry/general/storageclass/1.1.2/samples/storageclass/example_disallowed_pvc_nonamename.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: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: nostorageclass | ||
spec: | ||
accessModes: | ||
- ReadWriteOnce | ||
volumeMode: Filesystem | ||
resources: | ||
requests: | ||
storage: 8Gi |
30 changes: 30 additions & 0 deletions
30
...general/storageclass/1.1.2/samples/storageclass/example_disallowed_ssvct_badnamename.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,30 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: badvolumeclaimstorageclass | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: badvolumeclaimstorageclass | ||
serviceName: badvolumeclaimstorageclass | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: badvolumeclaimstorageclass | ||
spec: | ||
containers: | ||
- name: main | ||
image: registry.k8s.io/nginx-slim:0.8 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /usr/share/nginx/html | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
storageClassName: "badstorageclass" | ||
resources: | ||
requests: | ||
storage: 1Gi |
29 changes: 29 additions & 0 deletions
29
.../general/storageclass/1.1.2/samples/storageclass/example_disallowed_ssvct_nonamename.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 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: novolumeclaimstorageclass | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: novolumeclaimstorageclass | ||
serviceName: novolumeclaimstorageclass | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: novolumeclaimstorageclass | ||
spec: | ||
containers: | ||
- name: main | ||
image: registry.k8s.io/nginx-slim:0.8 | ||
volumeMounts: | ||
- name: data | ||
mountPath: /usr/share/nginx/html | ||
volumeClaimTemplates: | ||
- metadata: | ||
name: data | ||
spec: | ||
accessModes: ["ReadWriteOnce"] | ||
resources: | ||
requests: | ||
storage: 1Gi |
7 changes: 7 additions & 0 deletions
7
...neral/storageclass/1.1.2/samples/storageclass/example_inventory_allowed_storageclass.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,7 @@ | ||
apiVersion: storage.k8s.io/v1 | ||
kind: StorageClass | ||
metadata: | ||
name: somestorageclass | ||
provisioner: foo | ||
parameters: | ||
allowVolumeExpansion: true |
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,53 @@ | ||
kind: Suite | ||
apiVersion: test.gatekeeper.sh/v1alpha1 | ||
metadata: | ||
name: storageclass | ||
tests: | ||
- name: storageclass | ||
template: template.yaml | ||
constraint: samples/storageclass/constraint.yaml | ||
cases: | ||
- name: example-allowed-pvc | ||
object: samples/storageclass/example_allowed_pvc.yaml | ||
inventory: | ||
- samples/storageclass/example_inventory_allowed_storageclass.yaml | ||
assertions: | ||
- violations: no | ||
- name: example-allowed-ss | ||
object: samples/storageclass/example_allowed_ss.yaml | ||
inventory: | ||
- samples/storageclass/example_inventory_allowed_storageclass.yaml | ||
assertions: | ||
- violations: no | ||
- name: example-disallowed-pvc-badname | ||
object: samples/storageclass/example_disallowed_pvc_badname.yaml | ||
assertions: | ||
- violations: yes | ||
- name: example-disallowed-ssvct-badnamename | ||
object: samples/storageclass/example_disallowed_ssvct_badnamename.yaml | ||
assertions: | ||
- violations: yes | ||
- name: example-disallowed-pvc-nonamename | ||
object: samples/storageclass/example_disallowed_pvc_nonamename.yaml | ||
assertions: | ||
- violations: yes | ||
- name: example-disallowed-ssvct-nonamename | ||
object: samples/storageclass/example_disallowed_ssvct_nonamename.yaml | ||
assertions: | ||
- violations: yes | ||
- name: storageclass-allowlist | ||
template: template.yaml | ||
constraint: samples/storageclass-allowlist/constraint.yaml | ||
cases: | ||
- name: allowed-storage-class-pvc | ||
object: samples/storageclass-allowlist/example_allowed.yaml | ||
inventory: | ||
- samples/storageclass-allowlist/example_inventory_allowed_storageclass.yaml | ||
assertions: | ||
- violations: no | ||
- name: disallowed-storage-class-pvc | ||
object: samples/storageclass-allowlist/example_disallowed.yaml | ||
inventory: | ||
- samples/storageclass-allowlist/example_inventory_allowed_storageclass.yaml | ||
assertions: | ||
- violations: yes |
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,11 @@ | ||
apiVersion: config.gatekeeper.sh/v1alpha1 | ||
kind: Config | ||
metadata: | ||
name: config | ||
namespace: "gatekeeper-system" | ||
spec: | ||
sync: | ||
syncOnly: | ||
- group: "storage.k8s.io" | ||
version: "v1" | ||
kind: "StorageClass" |
Oops, something went wrong.