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

Per namespace agent injection #897

Merged
merged 14 commits into from
Feb 11, 2020

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Feb 7, 2020

Resolves #373

This adds a capability to auto inject Jaeger agent to namespaces annotated with sidecar.jaegertracing.io/inject - the same annotation which is used for deployments.

It brings a complication when the annotation is present on both namespace and deployment. Then the deployment has higher precedence, however if the specified instance on deployment is not found it does not fallback to the instance specified on the namespace.

Other notable changes

  • added namespaces to cluster role binding
  • tests now use cluster role binding from deploy/ directory

There was a discussion that Jaeger should not require access to the cluster resources and this PR adds the requirement on accessing Namespaces. At the moment the operator requires access to ClusterRoleBinding. To make the operator work without cluster-wide RBAC it will need more refactoring in a separate PR - related to #791.

Once merged

  • Documentation

My test notes:

oc new-project project33
oc create deployment vertx --image=jaegertracing/vertx-create-span:operator-e2e-tests

oc annotate namespace project33 sidecar.jaegertracing.io/inject=true
oc annotate namespace default sidecar.jaegertracing.io/inject-
oc annotate deployment vertx sidecar.jaegertracing.io/inject=true 

kubectl create namespace project33
kubectl config set-context minikube --namespace=project33  

Signed-off-by: Pavol Loffay [email protected]

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a couple of things that can be improved, but looks very good overall!

Makefile Outdated Show resolved Hide resolved
deploy/role.yaml Outdated Show resolved Hide resolved
deploy/role_binding.yaml Show resolved Hide resolved
pkg/inject/sidecar_test.go Show resolved Hide resolved
pkg/inject/sidecar_test.go Outdated Show resolved Hide resolved
test/e2e/sidecar_namespace_test.go Show resolved Hide resolved
JaegerCommonSpec: v1.JaegerCommonSpec{
// add inject annotation to jaeger deployment to non existing Jaeger instance
// we don't want to inject agent to jaeger deployment because the port collisions
Annotations: map[string]string{inject.Annotation: "doesNotExists"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I get it. Are you saying that if a Jaeger CR for all-in-one is created, it will get a sidecar injected if the namespace is annotated, unless the deployment is annotated with a non-existing Jaeger instance?

I think the operator should handle this special case: we can detect that the deployment is a Jaeger deployment, skip the deployment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I get it. Are you saying that if a Jaeger CR for all-in-one is created, it will get a sidecar injected if the namespace is annotated, unless the deployment is annotated with a non-existing Jaeger instance?

Yes, it will get sidecar injected.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create an issue for it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to fix it in this PR? This currently isn't a problem, as the Jaeger deployment has to be explicitly annotated to reach this situation, whereas current deployment will fail once this PR is merged and the namespace gets annotated. It should be relatively simple, as the Needed could just check for label app: jaeger, or app.kubernetes.io/part-of: jaeger.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a separate PR this is already a medium size.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's just keep in mind that we probably don't want to release 1.17 with this bug.

@pavolloffay
Copy link
Member Author

@jpkrohling I have applied requested changes. It should be ready from my side.

Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to clarify #900.

Makefile Show resolved Hide resolved
pkg/inject/sidecar_test.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Per-namespace inject annotation
2 participants