Open fhennig opened 1 year ago
I've played around with the error message a bit and the following command should be able to convert what k8s outputs to permissions we can stick in a ClusterRole object:
grep "APIGroups" | awk '{r = gensub("({.*})", "\\1,", "g"); print r }' | awk '{r = gensub("(\"[^ ]+\") ", "\\1, ", "g"); print r}' |tr -d "\n" | awk '{r = gensub("(?:|APIGroups|Resources|Verbs|ResourceNames)","\"\\1\"", "g"); print "[" r "]"}' | yq -o yaml -P > permissions.yaml
90% of this is to compensate for Kubernetes outputting something that resembles json but isn't:
After those are fixed it is really just piping it through yq
to convert it from json to yaml ..
Is this something we can document once for all operators or do we need to document this for every operator individually? What could be a good way to document this? Feels like it's very detailed and prone to become outdated.
Spent some time investigating this today. I used the Trino operator and the Secret operator for these tests as examples, as I think the secret operator is probably the most complex one and Trino as representation of a "normal" operator.
Testing was done in a kind cluster on my machine with impersonation:
helm --kube-as-user=foo install secret-operator stackable/secret-operator --version 23.11.0
The user foo had no permissions at all initially and I added permissions as I got errors during the installation process to arrive at these roles and rolebindings:
This seems to allow installing the operator itself, however the helm chart also deploys serviceaccounts for the operators themselves, which require additional privileges, since users can only grant permissions they hold themselves:
I have started adding these in a separate ClusterRole object to keep them a bit separate:
Not sure if this works yet, as I still get the full error message shown above. Maybe k8s reports all requested privileges as soon as one is missing .. I ran out of time at this point.