question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Enhancement] Possibility to configure more containers in a Pod (sidecars, init containers)

See original GitHub issue

Is your feature request related to a problem? Please describe.

We are deploying a Kafka cluster in our company, and we want to monitor it using the Elastic monitoring suite. To do this, we need to add a sidecar to all Kafka and Zookeeper pods. This sidecar will run Metricbeat, and will scrape metrics from Kafka/Zookeeper. Currently, it doesn’t seem possible to configure additional containers for Strimzi pods, when looking at PodTemplate.

Describe the solution you’d like

The solution would be to add a new configuration key in PodTemplate named containers, accepting a list of Container objects. This list would be merged with the containers created by Strimzi (Kafka/Zookeeper + TLS Sidecar).

Describe alternatives you’ve considered

Our workaround for now is to use k8s-sidecar-injector, and configure it to automatically inject a Metricbeats container. Then, we need to annotate the Zookeeper and Kafka pods (this is currently possible with Strimzi) to indicate to k8s-sidecar-injector to inject a container.

This solution is fine, but is cumbersome as it spreads the configuration in different Kubernetes objects.

I can try to contribute to this

If the suggested enhancement seems like a good idea, I’d be glad to try and implement it.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
3schwartzcommented, Jun 17, 2022

Hi @scholzj I’m also find this feature needed since we would like to migrate to Strimzi.

We are using Istio as a service mesh. Currently we need to implement a custom lifecycle hook such that envoy sidecars isn’t killed before Kafka have done a gracefully shutdown, see https://github.com/istio/istio/issues/7136. If it isn’t added, Kafka fails to shutdown gracefully and on restart it would need to startup from a forcefully shutdown. In cluster with a high data volume this can take quite some time. We use a start up probe since we have experienced endless restarts after forcefully shutdowns when only using ready- and liveness probes - and currently Strimzi only support these.

We are customizing the istio sidecar following the documentation from istio, and depends on istio which updates the sidecar configuration to be correct at scheduling. https://istio.io/latest/docs/setup/additional-setup/sidecar-injection/#customizing-injection

When using sidecar injectors, as proposed in this issue, to customize the istio sidecar I end up with error saying that two identical sidecars are added. I expect this is due to the order mutation admission webhook mutate the pod and I can’t control the order of mutation in current sidecar injectors.

Maybe I’m missing something related to the whole Strimzi Kafka and Istio comparability - if so I’m would be happy to learn 😃

1reaction
juergenhemeltcommented, Apr 1, 2022

I think it’s feasible. You may have to ensure certain things. Eg. you should check the exposed ports so that they do not conflict with the Kafka ports of the broker. You may also have to check for conflicting volume definitions. Or you prevent volume definitions initially. What else has to be considered?

Btw. regarding your comment on OPA in #5458 : Here is an example of how to use OPA as a sidecar: https://gitlab.com/cloud.yantra.oss/opa-gateway-sidecar It ensures the usage of up to date policies by having a central webserver hosting the policies which can be updated without having to restart the OPA pod. Seems to me like an approach which ensures up to date policies. Combined with caching it could be a perfect solution for balancing performance and timeliness of policies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending applications on Kubernetes with multi-container pods
Learn how to extend apps on Kubernetes without changing any code using multiple containers.
Read more >
Kubernetes Sidecar Container | Best Practices and Examples
Sidecar containers allow you to enhance and extend the functionalities of the main container without having to modify its codebase. Additionally, the sidecar...
Read more >
Configure sidecar and init containers - Bitnami Documentation
If additional containers are needed in the same pod (such as additional metrics or logging exporters), they can be defined using the *.sidecars...
Read more >
Init Containers | Kubernetes
This page provides an overview of init containers: specialized containers that run before app containers in a Pod. Init containers can contain ...
Read more >
Container Design Patterns for Kubernetes - Part 1 - Weaveworks
Container Design Patterns for Kubernetes - Part 1 · Sidecar pattern. The sidecar container extends and works with the primary container.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found