-
Notifications
You must be signed in to change notification settings - Fork 24
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
Showing
30 changed files
with
2,049 additions
and
119 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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: enforce-image-source | ||
namespace: development | ||
spec: | ||
validationFailureAction: Enforce | ||
rules: | ||
- name: validate-image-source | ||
match: | ||
resources: | ||
kinds: | ||
- Deployment | ||
validate: | ||
message: "Only images from the Docker Hub account vinod827/ are allowed." | ||
pattern: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- image: "vinod827/*" |
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,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: myapp | ||
name: myapp | ||
namespace: development | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
strategy: {} | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: vinod827/myapp:1.0.1 | ||
name: myapp | ||
status: {} |
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 was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
iac/demo/kyverno/3.1-kyverno-policy-generate-configmap.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,32 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: generate-postgres-configmap | ||
spec: | ||
rules: | ||
- name: generate-postgres-configmap | ||
match: | ||
resources: | ||
kinds: | ||
- Namespace | ||
preconditions: | ||
- key: "{{ request.object.metadata.labels.team }}" | ||
operator: Equals | ||
value: "infra" | ||
generate: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
name: postgres-config | ||
namespace: "{{ request.object.metadata.name }}" | ||
synchronize: true | ||
data: | ||
postgres.conf: | | ||
# Sample PostgreSQL Configuration | ||
listen_addresses = '*' | ||
port = 5432 | ||
max_connections = 100 | ||
shared_buffers = 128MB | ||
work_mem = 4MB | ||
maintenance_work_mem = 64MB | ||
timezone = 'UTC' | ||
log_statement = 'ddl' |
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,6 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: test-name-2 | ||
labels: | ||
team: infra |
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,23 @@ | ||
apiVersion: kyverno.io/v2beta1 | ||
kind: Policy | ||
metadata: | ||
name: cleanup-completed-jobs | ||
namespace: development | ||
spec: | ||
rules: | ||
- name: cleanup-jobs | ||
match: | ||
any: | ||
- resources: | ||
kinds: | ||
- Job | ||
namespaces: | ||
- development | ||
exclude: | ||
any: | ||
- resources: | ||
statuses: | ||
- "!Succeeded" | ||
- "!Failed" # Exclude active Jobs | ||
cleanup: | ||
ttl: 60s # Delete Jobs 1 minute after completion |
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: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: test-job | ||
namespace: development | ||
spec: | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
containers: | ||
- name: busybox | ||
image: busybox | ||
command: ["echo", "Hello, Welcome to the DevOps Malayalam community! Let's deep dive into Kyverno today."] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: Policy | ||
metadata: | ||
name: enforce-image-source | ||
namespace: development | ||
spec: | ||
validationFailureAction: Enforce | ||
rules: | ||
- name: validate-image-source | ||
match: | ||
resources: | ||
kinds: | ||
- Deployment | ||
validate: | ||
message: "Only images from the Docker Hub account vinod827/ are allowed." | ||
pattern: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- image: "vinod827/*" |
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
22 changes: 22 additions & 0 deletions
22
iac/demo/kyverno/demo/1.3-sample-app-valid-image-source.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 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: myapp | ||
name: myapp | ||
namespace: development | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: myapp | ||
strategy: {} | ||
template: | ||
metadata: | ||
labels: | ||
app: myapp | ||
spec: | ||
containers: | ||
- image: vinod827/myapp:1.0.1 | ||
name: myapp | ||
status: {} |
19 changes: 19 additions & 0 deletions
19
iac/demo/kyverno/demo/2.1-kyverno-clusterpolicy-mutate-label.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,19 @@ | ||
apiVersion: kyverno.io/v1 | ||
kind: ClusterPolicy | ||
metadata: | ||
name: add-app-label | ||
spec: | ||
rules: | ||
- name: add-app-label-to-pods-deployment | ||
match: | ||
resources: | ||
kinds: | ||
- Pod | ||
- Deployment | ||
mutate: | ||
patchStrategicMerge: | ||
metadata: | ||
labels: # Adds these labels if not provided | ||
company: "mycompany" | ||
app: "Observability" | ||
cost: "shared-infra" |
Oops, something went wrong.