-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add default request from namespace annotation #59
Comments
@atorrescogollo I have the same use case. Have you found a way to make it work? Or maybe a different project that is able to do this? |
Hi @domruf , In think Kyverno should work for this. The approach mentioned is similar to this clusterpolicy. |
I think something like this would work: apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
name: inject-certs
annotations:
policies.kyverno.io/title: Autoinject custom CA to pods
policies.kyverno.io/category: Certificates
policies.kyverno.io/subject: Pod
policies.kyverno.io/description: >-
Automount custom CA certificates when an annotation `inject-certs=enabled` is found
spec:
background: false
rules:
- name: add-volume
match:
resources:
kinds:
- Pod
preconditions:
all:
- key: "{{request.object.metadata.annotations.\"inject-certs\"}}"
operator: Equals
value: "enabled"
- key: "{{request.operation}}"
operator: In
value:
- CREATE
- UPDATE
mutate:
foreach:
- list: "request.object.spec.containers"
patchStrategicMerge:
spec:
containers:
- name: "{{ element.name }}"
volumeMounts:
- name: "etc-ssl-certs"
mountPath: "/etc/ssl/certs"
volumes:
- name: etc-ssl-certs
configMap:
name: ca-pemstore |
@atorrescogollo thank you very much. I think this will be very helpful. |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My use case is that I want to mount /etc/ssl/certs for each pod inside a namespace in order to use a custom CA easily. It would be great to take the requested annotation from the namespace (as a default annotation). For example:
I think the affected lines would be these:
k8s-sidecar-injector/pkg/server/webhook.go
Lines 163 to 167 in 85bf83c
The text was updated successfully, but these errors were encountered: