Skip to content
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

feat: allow webhook configuration #143

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .chainsaw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha2.json
apiVersion: chainsaw.kyverno.io/v1alpha2
kind: Configuration
metadata:
name: configuration
spec:
cleanup:
delayBeforeCleanup: 3s
discovery:
fullName: true
execution:
failFast: true
forceTerminationGracePeriod: 5s
parallel: 1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ metadata:
name: {{ template "kyverno.sidecar-injector.name" . }}
labels:
{{- include "kyverno.sidecar-injector.labels" . | nindent 4 }}
{{- with .Values.sidecarInjector.webhook.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
webhooks:
- name: kyverno-envoy-sidecar.kyverno-envoy-sidecar-injector.svc
clientConfig:
Expand All @@ -33,24 +37,21 @@ webhooks:
namespace: {{ template "kyverno.namespace" . }}
path: "/mutate"
caBundle: {{ $ca.Cert | b64enc }}
failurePolicy: Fail
failurePolicy: {{ .Values.sidecarInjector.webhook.failurePolicy }}
sideEffects: None
admissionReviewVersions:
- v1
admissionReviewVersions: [ v1 ]
rules:
- apiGroups:
- ''
apiVersions:
- v1
resources:
- pods
operations:
- CREATE
scope: '*'
- apiGroups: [ '' ]
apiVersions: [ v1 ]
resources: [ pods ]
operations: [ CREATE ]
scope: '*'
{{- with .Values.sidecarInjector.webhook.objectSelector }}
objectSelector:
matchExpressions:
- key: kyverno-envoy-sidecar/injection
operator: In
values:
- enabled
{{- tpl (toYaml .) $ | nindent 6 }}
{{- end }}
{{- with .Values.sidecarInjector.webhook.namespaceSelector }}
namespaceSelector:
{{- tpl (toYaml .) $ | nindent 6 }}
{{- end }}
{{- end -}}
20 changes: 20 additions & 0 deletions charts/kyverno-envoy-plugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sidecarInjector:
create: true

serviceAccount:

# -- The ServiceAccount name
name:

Expand Down Expand Up @@ -119,6 +120,7 @@ sidecarInjector:
nodeAffinity: {}

containers:

injector:

image:
Expand Down Expand Up @@ -232,4 +234,22 @@ sidecarInjector:

webhook:

# -- Webhook annotations
annotations: {}
# example.com/annotation: value

# -- Webhook object selector
objectSelector: ~

# -- Webhook failure policy
failurePolicy: Fail

# -- Webhook namespace selector
namespaceSelector:
matchExpressions:
- key: kyverno-injection
operator: In
values:
- enabled

pdb:
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: sidecar-injector
name: injected
spec:
namespaceTemplate:
metadata:
labels:
kyverno-injection: enabled
steps:
- try:
- create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: v1
kind: Pod
metadata:
name: pod
labels:
kyverno-envoy-sidecar/injection: enabled
spec:
containers:
- name: busybox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apiVersion: v1
kind: Pod
metadata:
name: pod
labels:
kyverno-envoy-sidecar/injection: enabled
spec:
containers:
- name: busybox
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e-test/sidecar-injector/not-injected/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: not-injected
spec:
namespaceTemplate:
metadata:
labels:
kyverno-injection: disabled
steps:
- try:
- create:
file: ./pod.yaml
- assert:
file: ./pod-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
(length(containers)): 1
11 changes: 11 additions & 0 deletions tests/e2e-test/sidecar-injector/not-injected/pod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Pod
metadata:
name: pod
spec:
containers:
- name: busybox
image: busybox
args:
- sleep
- 1d
Loading