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

Feature request: Support env _ METHOD_ #14

Closed
ThommyH opened this issue Feb 8, 2021 · 7 comments
Closed

Feature request: Support env _ METHOD_ #14

ThommyH opened this issue Feb 8, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@ThommyH
Copy link

ThommyH commented Feb 8, 2021

Hi,
thank you for your great work on this project. Like many, we faced issues with kiwigrid/k8s-sidecar loop getting stuck and hence seek for alternatives.
We use it as part of grafana, since it is the default.
For feature matching with kiwigrid we would need the flag _ METHOD_ which allows to run the container once and then exit. In grafana, the same image for init container (fetching datasources) and sidecar (fetching dashboards) is used.
In order to replace it with kopf-k8s-sidecar one need to make a lot of changes and hacks there due to the missing flag here.

@OmegaVVeapon OmegaVVeapon added the enhancement New feature or request label Feb 8, 2021
@bergerx
Copy link

bergerx commented Feb 8, 2021

Just came here to create this exact issue just now and found it created 2 minutes ago :)

We deploy grafana as a dependency to kube-prometheus-stack chart, and here is what i changed to make this work in our stack (other users may need to use extraRoleRules instead of extraClusterRoleRules if not using searchNamespace: ALL as below) :

diff --git a/clusteraddons/monitoring-stack.yaml b/clusteraddons/monitoring-stack.yaml
index 4e087cc..e95fcbe 100644
--- a/clusteraddons/monitoring-stack.yaml
+++ b/clusteraddons/monitoring-stack.yaml
@@ -70,10 +70,26 @@ spec:
         enabled: true
         sidecar:
+          image:
+            # Workaround for connection hanging bug in kiwigrid/k8s-sidecar see these issues for details:
+            # https://github.com/kiwigrid/k8s-sidecar/issues/85
+            # https://github.com/grafana/helm-charts/issues/18
+            repository: omegavveapon/kopf-k8s-sidecar
+            tag: 1.1.1
           dashboards:
             searchNamespace: ALL
           datasources:
             searchNamespace: ALL
+          rbac:
+            # This is a workaround for using the omegavveapon/kopf-k8s-sidecar
+            # instead of kiwigrid/k8s-sidecar. omegavveapon/kopf-k8s-sidecar is
+            # implemented with kopf, and kopf requires patch verb on any
+            # resources it watches, even if its needed just to watch, 
+            # see https://github.com/zalando-incubator/kopf/issues/318
+            extraClusterRoleRules:
+            - apiGroups: [""] # "" indicates the core API group
+              resources: ["configmaps", "secrets"]
+              verbs: ["patch"]
         plugins:
           - natel-discrete-panel
           - grafana-piechart-panel

Here is the status with this config:

image

@OmegaVVeapon
Copy link
Owner

@bergerx @ThommyH I see, I suppose we could do that but it sorta defeats the purpose of using an operator, which uses a control loop, AKA "a non-terminating loop that regulates the state of a system."

If we run one loop and then kill the process, then it's obviously not a control loop...

Does the chart allow you to specify a different image for the init container and for the actual running sidecar?

@bergerx
Copy link

bergerx commented Feb 8, 2021

I checked it already before coming here, it doesn't.

@bergerx
Copy link

bergerx commented Feb 9, 2021

Seems like our best bet is to go back to kiwigrid/k8s-sidecar and provide a PR there.

@OmegaVVeapon
Copy link
Owner

I've commented on the issue open on the Grafana helm chart since it seems like most of the action is happening there.

In the meantime, I'm trying to see if I can fit this use case in kopf-k8s-sidecar but it might prove challenging.

@OmegaVVeapon
Copy link
Owner

OmegaVVeapon commented Feb 16, 2021

After trying the latest version of kiwigrid sidecar merged to the Grafana Helm chart today (1.10.0) and seeing that it hung after a couple of hours, I decided to give this a try...

To my surprise, it wasn't that difficult to add a separate codepath for the LIST METHOD using kopf's embedding functionality.

Tentative PR in #16

Have a few details to figure out but the core functionality is 100% working for both LIST and WATCH.

Will leave the pod running overnight just to check I didn't somehow affect its stability.

@OmegaVVeapon
Copy link
Owner

The PR has been merged. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants