open-policy-agent / kube-mgmt

Sidecar for managing OPA instances in Kubernetes.
Apache License 2.0
235 stars 105 forks source link

Kube-mgmt syncing issue with ConfigMap kube-root-ca.crt and unexpected logs #244

Closed DorB-P closed 7 months ago

DorB-P commented 7 months ago

Description:

Kube-mgmt attempts to sync ConfigMap kube-root-ca.crt from namespace OPA when applying the admission-controller.yaml from the official OPA Kubernetes Ingress Validation tutorial. Even on a clean cluster with only the OPA namespace, tls secret and the bundle-server, the following issues occur:

Expected behavior:

Actual effects: Logs show a PUT /v1/policies/opa/kube-root-ca.crt/ca.crt request every minute with "resp_status": 400.

Steps to Reproduce:

Follow the tutorial until step 6 and run the following, give it a minute:

kubectl logs -l app=opa -c opa -f -n opa
kubectl get configmap kube-root-ca.crt -o yaml

Environment:

eshepelyuk commented 7 months ago

Few notes from current kube-mgmt spare time maintainer

  1. that tutorial refers to extremely old version, you should use the latest one.
  2. the preferred way to setup kube-mgmt is to use Helm chart that is covered with e2e tests, that are executed on each release.
  3. there is no guarantee that mentioned tutorial is working at all, tbh not even sure who is updating it, if anyone.
  4. also, if you are looking for admission controll for k8s resources, you'd rather should try Gatekeeper.
DorB-P commented 7 months ago

Thanks @eshepelyuk, I missed that helm! I'll try use it as soon as I can and update the issue if fixed. It does look like the tutorial is being maintained on OPA side (opa latest version), maybe not, who knows.

regarding Gatekeeper - I am also playing with that project atm, but the functionalities I require are so much harder to implement. AFAICT:

  1. Decision logs (with logDenies option) are currently only streamed to the gatekeeper's pods stdout, and I need those, so I must have my own app in cluster to monitor and collect them (and send to my remote server). Those Gatekeeper Audit logs are not what I look for...
  2. I love the Bundle API Ideology, perfect for my use-case! I wish Gatekeeper will implement something similar - maybe even a periodic kubectl apply --kustomize kustomization.yaml where kustomization.yaml points to my personal remote library... ATM I must a have a privileged pod that will periodically sync my remote library and apply the templates and constraints to the cluster. with Bundle API this was a gift!

So yea, I'm trying Gatekeeper, which means I need to create an image that will do 1 and 2 for my needs.

Thanks again for the clarification, I'll keep you posted if this was fixed by latest kube-mgmt version

eshepelyuk commented 7 months ago

Regarding decision logs there is 2 possibilities

Regarding Gatekeeper, I can't advice myself, but looks like it has bigger community and get more attention, so you can also ask for help in their github or slack.

DorB-P commented 7 months ago

Closing for now. Will re-open if I see this happens with newer kube-mgmt