-
Notifications
You must be signed in to change notification settings - Fork 784
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e5c26e
commit e76ce41
Showing
3 changed files
with
65 additions
and
0 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
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,40 @@ | ||
# Require deployments have multiple replicas | ||
|
||
Deployments with only a single replica produce availability concerns should that single replica fail. In most cases, you would want Deployment objects to have more than one replica to ensure continued availability if not scale. | ||
|
||
This sample policy requires that Deployments have more than one replica excluding a list of system namespaces. | ||
|
||
## More Information | ||
|
||
* [Kubernetes Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/) | ||
|
||
## Policy YAML | ||
|
||
[require_deployments_have_multiple_replicas.yaml](more/require_deployments_have_multiple_replicas.yaml) | ||
|
||
```yaml | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: deployment-has-multiple-replicas | ||
spec: | ||
validationFailureAction: audit | ||
rules: | ||
- name: deployment-has-multiple-replicas | ||
match: | ||
resources: | ||
kinds: | ||
- Deployment | ||
exclude: | ||
resources: | ||
namespaces: | ||
- kyverno | ||
- kube-system | ||
- kube-node-lease | ||
- kube-public | ||
validate: | ||
message: "Deployments must have more than one replica to ensure availability." | ||
pattern: | ||
spec: | ||
replicas: ">1" | ||
``` |
24 changes: 24 additions & 0 deletions
24
samples/more/require_deployments_have_multiple_replicas.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,24 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: deployment-has-multiple-replicas | ||
spec: | ||
validationFailureAction: audit | ||
rules: | ||
- name: deployment-has-multiple-replicas | ||
match: | ||
resources: | ||
kinds: | ||
- Deployment | ||
exclude: | ||
resources: | ||
namespaces: | ||
- kyverno | ||
- kube-system | ||
- kube-node-lease | ||
- kube-public | ||
validate: | ||
message: "Deployments must have more than one replica to ensure availability." | ||
pattern: | ||
spec: | ||
replicas: ">1" |