-
Notifications
You must be signed in to change notification settings - Fork 14
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
be able to pass annotations to the generated pods #252
Comments
@davidkarlsen I've been thinking about this a little bit more and had an idea I wanted to share with you. Just passing annotations wouldn't fit all scenarios, because we cannot know for sure whether the user wants to have those annotations set on:
Besides, in the future someone may require the injection of extra environment variables ( Kubernetes used to have something called PodPresets for this kind of use case, but it was removed recently 😞. The current "recommended" way to inject extra configuration into arbitrary objects upon creation/update is to create an admission controller (https://docs.giantswarm.io/guides/creating-your-own-admission-controller/), but this is quite involved just for adding an annotation... My proposal is that we implement a configuration object that can be used to bind annotations to any Kubernetes object: Deployments, Pods, custom objects... The spec could look like this (it is very much inspired by https://github.com/mattmoor/bindings): apiVersion: settings.triggermesh.io/v1
kind: AnnotationsBinding
metadata:
name: istio-injection
spec:
# 'subject' selects what object(s) the binding applies to, either by name or label selector
subject:
apiVersion: v1
kind: Pod
selector:
matchLabels:
# applies to all AWS event sources
app.kubernetes.io/part-of: aws-event-sources
# applies to all SQS event sources
app.kubernetes.io/name: awssqssource
# applies to a specific SQS event source
app.kubernetes.io/instance: my-source
# 'values' is a map of annotations to inject into the object(s) selected by 'subject'
values:
sidecar.istio.io/inject: 'true'
other.istio.annotation: some value By keeping the labels selector broad, you could have all your Pods covered (not only TriggerMesh's) with a single binding inside the namespace. Example: if the Pod that runs the SQS source is created like this: apiVersion: v1
kind: Pod
metadata:
name: awssqssource-my-source
labels:
app.kubernetes.io/part-of: aws-event-source
app.kubernetes.io/name: awssqssource
app.kubernetes.io/instance: my-source
spec:
containers:
- names: adapter
env:
- name: ARN
value: arn:aws:sqs:us-east-2:123456789012:my-queue
- name: K_SINK
value: http://...
# ... then the binding will ensure the following annotations are always present: apiVersion: v1
kind: Pod
metadata:
name: awssqssource-my-source
labels:
app.kubernetes.io/part-of: aws-event-source
app.kubernetes.io/name: awssqssource
app.kubernetes.io/instance: my-source
# injected by the binding
annotations:
sidecar.istio.io/inject: 'true'
other.istio.annotation: some value
spec:
containers:
- names: adapter
env:
- name: ARN
value: arn:aws:sqs:us-east-2:123456789012:my-queue
- name: K_SINK
value: http://...
# ... Does that sound like something that could help with your use case, or is the overhead not worth the effort compared to deploying Pods manually? |
That design sounds good, however I have researched the istio capabilities in this space, and it appears it can't do it (yet, at least, envoyproxy/envoy#11308 was just recently merged to support it) - so for now I think I just need to go with bare pods. BTW: I found the ContainerSource api https://knative.dev/docs/eventing/samples/container-source/ - it's seems a bit more native than bare pods, do you support running like this (i.e. will the image respect the sink configuration)? Still quite new to k-native. |
We do! Just replace |
Yay - that worked! :) |
Hmm, that shouldn't be the case since the body of SQS messages are plain strings (as opposed to raw bytes). Here is what the source generates for the JSON payload
If you think that is a bug, would you mind opening a new issue with a description of what is happening, and the expected behaviour? |
Doh - I was fooled by the logging which outputs it b64 encoded when presented as a byte[]. Everything works like it should. |
Correct, Glad it works! |
See #251.
I want to be able to set annotations on the pods generated from the trigger mesh custom resources, in order to do istio side-car injection on openshift. This is only possible through annotating the pods when using openshift, not via namespace labelling.
The text was updated successfully, but these errors were encountered: