linkerd2 icon indicating copy to clipboard operation
linkerd2 copied to clipboard

Namespace Settings Also Applied To Services

Open lupusllc opened this issue 3 years ago • 4 comments

What problem are you trying to solve?

When adding namespace level opaque ports, this is added to pods automatically but not to their related services. When doing a linkerd check --proxy we see warnings about this and the following documentation says that's it needed.

https://linkerd.io/2.12/tasks/troubleshooting/#linkerd-opaque-ports-definition

linkerd-data-plane
------------------
√ data plane namespace exists
√ data plane proxies are ready
√ data plane is up-to-date
√ data plane and cli versions match
√ data plane pod labels are configured correctly
√ data plane service labels are configured correctly
√ data plane service annotations are configured correctly
‼ opaque ports are properly annotated
        * service ingress-ingress-nginx-controller targets the opaque port https through 443; add 443 to its config.linkerd.io/opaque-ports annotation
        * service ingress-ingress-nginx-controller targets the opaque port https through 443; add 443 to its config.linkerd.io/opaque-ports annotation
    see https://linkerd.io/2.12/checks/#linkerd-opaque-ports-definition for hints

How should the problem be solved?

Appropriate namespace configurations for Linkerd should be applied also to the services

Any alternatives you've considered?

I don't know how adding some of these values actually effect the service and the way Linkerd operates. If possible, maybe Linkerd just automatically assumes to use pod settings on the service, without the need to annotate the service. Then the linkerd check can be updated to not give these warnings.

Plus the warnings themselves are confusing, when it says the "opaque ports are properly annotated" it should say "opaque ports are not properly annotated". Otherwise, it looks like a false negative.

How would users interact with this feature?

No response

Would you like to work on this feature?

no

lupusllc avatar Feb 03 '23 17:02 lupusllc

@lupusllc services (unlike pods) are generally immutable. Not sure if this would be very helpful in the long run. A service may pass through the injector only when it is first created (and this still enforces a dependency on the control plane existing). It's easier to have them treated separately imo and it eliminates doubts and assumptions.

Plus the warnings themselves are confusing, when it says the "opaque ports are properly annotated" it should say "opaque ports are not properly annotated". Otherwise, it looks like a false negative.

That's the check's name, not the check's result. As you can see in the output you've posted, a pair of exclamation marks show up next to the check. Other (successful) checks have a tick.

mateiidavid avatar Feb 08 '23 15:02 mateiidavid

For services, are linkerd annotations only honored at their creation? Would there be a reason a service would ever not want to have the same annotations that the pods would have for opaque ports?

lupusllc avatar Feb 09 '23 03:02 lupusllc

It's not whether annotations are honored when objects are created, but more about how configuration is propagated from a namespace to a child object. An opaque port annotation on a service will be honored when traffic is flowing through the service, but if we're talking specifically about inheriting from an outer object, that will only happen when the service is created.

To get annotation inheritance to work, an object must pass through the injector (i.e admission server). An object may pass through an admission server only when it is created (or mutated). If you are going to mutate a service, you might as well add the annotation on it yourself. Which only leaves creation out.

Would there be a reason a service would ever not want to have the same annotations that the pods would have for opaque ports?

If the service does not expose a port that the pod does, yes. Services also do port mapping. In a lot of cases, we end up with mismatches. A very frequent mapping, for example:

- name: http
  port: 80
  targetPort: 8080

On the pod, we'd expect to see opaquePorts: 8080. On the service, we'd expect to see opaquePorts: 80. A client will connect to svc:80 and the request will be forwarded to pod:8080.

We could do the mapping in the injector maybe, but I'm not sure if it's worth doing...

mateiidavid avatar Feb 09 '23 15:02 mateiidavid

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 11 '23 04:05 stale[bot]